Board index » delphi » Major Gremlin in program!!! HElP!!!

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                           |
     \-----------------------------------------------------------------/  

Quote
}

  Procedure PreInit;
  begin
    new(Curload);
  end;

  Procedure DeInit; Far;
  begin
    release(Curload);
    clrscr;
    writeln('Hasta La Vista Babe!');
    delay(2500);
    ExitProc := OldExitProc;
  end;

{***************************************************************************}
{    /-----------------------------------------------------------------\
     | LoadFile                                                        |
     \-----------------------------------------------------------------/  

Quote
}

  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                                                            |
     \-----------------------------------------------------------------/  

Quote
}

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 )

 

Re:Major Gremlin in program!!! HElP!!!


In article <4e3gsa$...@pipe6.nyc.pipeline.com>,
   con...@nyc.pipeline.com (Yu Kwan Cheng) wrote:

Quote
>{!!!!!!!!!!!!!!!!!!!!!!!!----------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}

It's been a long time since I worked in DOS Text mode but I seem to remember
having this problem at one time. I seem to remember that the problem was that
the string had a value. You could try setting the string length to zero before
doing the ReadLn.

-----------------------------------------------
Mike Chapin
Powder River
mcha...@vcn.com
http://www.vcn.com/server/netizens/mchapin/first.html
Gillette, WY

Not the end of the earth but you can see it from
there.
-----------------------------------------------

Re:Major Gremlin in program!!! HElP!!!


In article <4ed79e$...@news.tcd.net>, mcha...@vcn.com says...

Quote

>In article <4e3gsa$...@pipe6.nyc.pipeline.com>,
>   con...@nyc.pipeline.com (Yu Kwan Cheng) wrote:
>>{!!!!!!!!!!!!!!!!!!!!!!!!----------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}

DOS will sometimes hold things in the keypress buffer that you aren't
expecting. look earlier in your program at other places where key presses are
being taken and make sure you grab all of them. (may an IF KEYPRESSED THEN c =
readkey before the readln?) I had this problem in QuickBasic a long while back.
That delline; function might be shoving something in the buffer.

--
The Crow - thec...@iconn.net
"It can't rain all the time"
-Kryptology

Re:Major Gremlin in program!!! HElP!!!


In article <4e3gsa$...@pipe6.nyc.pipeline.com>,
   con...@nyc.pipeline.com (Yu Kwan Cheng) wrote:

Quote
>>{!!!!!!!!!!!!!!!!!!!!!!!!----------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}
>It's been a long time since I worked in DOS Text mode but I seem to remember
>having this problem at one time. I seem to remember that the problem was that
>the string had a value. You could try setting the string length to zero before

 >doing the ReadLn.

Or try using read(mfilename)  Instead of readln(myfilename);

Eddy

Other Threads