Major Gremlin in program!!! HElP!!!
I cannot ask a specific question on this program because I don't really
know what's wrong with the program.
Okay here's the program.
Program Voca63Beta; { Voca version 6.3 Beta }
uses Crt, Dos;
Const
Compiler = 'Turbo Pascal 7.0';
Author = 'Cheng, Yu Kwan';
Version = 'Version 6.3 Beta';
Title = 'Voca Tester';
Company = 'U Co.';
type
{------------Cur Load----------------}
rCurload = record
Filename : string[8];
NumofRec : integer;
Datasize : longint;
end;
pCurload = ^rCurload;
{------------Voca Records------------}
VocaSelector = ( InfoRec, DataRec );
VocaRec = record
case vs : vocaselector of
InfoRec : ( NumOfRec : Integer;
FileId : string[8] );
DataRec : ( Japword, Engword : string[40] );
end;
Vocarray = array[0..0] of VocaRec;
pVocarray = ^Vocarray;
var
Mselect : char;
Mloop : boolean;
OldExitProc : Pointer;
Curload : pCurload;
VocaList : pVocarray;
mfilename : string[8];
{***************************************************************************}
{ /-----------------------------------------------------------------\
| Initialization Section & DeInitialize |
\-----------------------------------------------------------------/
Procedure PreInit;
begin
new(Curload);
end;
Procedure DeInit; Far;
begin
release(Curload);
clrscr;
writeln('Hasta La Vista Babe!');
delay(2500);
ExitProc := OldExitProc;
end;
{***************************************************************************}
{ /-----------------------------------------------------------------\
| LoadFile |
\-----------------------------------------------------------------/
Procedure LoadFile;
type
FileArray = array[1..1] of string[8];
pFileArray = ^FileArray;
var
DirList : pFileArray;
DirInfo : searchrec;
FileCount, Counter : integer;
CurX, CurY : integer;
Procedure SortBB(var Farray : pFileArray);
var
level1, level2 : integer;
tstring : string[8];
begin
for level1 := 1 to filecount + 1 do
for level2 := 1 to filecount - 1 do
begin
if Farray^[level2] > Farray^[level2 + 1] then
begin
Tstring := farray^[level2];
Farray^[level2] := farray^[level2 + 1];
farray^[level2 + 1] := tstring;
end;
end;
end;
begin
clrscr;
CurX := 1; CurY := 3;
writeln('Current available files');
writeln('-----------------------');
Filecount := 0;
FindFirst('*.*', anyfile, DirInfo);
while doserror = 0 do
begin
inc(filecount);
findnext(DirInfo);
end;
GetMem(DirList, 9 * filecount);
filecount := 0;
FindFirst('*.*', anyfile, DirInfo);
while doserror = 0 do
with DirInfo do
begin
inc(filecount);
DirList^[Filecount] := name;
FindNext(DirInfo);
end;
SortBB(dirlist);
for Counter := 1 to filecount do
begin
gotoxy(curx, cury); write(counter,'. ',dirlist^[counter]);
inc(cury);
if wherey >= 24 then
begin
curx := curx + 13;
cury := 3;
end;
end;
freemem(dirlist, 9 * filecount);
{!!!!!!!!!!!!!!!!!!!!!!!!----------HERE'S THE PROBLEM I
THINK-------!!!!!!!!!!!!!!!!!!!}
gotoxy(1,24);
delline;
write('Enter Filename - ');
readln(mfilename);
{The problem is with this read statement. when the program runs it skips
the read statement instead of stopping
and reading the actaul line. I can't debug this because when I trace the
program is does not work either. So I hope
some guru can help me. compile the program and try it out for you self}
end;
{***************************************************************************}
{ /-----------------------------------------------------------------\
| Main |
\-----------------------------------------------------------------/
Begin
new(curload);
Mloop := false;
repeat
clrscr;
writeln('Main Menu');
writeln('---------');
writeln('(L)oad File');
writeln('(Q)uit');
writeln;
write('Enter Selection - '); read(Mselect);
Mselect := upcase(Mselect);
case Mselect of
'L' : Loadfile;
'Q' : Mloop := true;
end;
until Mloop;
release(curload);
end.
--
Yu Kwan Cheng
( Hopefully I'll have my page soon )