Forum > General

I did something wrong here i think

(1/4) > >>

captian jaster:

--- Code: --- unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  Menus, CRT;

type

  { TForm1 }

  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    BWallet: TMenuItem;
    OpenWallet: TMenuItem;
    EditWallet: TMenuItem;

    procedure OpenWalletClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

Type
 STR = string;
 Walletrec = Record
 Balance,Addto,Remove : STR;
 WFile : Text;
 end;

var
  Form1: TForm1;
  WalletV : WalletRec;
  ReadSTR : string;
implementation

{ TForm1 }



procedure TForm1.OpenWalletClick(Sender: TObject);
BEGIN
  ClrScr;
  Writeln('Please Wait...');
  AssignFile(WalletV.WFile,'Wallet.dat');
  While NOT FIleexists('Wallet.Dat') Do
  begin
    ClrScr;
    Writeln('You Do Not Have a wallet yet!');
    writeln('Input your current wallet balance');
    Readln(WalletV.Balance);
    Rewrite(WalletV.WFile);
    writeln(WalletV.WFile,WalletV.Balance);
    Closefile(WalletV.WFile);
    writeln('Your Wallet Has been saved!');
    Delay(1000);
    ClrScr;
  end;
  ClrScr;
  Reset(WalletV.WFile);
  writeln('Current Balance:');
  While NOT EoF(WalletV.WFile) Do
  begin
    Readln(WalletV.WFile,ReadSTR);
    writeln(ReadSTR);
  end;
END;

initialization
  {$I unit1.lrs}

end.   
--- End code ---

If i click the Open wallet windows fails to respond

Martin_fr:
writeln and readeln (unless given a file descriptor) goes to the console (the dos like window).

Since I see Form1 => you have a GUI (Graphical User Interface) application.
By default a GUI app does not have a console, so your readln/writeln can not work.

You can go to the project or compiler option, and enable a console => but that is pointless.

You want to but some TEdit and TLabel on your form, where the user must input.... (or better pop up a 2nd form, but that's for later)

captian jaster:
Could you explain how to use the TEdit and Tlabel
Thanks

Troodon:

--- Quote from: captian jaster on March 08, 2010, 11:50:56 pm ---Could you explain how to use the TEdit and Tlabel

--- End quote ---

Try these: http://docwiki.embarcadero.com/RADStudio/en/Edit_Controls and http://docwiki.embarcadero.com/RADStudio/en/Labels

captian jaster:
what im having trouble understanding is how do i put a text in the program with that code? can i have an example...

Navigation

[0] Message Index

[#] Next page

Go to full version