-
Grand Future Air Dried Fresh Beef Dog Food
Air Dried Dog Food | Fresh Beef

Carnivore Diet for Dogs

Go Back   Automotive Forums Car Chat > Coffee Break (Off-Topic) > COMPLETELY off-topic
Register FAQ Community
COMPLETELY off-topic Talk about anything other than cars. But you can't be mad and angry in this forum!
Reply Show Printable Version Show Printable Version | Subscription Subscribe to this Thread
 
Thread Tools
  #1  
Old 04-02-2003, 04:23 PM
Twist's Avatar
Twist Twist is offline
AF Enthusiast
 
Join Date: Aug 2001
Posts: 1,027
Thanks: 0
Thanked 0 Times in 0 Posts
Programming

//Twist's C Post!

#include <stdio.h>

void af();

int main(void)
{
char Answer;
char Prog[80];

printf("\nDoes any one here know how to program?\n");
printf("Enter 'y' if you do know how to program or 'n' if you dont: ");
scanf("%c", &Answer);

if (Answer == 'y' || Answer == 'Y')
{
printf("\nWhich do you know? ");
scanf("%s", &Prog);
printf("\nYou know %s. Good for you.\n", Prog);
}

else
{
printf("\nYou're lucky! You don't have to suffer through functions and
the like.");
}

printf("\nThis is C programming language. I also know Fortran.");
af();

return 0;
}

void af()
{
printf("\nAF RULES!\n");
}
__________________
Initialize your Dreams!
Master of the invisble post...


Last edited by Twist; 04-02-2003 at 07:49 PM.
Reply With Quote
  #2  
Old 04-02-2003, 04:25 PM
Twist's Avatar
Twist Twist is offline
AF Enthusiast
Thread starter
 
Join Date: Aug 2001
Posts: 1,027
Thanks: 0
Thanked 0 Times in 0 Posts
For the non-programmers, that basically said this:

Does any one here know how to program?
Enter y if you do know how to program or n if you dont:

If you do:
Which do you know?
You know "blah program"

If you don't know how to program:
You're lucky! You don't have to suffer through functions and the like.


This is C programming language. I also know Fortran.

AF RULES!
__________________
Initialize your Dreams!
Master of the invisble post...


Last edited by Twist; 04-02-2003 at 07:56 PM.
Reply With Quote
  #3  
Old 04-02-2003, 04:34 PM
Rich's Avatar
Rich Rich is offline
Never Fear, Rich is here!
 
Join Date: Apr 2001
Posts: 2,663
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to Rich
Certified in VB6
A+ Certified
MCSE Certified

Also studied HTML, Javascript, C/C+, Fortran, Turing.

All of this in 3yrs at college, which I will be graduating from in ~1month. (With honors )
__________________
My Wheels
15' Kia Soul SX 2.0L
13' GMC 1500 P/U 5.3L
Reply With Quote
  #4  
Old 04-02-2003, 04:35 PM
Amish_kid's Avatar
Amish_kid Amish_kid is offline
AF Enthusiast
 
Join Date: Jun 2002
Posts: 2,277
Thanks: 0
Thanked 0 Times in 0 Posts
//Af Programming Amish_kid

#include<iostream.h>

int main()
{
cout<<" Yeah MANG C++ ROXXORS! if you agree press 1 if not 2 "<<endl;
cout<<" Yay I << answer <<" programming"<<endl;
int answer;
if (answer == 1)
cout<<"You Like Programming"<<endl;
if (answer == 2)

cout<<"Programming is for nerd/I SUCK "<<endl;
return(0);
}
i know some of 'er is wrong i need a debugger
Reply With Quote
  #5  
Old 04-02-2003, 07:04 PM
Marc-OS's Avatar
Marc-OS Marc-OS is offline
AF Enthusiast
 
Join Date: Dec 2001
Posts: 2,254
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via ICQ to Marc-OS Send a message via AIM to Marc-OS
I learned C+ and BASIC when I was 12, but I quickly forgot it when I started getting into cars instead of computers.
Reply With Quote
  #6  
Old 04-02-2003, 07:31 PM
Oz's Avatar
Oz Oz is offline
Aussie Mod
 
Join Date: Dec 2001
Posts: 13,239
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via AIM to Oz
I tried compiling Twist's code in Bloodshed, but it quickly spat the dummy, and I don't have the time or inclination to debug it. :finger:

However, this thread is cool. I'm first year comp sci dtudent learning CPP. Here's some code from yesterday:

#include <iostream>
#include <string>
#include <cstdlib>
#include <fstream>
#include <sstream>

int makehtml(int a, int b)
{
ofstream ofs;
ofs << "<html>" << endl;
ofs << "<head><title>All Combinations of " << a << " and " << b << "</title></head>" << endl;
ofs << "<body>" << endl;
int temp;
if (a > b)
{
temp == a;
a == b;
b == temp;
}
for (int combcount = 0; (combcount <= b); combcount = combcount++)
{
for (int i = 0; (i <= b); i = 0)
{
ofs << combcount << i << " <br>" << endl;
i = i++;
}
}
ofs << "</body>" << endl;
ofs << "</html>" << endl;
return 0;
}


int main()
{
ofstream ofs;
string filepath = "h:\\myhtml.html";
ofs.open (filepath, ios::out);
cout << "Enter 2 numbers: " << endl;
int num1;
int num2;
cin >> num1 >> num2;
cout << "Done, created file " << filepath << endl;
makehtml(num1, num2);
ofs.close;
system("Pause");
return 0;
}

---
Not quite working yet, but the programmers here should be able to see what it does.

Oz
__________________
Quote:
Originally Posted by RaeRae1
Blessed are the cracked ones for they are the ones that let in the light.
Reply With Quote
  #7  
Old 04-02-2003, 07:39 PM
speediva's Avatar
speediva speediva is offline
AF Fanatic
 
Join Date: Sep 2001
Posts: 9,253
Thanks: 110
Thanked 46 Times in 43 Posts
Send a message via AIM to speediva Send a message via Yahoo to speediva
Tangie is taking Basic either this summer, or next Fall. If I take basic over the summer, then I'll be taking Visual Basic in the Fall. My IT major friends have told me that Visual Basic will be easier to manage than C or C++ God I hope so.
__________________
Like a boy - but BETTER!

2005 Subaru Forester 2.5X
1997 Honda Civic EX Coupe

Inform yourself:
AF User Guidelines
Reply With Quote
  #8  
Old 04-02-2003, 07:49 PM
Twist's Avatar
Twist Twist is offline
AF Enthusiast
Thread starter
 
Join Date: Aug 2001
Posts: 1,027
Thanks: 0
Thanked 0 Times in 0 Posts
@#$@#ing semi-colons. Try it now!

That and I don't think the header file "af.h" exists. So I took that out.
__________________
Initialize your Dreams!
Master of the invisble post...

Reply With Quote
  #9  
Old 04-02-2003, 09:00 PM
YellowMaranello's Avatar
YellowMaranello YellowMaranello is offline
AF Enthusiast
 
Join Date: Aug 2001
Posts: 2,228
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to YellowMaranello
I used to play around in qbasic a long time ago...
Reply With Quote
  #10  
Old 04-03-2003, 12:09 AM
Oz's Avatar
Oz Oz is offline
Aussie Mod
 
Join Date: Dec 2001
Posts: 13,239
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via AIM to Oz
Quote:
Originally posted by YellowMaranello
I used to play around in qbasic a long time ago...
that was my first port of call. I took out af.h and added a few semi-colons. I'll compile it and upload the program in .exe form to my personal webspace when I get home in about 5 hours. Cool coding though. Just learning?
__________________
Quote:
Originally Posted by RaeRae1
Blessed are the cracked ones for they are the ones that let in the light.
Reply With Quote
  #11  
Old 04-03-2003, 05:58 AM
Oz's Avatar
Oz Oz is offline
Aussie Mod
 
Join Date: Dec 2001
Posts: 13,239
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via AIM to Oz
Oz's compilation of Twist's code. v1.1
-Added system pause
-Added some more lines


http://www.froggy.com.au/gdavies/twist.exe
__________________
Quote:
Originally Posted by RaeRae1
Blessed are the cracked ones for they are the ones that let in the light.
Reply With Quote
  #12  
Old 04-03-2003, 07:14 AM
Twist's Avatar
Twist Twist is offline
AF Enthusiast
Thread starter
 
Join Date: Aug 2001
Posts: 1,027
Thanks: 0
Thanked 0 Times in 0 Posts
I'm in my second week of learning C. I just got done learning Fortan for a month and a half.
__________________
Initialize your Dreams!
Master of the invisble post...

Reply With Quote
  #13  
Old 04-03-2003, 08:10 AM
YogsVR4's Avatar
YogsVR4 YogsVR4 is offline
Funding the welfare state
 
Join Date: Feb 2001
Posts: 17,795
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via AIM to YogsVR4
EDIT: I don't know why the post lost all the indentations.

Here is part of a little component I was whipping up yesterday. Pretty straight forward. (didn't include the DFM so you wont have any luck if you know the compiler)

btw - Does anyone else here besides me know what this is written in?


unit uAttachment;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
UBASICFORM, DBActns, StdActns, ActnList, MlsStandard, ImgList, MlsWin32,
MlsKeystrokes, MLSAboutBox, Menus, MLSStore, ComCtrls, ToolWin,
MlsStatusBar, ExtCtrls, MlsAdditional, registry, DBTables, MlsDataControls, MlsDataAccess,
Db, Grids, DBGrids, StdCtrls, Mask, DBCtrls, MlsDbFunctions, MLSDBComboEdit,
shellapi, MLSLocatorButton;

type
TfAttachment = class(Tfmain)
pCurrentEntries: TMlsPanel;
pPreview: TMlsPanel;
lvAttachment: TMlsListView;
imgAttachment: TMlsImageList;
pupListview: TMlsPopupMenu;
New2: TMenuItem;
Cancel2: TMenuItem;
N7: TMenuItem;
Cancel3: TMenuItem;
Delete2: TMenuItem;
N8: TMenuItem;
Refresh1: TMenuItem;
qosAttachment: TMlsQuery;
dsosAttachment: TMlsDataSource;
updtsqlosAttachment: TMlsUpdateSQL;
qosAttachmentPK: TIntegerField;
qosAttachmentTableName: TStringField;
qosAttachmentTableNamePK: TIntegerField;
qosAttachmentAttachmentPath: TStringField;
qosAttachmentIsPathValid: TStringField;
qosAttachmentfkosCompanyWorker: TIntegerField;
qosAttachmentAttachmentDate: TDateTimeField;
qosAttachmentDescription: TStringField;
qosAttachmentNote: TMemoField;
MlsPanel1: TMlsPanel;
pNote: TMlsPanel;
dbMemo: TMlsDBMemo;
lAttachment: TMlsLabel;
dbAttachmentPath: TMLSDBFileNameEdit;
dbDescription: TMlsDbEdit;
lDescription: TMlsLabel;
lNote: TMlsLabel;
imageInvalidPath: TMlsImage;
lInvalidPath: TMlsLabel;
dbCreationDate: TMlsDbEdit;
lAttachmentDate: TMlsLabel;
MlsLabel1: TMlsLabel;
dbUser: TMlsDbEdit;
qCompanyWorker: TMlsQuery;
qCompanyWorkerpk: TIntegerField;
qCompanyWorkerfullname: TStringField;
dsCompanyWorker: TMlsDataSource;
qosAttachmentWorkerName: TStringField;
pp: TMenuItem;
alProperties: TAction;
procedure SetListViewItems;
procedure FormShow(Sender: TObject);
procedure Refresh1Click(Sender: TObject);
procedure qosAttachmentNewRecord(DataSet: TDataSet);
procedure AfterDelete(DataSet: TDataSet);
procedure qosAttachmentAfterCancel(DataSet: TDataSet);
procedure qosAttachmentBeforeDelete(DataSet: TDataSet);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure qosAttachmentAfterScroll(DataSet: TDataSet);
procedure lvAttachmentChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
procedure qosAttachmentBeforePost(DataSet: TDataSet);
procedure UpdateListView;
procedure AddNewNodeToTree;
procedure lvAttachmentDblClick(Sender: TObject);
procedure qosAttachmentAfterPost(DataSet: TDataSet);
procedure UpdateIcon(bEdit : boolean);
procedure alPropertiesExecute(Sender: TObject);
procedure alPropertiesUpdate(Sender: TObject);
procedure lvAttachmentChanging(Sender: TObject; Item: TListItem;
Change: TItemChange; var AllowChange: Boolean);
private
public
fkosCompanyWorker : Integer;
TableName : String;
TableNamePK : Integer;
procedure CheckChanges;
end;

var
fAttachment: TfAttachment;

implementation

Uses UnitNodeData, MLSAttachment;

{$R *.DFM}


procedure TfAttachment.SetListViewItems;
Var
recordsExist : boolean;
begin
recordsExist := false;

with qosAttachment do begin
first;
while not eof do begin
AddNewNodeToTree;
recordsExist := true;
next;
end;
First;
end;

If recordsExist then lvAttachment.Items[0].Selected := true;
end;

procedure TfAttachment.FormShow(Sender: TObject);
begin
inherited;
// Build the list view
Refresh1.Click;
end;

procedure TfAttachment.alPropertiesExecute(Sender: TObject);
var
sei: TShellExecuteInfo;
begin
inherited;
FillChar(sei, SizeOf(sei), 0);
sei.cbSize := SizeOf(sei);
If Assigned(lvAttachment.Selected) and Assigned(lvAttachment.Selected.data)
then sei.lpFile := PChar(TNodeData(lvAttachment.Selected.data).Desc);
sei.lpVerb := 'properties';
sei.fMask := SEE_MASK_INVOKEIDLIST;
ShellExecuteEx(@sei);
end;

procedure TfAttachment.alPropertiesUpdate(Sender: TObject);
begin
inherited;
if lvAttachment.SelCount > 0 Then alProperties.Enabled := true
else alProperties.Enabled := false;
end;

procedure TfAttachment.lvAttachmentChanging(Sender: TObject;
Item: TListItem; Change: TItemChange; var AllowChange: Boolean);
begin
inherited;
if qosAttachment.state in [dsedit,dsInsert] then AllowChange := false
else AllowChange := true;
end;

procedure TfAttachment.Refresh1Click(Sender: TObject);
begin
inherited;
lvAttachment.Items.Clear;
SetListViewItems;
end;

procedure TfAttachment.qosAttachmentNewRecord(DataSet: TDataSet);
begin
inherited;
// assign the pk, fkoscompanymodule, tablename, tablenamepk, attachmentdate

AssignPkIfNeeded(qosAttachment,'osAttachment');

qosAttachment.fieldbyname('tablename').asstring := TableName;
qosAttachment.fieldbyname('tablenamepk').asinteger := tableNamePK;
qosAttachment.fieldbyname('attachmentdate').AsDate Time := date;

// clean this up after testing....... dwg
if fkosCompanyWorker <> 0 then
qosAttachment.fieldbyname('fkoscompanyworker').asi nteger := fkosCompanyWorker
else
qosAttachment.fieldbyname('fkoscompanyworker').asi nteger := 16;
end;

procedure TfAttachment.AfterDelete(DataSet: TDataSet);
begin
inherited;
lvAttachment.Selected.Free;
MlsDbFunctions.ApplyDatabaseUpdates([tDbDataset(DataSet)]);
end;

procedure TfAttachment.qosAttachmentAfterCancel(DataSet: TDataSet);
begin
inherited;
RevertRecordIfNeeded(tDbDataset(DataSet), True);
Refresh1.Click;
end;

procedure TfAttachment.qosAttachmentBeforeDelete(DataSet: TDataSet);
begin
inherited;
Case MessageDlg('Delete the attachment?' + #13#10 +
'Note: This will not delete the document.',mtConfirmation, [mbYes,mbNo,mbCancel], 0) of
//mrYes:
mrNo: Abort;
mrCancel: Abort;
end;
end;

procedure TfAttachment.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
inherited;
try
CanClose := True;
CheckChanges;
except
CanClose := False;
end;
end;

procedure TfAttachment.CheckChanges;
begin
if qosAttachment.State in dsEditModes then begin
case MessageDlg('Do you want to save changes before exiting?',
mtConfirmation, [mbYes, mbNo, mbCancel], 0) of
mrYes : qosAttachment.Post;
mrNo : qosAttachment.Cancel;
mrCancel : Abort;
end;
end;
end;

procedure TfAttachment.qosAttachmentAfterScroll(DataSet: TDataSet);
begin
inherited;
If qosAttachment.fieldbyname('ispathvalid').asstring = 'No' then begin
imageInvalidPath.Visible := true;
lInvalidPath.Visible := true;
end
else begin
imageInvalidPath.Visible := false;
lInvalidPath.Visible := false;
end;
end;

procedure TfAttachment.lvAttachmentChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
inherited;
if Assigned(lvAttachment.Selected) and Assigned(lvAttachment.Selected.data)
and (lvAttachment.SelCount > 0) then
qosAttachment.locate('PK',TNodeData(lvAttachment.S elected.data).pk,[]);
end;

procedure TfAttachment.qosAttachmentBeforePost(DataSet: TDataSet);
begin
inherited;
With qosAttachment do begin
If state = dsedit then begin
If (fieldbyname('attachmentpath').NewValue <> fieldbyname('attachmentpath').OldValue) and
(fieldbyname('description').NewValue = fieldbyname('description').OldValue) then begin

Case MessageDlg('The current file has a different name then in the description.' + #13#10 +
'Would you like the description to match the file name?',mtConfirmation, [mbYes,mbNo,mbCancel], 0) of
mrYes: fieldbyname('Description').asstring := ExtractFileName(fieldbyname('attachmentpath').asst ring);
//mrNo: Do nothing ;
mrCancel: Abort;
end;
end;
end;

If FileExists(fieldbyname('attachmentpath').asstring) Then
fieldbyname('ispathvalid').asstring := 'Yes'
else
fieldbyname('ispathvalid').asstring := 'No';

fieldbyname('attachmentpath').asstring := ExpandUNCFileName(fieldbyname('attachmentpath').as string);

If fieldbyname('Description').asstring = '' Then
fieldbyname('Description').asstring := ExtractFileName(fieldbyname('attachmentpath').asst ring);
end;

qosAttachmentAfterScroll(DataSet);
end;

procedure TfAttachment.UpdateListView;
Var
i : integer;
begin
with qosAttachment do begin
for i := 0 to (lvAttachment.Items.Count -1) do begin
If Assigned(lvAttachment.items[i].data)
And (TNodeData(lvAttachment.items[i].data).pk = strtoint(fieldbyname('pk').asstring)) then begin
lvAttachment.Selected.Caption := fieldbyname('Description').asstring;
TNodeData(lvAttachment.Selected.data).Desc := fieldbyname('attachmentpath').asstring;
UpdateIcon(True);
exit;
end;
end;
end;

//add new node because the edited one could not be found.
AddNewNodeToTree;
end;

procedure TfAttachment.AddNewNodeToTree;
Var
NodeData : TNodeData;
begin
lvAttachment.SortType := stNone;
with qosAttachment do begin
NodeData := TNodeData.Create;
NodeData.PK := fieldbyname('pk').asinteger;
NodeData.Desc := fieldbyname('attachmentpath').asstring;

lvAttachment.Items.Add;
lvAttachment.Items[lvAttachment.Items.count -1].Caption := fieldbyname('Description').asstring;
lvAttachment.Items[lvAttachment.Items.count -1].Data := NodeData;
lvAttachment.Items[lvAttachment.Items.count -1].Selected := true;
Application.ProcessMessages;

UpdateIcon(False);
end;
lvAttachment.SortType := stText;
end;

procedure TfAttachment.lvAttachmentDblClick(Sender: TObject);
var
FileHandle : Integer;
begin
inherited;
If Not Assigned(lvAttachment.Selected) or Not Assigned(lvAttachment.Selected.data) then begin
Showmessage('Cannot find information for selected file.');
Exit;
end;

FileHandle := FileOpen(TNodeData(lvAttachment.Selected.data).des c, fmOpenWrite or fmShareDenyNone);
if FileHandle > 0 then begin
FileClose(FileHandle);
Try
ShellExecute(Handle, PChar('open'), PChar(TNodeData(lvAttachment.Selected.data).desc),
nil,nil, SW_NORMAL);
except
Showmessage('Cannot open selected file.');
end;
end
else Showmessage('Cannot access selected file.');
end;

procedure TfAttachment.qosAttachmentAfterPost(DataSet: TDataSet);
Var
doInsert : boolean;
begin
inherited;
If qosAttachment.State = dsinsert then doInsert := true
else doInsert := false;

MlsDbFunctions.ApplyDatabaseUpdates([tDbDataset(DataSet)]);

if doInsert then AddNewNodeToTree
else begin
lvAttachment.SortType := stNone;
UpdateListView;
lvAttachment.SortType := stText;
end;
end;

procedure TfAttachment.UpdateIcon(bEdit : boolean);
Var
MyhInst: HINST;
lpIcon: Word;
IconHandle : HICON;
icn : ticon;
begin
MyhInst := 0;
with qosAttachment do begin
If FileExists(fieldbyname('attachmentpath').asstring) Then begin
IconHandle := ExtractAssociatedIcon(MyhInst, PChar(fieldbyname('attachmentpath').asstring),lpIc on);
icn := TIcon.Create;
try
icn.Handle := IconHandle;
imgAttachment.AddIcon(icn);
If bEdit then lvAttachment.Selected.imageindex := (imgAttachment.Count -1)
else lvAttachment.Items[lvAttachment.Items.count -1].imageindex := (imgAttachment.Count -1) ;
Finally
FreeAndNil(icn);
end;
End
Else lvAttachment.Items[lvAttachment.Items.count -1].imageindex := 0;
end;
end;


end.













__________________
Resistance Is Futile (If < 1ohm)
Reply With Quote
  #14  
Old 04-03-2003, 08:29 AM
Deakins's Avatar
Deakins Deakins is offline
AF Enthusiast
 
Join Date: Jul 2002
Posts: 1,879
Thanks: 0
Thanked 1 Time in 1 Post
Delphi?
__________________
The ringing of the division bell, have stopped...
AF User Guidelines
Reply With Quote
  #15  
Old 04-03-2003, 09:06 AM
YogsVR4's Avatar
YogsVR4 YogsVR4 is offline
Funding the welfare state
 
Join Date: Feb 2001
Posts: 17,795
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via AIM to YogsVR4
Quote:
Originally posted by Deakins
Delphi?
Correct













__________________
Resistance Is Futile (If < 1ohm)
Reply With Quote
 
Similar Threads
Thread Thread Starter Forum Replies Last Post
06 Camry LE - How to program keyless entry pshrivas Camry/Camry Hybrid/Vista 0 03-20-2009 02:54 PM
How to put BCM into program mode? (Where is BCM/MALL fuse?) copchick527 Grand AM 5 03-02-2009 03:30 PM
Programming Instructions for programming instructions EZSDEI474V eddiem Engineering/ Technical 1 03-18-2005 05:15 PM

Reply

POST REPLY TO THIS THREAD

Go Back   Automotive Forums Car Chat > Coffee Break (Off-Topic) > COMPLETELY off-topic


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -5. The time now is 03:29 PM.

Community Participation Guidelines | How to use your User Control Panel

Powered by: vBulletin | Copyright Jelsoft Enterprises Ltd.
 
 
no new posts