|
|
| Search | Car Forums | Gallery | Articles | Helper | Air Dried Fresh Beef Dog Food | IgorSushko.com | Corporate |
|
|||||||
| COMPLETELY off-topic Talk about anything other than cars. But you can't be mad and angry in this forum! |
![]() |
Show Printable Version |
Subscribe to this Thread
|
|
|
Thread Tools |
|
#1
|
||||
|
||||
|
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. |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
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 |
|
#4
|
||||
|
||||
|
//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 |
|
#5
|
||||
|
||||
|
I learned C+ and BASIC when I was 12, but I quickly forgot it when I started getting into cars instead of computers.
|
|
#6
|
||||
|
||||
|
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:
|
|
#7
|
||||
|
||||
|
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 |
|
#8
|
||||
|
||||
|
@#$@#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... |
|
#9
|
||||
|
||||
|
I used to play around in qbasic a long time ago...
__________________
My dream, feel free to donate some money to help
|
|
#10
|
||||
|
||||
|
Quote:
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:
|
|
#11
|
||||
|
||||
|
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:
|
|
#12
|
||||
|
||||
|
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... |
|
#13
|
||||
|
||||
|
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) |
|
#14
|
||||
|
||||
|
Delphi?
|
|
#15
|
||||
|
||||
|
Quote:
![]()
__________________
Resistance Is Futile (If < 1ohm) |
| ||||||||||||||||||||||||||||
![]() |
POST REPLY TO THIS THREAD |
![]() |
|
|