Write to And Read From a File

[b][red]This message was edited by DarknessX at 2006-9-28 18:44:50[/red][/b][hr]
[b][red]This message was edited by DarknessX at 2006-9-28 18:27:27[/red][/b][hr]
Ok, well, I'm making a text-based RPG game, basically just for fun. I'm trying to add a save function to it, and I was wondering how I would do the following:
a) Write the username/password to the file
b) name the file as the username
c) write the character data (Race, Subrace)

d) Load all of that information and apply it to the variables.

I know its mostly simple, but I could never get it to work...
The source is at: http://66.90.118.23/~darknessx/eg_BETA_v0.01.txt
The part where I want the writing to file stuff to go, is where it says {Save Character File}
And the load character data would go after the:
if previous = 'no' then
...
end;
block, in an else.
If you need more info, then please tell me. And I could write the data to a file fine (as long as its all on one line, which I don't want) but i cant load the data... it should save the files as user.mqs, in text format.
This program does work, if you compile it and run it. Thanks for all help..

And the format of the text file (how i want it, atleast) should be like this: without the comments of course.

Thanks again, in advance, for any help.

Note: I'm asking only for code how to do the above- this code will be addeed to, so i can store the characters level, where in the program they are at, his statistics, etc, which is why im so picky about format.
I'm mostly using your example for learning purposes, so if you could please post the entire code, however it would need to be (not my program, but the code I'm asking for...) so that I can figure this out?
I tried to find tutorials on loading the contents, but I could not find this particular way of loading the file. And I added this note because I wanted to make sure that you don't misread it and only post an example code. And if it is too much to code, then please tell me, and just give me an example that I can do a look-and-replace on. thanks!

EDIT:
My site might go down, so heres the source:
Source:[code]
program Magic_Quest;
var User: String;
var Pass: String;
var Serial: String;
var previous: String;
var Race: String;
var sRace: String;
var confirm: String;
{battle system}
begin
begin
{The battle system, when devoloped, will be put here.}
end;

begin
writeln('Have you already played the game? Type y for yes and n for no.');
readln(previous);
if previous = 'n' then
begin

{begin game creation, IE, race, character, etc.}

begin
{race selection}
Writeln('Please choose a race. Your choices are:');
Writeln('Dwarf');
Writeln('Human');
Writeln('Elf');
Writeln('Shapeshifter');
Writeln('Orc');
Writeln('Knight');
Writeln('Halfling');
Writeln('Titan');
writeln('Minotaur');
writeln('Gnome');
readln(Race);
end;

begin
{subrace selection}
Writeln('Now please choose your subrace/career. Your choices are:');
Writeln('Soldier');
Writeln('Mageling');
Writeln('Archer');
Writeln('Shadow');
Writeln('SunFire');
Writeln('Spy');
Writeln('Cuthroat');
Writeln('Caravaneer');
Writeln('Smithy');
Readln(sRace);
end;

{Username}
begin
Writeln('Please enter the name for your character.');
Readln(User);
{Password}
Writeln('Please enter a password.');
Readln(Pass);
end;


{confirmation}
begin
writeln;
Writeln('Your race is: ');
Writeln(Race);
writeln;
Writeln('Your Sub-Race/Career is: ');
Writeln(sRace);
writeln;
Writeln('Your characters name is:');
Writeln(User);
writeln;
Writeln('Is this correct?');
Writeln('If it is not, then type n for no. If it is, type y for yes.');
Readln(confirm);
if confirm = 'y' then
{save character file}
Writeln('Sorry, but the saving function is not available at this time.')
end;
end;
end;
{Login section. This will be where all the login information goes.}
begin
writeln('Welcome! Please login to your account.');
writeln('Please note, at this time, login, saving, and other features do not work.');
end;

{load saved file from previous play}
Writeln('Saved files cannot be loaded.');
end.
[/code]
Savefile Format:
[code]
Username {var User;}
Password {var Pass;}
Race {var Race;}
Subrace {var sRace;}
[/code]

Comments

  • : [b][red]This message was edited by DarknessX at 2006-9-28 18:44:50[/red][/b][hr]
    : [b][red]This message was edited by DarknessX at 2006-9-28 18:27:27[/red][/b][hr]
    : Ok, well, I'm making a text-based RPG game, basically just for fun. I'm trying to add a save function to it, and I was wondering how I would do the following:
    : a) Write the username/password to the file
    : b) name the file as the username
    : c) write the character data (Race, Subrace)
    :
    : d) Load all of that information and apply it to the variables.
    :
    : I know its mostly simple, but I could never get it to work...
    : The source is at: http://66.90.118.23/~darknessx/eg_BETA_v0.01.txt
    : The part where I want the writing to file stuff to go, is where it says {Save Character File}
    : And the load character data would go after the:
    : if previous = 'no' then
    : ...
    : end;
    : block, in an else.
    : If you need more info, then please tell me. And I could write the data to a file fine (as long as its all on one line, which I don't want) but i cant load the data... it should save the files as user.mqs, in text format.
    : This program does work, if you compile it and run it. Thanks for all help..
    :
    : And the format of the text file (how i want it, atleast) should be like this: without the comments of course.
    :
    : Thanks again, in advance, for any help.
    :
    : Note: I'm asking only for code how to do the above- this code will be addeed to, so i can store the characters level, where in the program they are at, his statistics, etc, which is why im so picky about format.
    : I'm mostly using your example for learning purposes, so if you could please post the entire code, however it would need to be (not my program, but the code I'm asking for...) so that I can figure this out?
    : I tried to find tutorials on loading the contents, but I could not find this particular way of loading the file. And I added this note because I wanted to make sure that you don't misread it and only post an example code. And if it is too much to code, then please tell me, and just give me an example that I can do a look-and-replace on. thanks!
    :
    : EDIT:
    : My site might go down, so heres the source:
    : Source:[code]
    : program Magic_Quest;
    : var User: String;
    : var Pass: String;
    : var Serial: String;
    : var previous: String;
    : var Race: String;
    : var sRace: String;
    : var confirm: String;
    : {battle system}
    : begin
    : begin
    : {The battle system, when devoloped, will be put here.}
    : end;
    :
    : begin
    : writeln('Have you already played the game? Type y for yes and n for no.');
    : readln(previous);
    : if previous = 'n' then
    : begin
    :
    : {begin game creation, IE, race, character, etc.}
    :
    : begin
    : {race selection}
    : Writeln('Please choose a race. Your choices are:');
    : Writeln('Dwarf');
    : Writeln('Human');
    : Writeln('Elf');
    : Writeln('Shapeshifter');
    : Writeln('Orc');
    : Writeln('Knight');
    : Writeln('Halfling');
    : Writeln('Titan');
    : writeln('Minotaur');
    : writeln('Gnome');
    : readln(Race);
    : end;
    :
    : begin
    : {subrace selection}
    : Writeln('Now please choose your subrace/career. Your choices are:');
    : Writeln('Soldier');
    : Writeln('Mageling');
    : Writeln('Archer');
    : Writeln('Shadow');
    : Writeln('SunFire');
    : Writeln('Spy');
    : Writeln('Cuthroat');
    : Writeln('Caravaneer');
    : Writeln('Smithy');
    : Readln(sRace);
    : end;
    :
    : {Username}
    : begin
    : Writeln('Please enter the name for your character.');
    : Readln(User);
    : {Password}
    : Writeln('Please enter a password.');
    : Readln(Pass);
    : end;
    :
    :
    : {confirmation}
    : begin
    : writeln;
    : Writeln('Your race is: ');
    : Writeln(Race);
    : writeln;
    : Writeln('Your Sub-Race/Career is: ');
    : Writeln(sRace);
    : writeln;
    : Writeln('Your characters name is:');
    : Writeln(User);
    : writeln;
    : Writeln('Is this correct?');
    : Writeln('If it is not, then type n for no. If it is, type y for yes.');
    : Readln(confirm);
    : if confirm = 'y' then
    : {save character file}
    : Writeln('Sorry, but the saving function is not available at this time.')
    : end;
    : end;
    : end;
    : {Login section. This will be where all the login information goes.}
    : begin
    : writeln('Welcome! Please login to your account.');
    : writeln('Please note, at this time, login, saving, and other features do not work.');
    : end;
    :
    : {load saved file from previous play}
    : Writeln('Saved files cannot be loaded.');
    : end.
    : [/code]
    : Savefile Format:
    : [code]
    : Username {var User;}
    : Password {var Pass;}
    : Race {var Race;}
    : Subrace {var sRace;}
    : [/code]
    :
    There are several options: text-file, typed file, and untyped file. The basic code layout for writing is this, no matter which file type:
    [code]
    Assign(FileVar, FileName);
    Rewrite(FileVar);
    { Write statements, see below }
    Close(FileVar);
    [/code]
    Typed files can only support write() and BlockWrite().
    Text files can also support writeln(), which includes a line ending.
    Untyped files only support BlockWrite().
    For examples see the help files, under: Assign(), Rewrite(), BlockWrite(), Write(), Close(), "file", and "text".

    Reading is very similar, but with 2 differences. The Rewrite() statement becomes a Reset() statement, and all Write()s must be Read()s.
    Here are a few examples:
    [code]
    var
    s: string;
    i: integer;
    f: text;
    begin
    s := 'Hello world';
    i := 10;
    Assign(f, 'File1.txt');
    Rewrite(f);
    writeln(f, s);
    writeln(f, i);
    Close(f);
    end.
    [/code]
    [code]
    var
    i: integer;
    f: file of integer; { typed file }
    begin
    Assign(f, 'File2.txt');
    Rewrite(f);
    for i := 0 to 99 do
    write(f, i);
    Close(f);
    end.
    [/code]
    [code]
    var
    s: string;
    i: integer;
    f: file; { untyped file }
    begin
    s := 'Hello world';
    i := 10;
    Assign(f, 'File3.txt');
    Rewrite(f, 1); { byte record length }
    BlockWrite(f, i, SizeOf(i));
    BlockWrite(f, s, SizeOf(s));
    Close(f);
    end.
    [/code]

  • [b][red]This message was edited by DarknessX at 2006-10-2 14:5:30[/red][/b][hr]
    [b][red]This message was edited by DarknessX at 2006-10-2 13:7:15[/red][/b][hr]
    : There are several options: text-file, typed file, and untyped file. The basic code layout for writing is this, no matter which file type:
    : [code]
    : Assign(FileVar, FileName);
    : Rewrite(FileVar);
    : { Write statements, see below }
    : Close(FileVar);
    : [/code]
    : Typed files can only support write() and BlockWrite().
    : Text files can also support writeln(), which includes a line ending.
    : Untyped files only support BlockWrite().
    : For examples see the help files, under: Assign(), Rewrite(), BlockWrite(), Write(), Close(), "file", and "text".
    :
    : Reading is very similar, but with 2 differences. The Rewrite() statement becomes a Reset() statement, and all Write()s must be Read()s.
    : Here are a few examples:
    : [code]
    : var
    : s: string;
    : i: integer;
    : f: text;
    : begin
    : s := 'Hello world';
    : i := 10;
    : Assign(f, 'File1.txt');
    : Rewrite(f);
    : writeln(f, s);
    : writeln(f, i);
    : Close(f);
    : end.
    : [/code]
    : [code]
    : var
    : i: integer;
    : f: file of integer; { typed file }
    : begin
    : Assign(f, 'File2.txt');
    : Rewrite(f);
    : for i := 0 to 99 do
    : write(f, i);
    : Close(f);
    : end.
    : [/code]
    : [code]
    : var
    : s: string;
    : i: integer;
    : f: file; { untyped file }
    : begin
    : s := 'Hello world';
    : i := 10;
    : Assign(f, 'File3.txt');
    : Rewrite(f, 1); { byte record length }
    : BlockWrite(f, i, SizeOf(i));
    : BlockWrite(f, s, SizeOf(s));
    : Close(f);
    : end.
    : [/code]
    :
    :

    Ok, so thats writing. How about reading? Writing is down pat, but I have no clue how to read it and apply to variables. Example, if file was this:
    [code]
    darknessx.txt:
    darknessx {var User}
    nintendo {var Pass}
    54 {var Str}{Strength}
    67 {var Pwr} {Power}
    53 {var Spd} {Speed}
    57 {var Chr} {Charisma}
    42 {var cHP} {Current HP}
    13 {var cMP} {Current MP}
    32 {var mHP} {Maximum HP}
    15 {var mMP} {Maximum MP}
    [/code]
    then how would i read that and apply each line to a specific variable? (The comments show which variable they should be)Of course, those aren't all the variables to be read- there is some odd 20-25 variables to be read (example, backpack items, quest items, etc etc).
    Thanks for the info on writing, though, because it is very useful. I can now actually write the info to a file :)
    just a guess, but does it use EOL?
    EDIT:
    Also, one quick question, how would I call an external procedure in file procedure.pas? It's in the same folder as the program.


  • : [b][red]This message was edited by DarknessX at 2006-10-2 14:5:30[/red][/b][hr]
    : [b][red]This message was edited by DarknessX at 2006-10-2 13:7:15[/red][/b][hr]
    : : There are several options: text-file, typed file, and untyped file. The basic code layout for writing is this, no matter which file type:
    : : [code]
    : : Assign(FileVar, FileName);
    : : Rewrite(FileVar);
    : : { Write statements, see below }
    : : Close(FileVar);
    : : [/code]
    : : Typed files can only support write() and BlockWrite().
    : : Text files can also support writeln(), which includes a line ending.
    : : Untyped files only support BlockWrite().
    : : For examples see the help files, under: Assign(), Rewrite(), BlockWrite(), Write(), Close(), "file", and "text".
    : :
    : : Reading is very similar, but with 2 differences. The Rewrite() statement becomes a Reset() statement, and all Write()s must be Read()s.
    : : Here are a few examples:
    : : [code]
    : : var
    : : s: string;
    : : i: integer;
    : : f: text;
    : : begin
    : : s := 'Hello world';
    : : i := 10;
    : : Assign(f, 'File1.txt');
    : : Rewrite(f);
    : : writeln(f, s);
    : : writeln(f, i);
    : : Close(f);
    : : end.
    : : [/code]
    : : [code]
    : : var
    : : i: integer;
    : : f: file of integer; { typed file }
    : : begin
    : : Assign(f, 'File2.txt');
    : : Rewrite(f);
    : : for i := 0 to 99 do
    : : write(f, i);
    : : Close(f);
    : : end.
    : : [/code]
    : : [code]
    : : var
    : : s: string;
    : : i: integer;
    : : f: file; { untyped file }
    : : begin
    : : s := 'Hello world';
    : : i := 10;
    : : Assign(f, 'File3.txt');
    : : Rewrite(f, 1); { byte record length }
    : : BlockWrite(f, i, SizeOf(i));
    : : BlockWrite(f, s, SizeOf(s));
    : : Close(f);
    : : end.
    : : [/code]
    : :
    : :
    :
    : Ok, so thats writing. How about reading? Writing is down pat, but I have no clue how to read it and apply to variables. Example, if file was this:
    : [code]
    : darknessx.txt:
    : darknessx {var User}
    : nintendo {var Pass}
    : 54 {var Str}{Strength}
    : 67 {var Pwr} {Power}
    : 53 {var Spd} {Speed}
    : 57 {var Chr} {Charisma}
    : 42 {var cHP} {Current HP}
    : 13 {var cMP} {Current MP}
    : 32 {var mHP} {Maximum HP}
    : 15 {var mMP} {Maximum MP}
    : [/code]
    : then how would i read that and apply each line to a specific variable? (The comments show which variable they should be)Of course, those aren't all the variables to be read- there is some odd 20-25 variables to be read (example, backpack items, quest items, etc etc).
    : Thanks for the info on writing, though, because it is very useful. I can now actually write the info to a file :)
    : just a guess, but does it use EOL?
    : EDIT:
    : Also, one quick question, how would I call an external procedure in file procedure.pas? It's in the same folder as the program.
    :
    :
    :
    As I have said in my previous reply: [b]": Reading is very similar, but with 2 differences. The Rewrite() statement becomes a Reset() statement, and all Write()s must be Read()s."[/b]
    Thus:
    [code]
    : : var
    : : s: string;
    : : i: integer;
    : : f: text;
    : : begin
    : : s := 'Hello world';
    : : i := 10;
    : : Assign(f, 'File1.txt');
    : : Reset(f);
    : : Readln(f, s);
    : : Readln(f, i);
    : : Close(f);
    : : end.
    [/code]
    To use another unit place it's name in the uses list:
    [code]
    program Example;

    uses
    Procedures, Crt, Dos;

    begin
    ClrScr; { declared in Crt }
    ...
    end.
    [/code]
  • : : [b][red]This message was edited by DarknessX at 2006-10-2 14:5:30[/red][/b][hr]
    : : [b][red]This message was edited by DarknessX at 2006-10-2 13:7:15[/red][/b][hr]
    : : : There are several options: text-file, typed file, and untyped file. The basic code layout for writing is this, no matter which file type:
    : : : [code]
    : : : Assign(FileVar, FileName);
    : : : Rewrite(FileVar);
    : : : { Write statements, see below }
    : : : Close(FileVar);
    : : : [/code]
    : : : Typed files can only support write() and BlockWrite().
    : : : Text files can also support writeln(), which includes a line ending.
    : : : Untyped files only support BlockWrite().
    : : : For examples see the help files, under: Assign(), Rewrite(), BlockWrite(), Write(), Close(), "file", and "text".
    : : :
    : : : Reading is very similar, but with 2 differences. The Rewrite() statement becomes a Reset() statement, and all Write()s must be Read()s.
    : : : Here are a few examples:
    : : : [code]
    : : : var
    : : : s: string;
    : : : i: integer;
    : : : f: text;
    : : : begin
    : : : s := 'Hello world';
    : : : i := 10;
    : : : Assign(f, 'File1.txt');
    : : : Rewrite(f);
    : : : writeln(f, s);
    : : : writeln(f, i);
    : : : Close(f);
    : : : end.
    : : : [/code]
    : : : [code]
    : : : var
    : : : i: integer;
    : : : f: file of integer; { typed file }
    : : : begin
    : : : Assign(f, 'File2.txt');
    : : : Rewrite(f);
    : : : for i := 0 to 99 do
    : : : write(f, i);
    : : : Close(f);
    : : : end.
    : : : [/code]
    : : : [code]
    : : : var
    : : : s: string;
    : : : i: integer;
    : : : f: file; { untyped file }
    : : : begin
    : : : s := 'Hello world';
    : : : i := 10;
    : : : Assign(f, 'File3.txt');
    : : : Rewrite(f, 1); { byte record length }
    : : : BlockWrite(f, i, SizeOf(i));
    : : : BlockWrite(f, s, SizeOf(s));
    : : : Close(f);
    : : : end.
    : : : [/code]
    : : :
    : : :
    : :
    : : Ok, so thats writing. How about reading? Writing is down pat, but I have no clue how to read it and apply to variables. Example, if file was this:
    : : [code]
    : : darknessx.txt:
    : : darknessx {var User}
    : : nintendo {var Pass}
    : : 54 {var Str}{Strength}
    : : 67 {var Pwr} {Power}
    : : 53 {var Spd} {Speed}
    : : 57 {var Chr} {Charisma}
    : : 42 {var cHP} {Current HP}
    : : 13 {var cMP} {Current MP}
    : : 32 {var mHP} {Maximum HP}
    : : 15 {var mMP} {Maximum MP}
    : : [/code]
    : : then how would i read that and apply each line to a specific variable? (The comments show which variable they should be)Of course, those aren't all the variables to be read- there is some odd 20-25 variables to be read (example, backpack items, quest items, etc etc).
    : : Thanks for the info on writing, though, because it is very useful. I can now actually write the info to a file :)
    : : just a guess, but does it use EOL?
    : : EDIT:
    : : Also, one quick question, how would I call an external procedure in file procedure.pas? It's in the same folder as the program.
    : :
    : :
    : :
    : As I have said in my previous reply: [b]": Reading is very similar, but with 2 differences. The Rewrite() statement becomes a Reset() statement, and all Write()s must be Read()s."[/b]
    : Thus:
    : [code]
    : : : var
    : : : s: string;
    : : : i: integer;
    : : : f: text;
    : : : begin
    : : : s := 'Hello world';
    : : : i := 10;
    : : : Assign(f, 'File1.txt');
    : : : Reset(f);
    : : : Readln(f, s);
    : : : Readln(f, i);
    : : : Close(f);
    : : : end.
    : [/code]
    : To use another unit place it's name in the uses list:
    : [code]
    : program Example;
    :
    : uses
    : Procedures, Crt, Dos;
    :
    : begin
    : ClrScr; { declared in Crt }
    : ...
    : end.
    : [/code]
    :
    Ok. I was just confused as I didn't know how the variable is read. You don't happen to know how to make an external procedure, though, do you? I just can't get it to work...
  • : : : [b][red]This message was edited by DarknessX at 2006-10-2 14:5:30[/red][/b][hr]
    : : : [b][red]This message was edited by DarknessX at 2006-10-2 13:7:15[/red][/b][hr]
    : : : : There are several options: text-file, typed file, and untyped file. The basic code layout for writing is this, no matter which file type:
    : : : : [code]
    : : : : Assign(FileVar, FileName);
    : : : : Rewrite(FileVar);
    : : : : { Write statements, see below }
    : : : : Close(FileVar);
    : : : : [/code]
    : : : : Typed files can only support write() and BlockWrite().
    : : : : Text files can also support writeln(), which includes a line ending.
    : : : : Untyped files only support BlockWrite().
    : : : : For examples see the help files, under: Assign(), Rewrite(), BlockWrite(), Write(), Close(), "file", and "text".
    : : : :
    : : : : Reading is very similar, but with 2 differences. The Rewrite() statement becomes a Reset() statement, and all Write()s must be Read()s.
    : : : : Here are a few examples:
    : : : : [code]
    : : : : var
    : : : : s: string;
    : : : : i: integer;
    : : : : f: text;
    : : : : begin
    : : : : s := 'Hello world';
    : : : : i := 10;
    : : : : Assign(f, 'File1.txt');
    : : : : Rewrite(f);
    : : : : writeln(f, s);
    : : : : writeln(f, i);
    : : : : Close(f);
    : : : : end.
    : : : : [/code]
    : : : : [code]
    : : : : var
    : : : : i: integer;
    : : : : f: file of integer; { typed file }
    : : : : begin
    : : : : Assign(f, 'File2.txt');
    : : : : Rewrite(f);
    : : : : for i := 0 to 99 do
    : : : : write(f, i);
    : : : : Close(f);
    : : : : end.
    : : : : [/code]
    : : : : [code]
    : : : : var
    : : : : s: string;
    : : : : i: integer;
    : : : : f: file; { untyped file }
    : : : : begin
    : : : : s := 'Hello world';
    : : : : i := 10;
    : : : : Assign(f, 'File3.txt');
    : : : : Rewrite(f, 1); { byte record length }
    : : : : BlockWrite(f, i, SizeOf(i));
    : : : : BlockWrite(f, s, SizeOf(s));
    : : : : Close(f);
    : : : : end.
    : : : : [/code]
    : : : :
    : : : :
    : : :
    : : : Ok, so thats writing. How about reading? Writing is down pat, but I have no clue how to read it and apply to variables. Example, if file was this:
    : : : [code]
    : : : darknessx.txt:
    : : : darknessx {var User}
    : : : nintendo {var Pass}
    : : : 54 {var Str}{Strength}
    : : : 67 {var Pwr} {Power}
    : : : 53 {var Spd} {Speed}
    : : : 57 {var Chr} {Charisma}
    : : : 42 {var cHP} {Current HP}
    : : : 13 {var cMP} {Current MP}
    : : : 32 {var mHP} {Maximum HP}
    : : : 15 {var mMP} {Maximum MP}
    : : : [/code]
    : : : then how would i read that and apply each line to a specific variable? (The comments show which variable they should be)Of course, those aren't all the variables to be read- there is some odd 20-25 variables to be read (example, backpack items, quest items, etc etc).
    : : : Thanks for the info on writing, though, because it is very useful. I can now actually write the info to a file :)
    : : : just a guess, but does it use EOL?
    : : : EDIT:
    : : : Also, one quick question, how would I call an external procedure in file procedure.pas? It's in the same folder as the program.
    : : :
    : : :
    : : :
    : : As I have said in my previous reply: [b]": Reading is very similar, but with 2 differences. The Rewrite() statement becomes a Reset() statement, and all Write()s must be Read()s."[/b]
    : : Thus:
    : : [code]
    : : : : var
    : : : : s: string;
    : : : : i: integer;
    : : : : f: text;
    : : : : begin
    : : : : s := 'Hello world';
    : : : : i := 10;
    : : : : Assign(f, 'File1.txt');
    : : : : Reset(f);
    : : : : Readln(f, s);
    : : : : Readln(f, i);
    : : : : Close(f);
    : : : : end.
    : : [/code]
    : : To use another unit place it's name in the uses list:
    : : [code]
    : : program Example;
    : :
    : : uses
    : : Procedures, Crt, Dos;
    : :
    : : begin
    : : ClrScr; { declared in Crt }
    : : ...
    : : end.
    : : [/code]
    : :
    : Ok. I was just confused as I didn't know how the variable is read. You don't happen to know how to make an external procedure, though, do you? I just can't get it to work...
    :
    [code]
    unit HelloWorld;

    interface

    procedure DoHelloWorld;

    implementation

    procedure DoHelloWorld;
    begin
    writeln('Hello world');
    end;

    end.
    [/code]

    [code]
    program HelloUniverse;

    uses
    HelloWord;

    begin
    DoHelloWorld;
    end.
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories