In the code below the two lines marked with ????????????????? do not work
properly.
The line:
inCF.BaseStream.Seek(0, SeekOrigin.Begin); // rewind inCF to
beginning of the file ??????????????????????
does not change the character position inCF.charPos, and the line:
st = inCF.ReadLine(); // read in next line ?????????????????????????
after reading the last line of the text file, will read the first line of
the file again and never returns a null string.
What am I doing wrong?
Other code in the file:
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
StreamReader inCF = new StreamReader(fName);
public static bool GoToLabel(ref string prSt, ref string st, ref
StreamReader inCF) // do a GoTo statement
{
bool upTo;
string label1;
bool findLabel;
bool byFile = (inCF != null);
string st7 = GetField(ref st);
if ((st7 != "GOTO") && (st7 != "GOUPTO")) return false;
upTo = (st7 != "GOTO");
if (upTo)
{
DelNPBls(ref st, 6);
}
else
{
DelNPBls(ref st, 4);
}
label1 = GetField(ref st);
if (upTo) st = prSt;
LookLabel(ref st, label1, out findLabel);
if (findLabel) return true;
if (!byFile) return true;
if (upTo)
{
inCF.BaseStream.Seek(0, SeekOrigin.Begin); // rewind inCF to
beginning of the file ??????????????????????
}
do
{
st = inCF.ReadLine(); // read in next line ?????????????????????????
if (st == null) break;
DelTabs(ref st);
LookLabel(ref st, label1, out findLabel);
if (findLabel) return true;
MultiID.MuInterrupt();
}
while (!MultiID.muAbort);
return true;
}
-Harry