SizeOf, fWriteRec, fReadRec, support for writing records and array of records to datafiles

This commit is contained in:
mysticbbs 2012-04-20 20:44:06 -04:00
parent 5cee7974a7
commit 9cfef82e91
4 changed files with 40 additions and 20 deletions

View File

@ -243,6 +243,8 @@ Begin
AddProc ({$IFDEF MPLPARSER} 'strippipe', {$ENDIF} 's', iString); // 88 AddProc ({$IFDEF MPLPARSER} 'strippipe', {$ENDIF} 's', iString); // 88
AddProc ({$IFDEF MPLPARSER} 'sizeof', {$ENDIF} '*', iLongInt); // 89 AddProc ({$IFDEF MPLPARSER} 'sizeof', {$ENDIF} '*', iLongInt); // 89
AddProc ({$IFDEF MPLPARSER} 'fillchar', {$ENDIF} '*lc', iNone); // 90 AddProc ({$IFDEF MPLPARSER} 'fillchar', {$ENDIF} '*lc', iNone); // 90
AddProc ({$IFDEF MPLPARSER} 'fwriterec', {$ENDIF} 'fx', iNone); // 91
AddProc ({$IFDEF MPLPARSER} 'freadrec', {$ENDIF} 'fx', iNone); // 92
IW := 500; // BEGIN BBS-SPECIFIC STUFF IW := 500; // BEGIN BBS-SPECIFIC STUFF

View File

@ -136,7 +136,7 @@ Type
Procedure ParseVarChar; Procedure ParseVarChar;
Procedure ParseVarRecord; Procedure ParseVarRecord;
Procedure ParseVariable (VT: TIdentTypes); Procedure ParseVariable (VT: TIdentTypes);
Procedure ParseArray (VN: Word); Procedure ParseArray (VN: Word; Forced: Boolean);
Function ParseElement (VN: Word; TypeCheck: Boolean; VT: TIdentTypes) : TIdentTypes; Function ParseElement (VN: Word; TypeCheck: Boolean; VT: TIdentTypes) : TIdentTypes;
Function ParseElementType (VN: Word; SkipIdent: Boolean) : TIdentTypes; Function ParseElementType (VN: Word; SkipIdent: Boolean) : TIdentTypes;
@ -708,7 +708,7 @@ Begin
Seek (OutFile, SavedPos + mplVerLength); Seek (OutFile, SavedPos + mplVerLength);
End; End;
Procedure TParserEngine.ParseArray (VN: Word); Procedure TParserEngine.ParseArray (VN: Word; Forced: Boolean);
Var Var
X : Word; X : Word;
Begin Begin
@ -978,7 +978,7 @@ begin
Else Begin Else Begin
OutString (Char(opVariable)); OutString (Char(opVariable));
OutWord (VarData[VarNum]^.VarID); OutWord (VarData[VarNum]^.VarID);
ParseArray (VarNum); ParseArray (VarNum, True);
ParseElement (VarNum, False, iLongInt); ParseElement (VarNum, False, iLongInt);
End; End;
End; End;
@ -1093,7 +1093,7 @@ Begin
Else Begin Else Begin
OutString (Char(opVariable)); OutString (Char(opVariable));
OutWord (VarData[VarNum]^.VarID); OutWord (VarData[VarNum]^.VarID);
ParseArray (VarNum); ParseArray (VarNum, True);
ParseElement (VarNum, True, iChar); ParseElement (VarNum, True, iChar);
End; End;
End; End;
@ -1224,7 +1224,7 @@ Begin
Else Begin Else Begin
OutString (Char(opVariable)); OutString (Char(opVariable));
OutWord (VarData[VarNum]^.VarID); OutWord (VarData[VarNum]^.VarID);
ParseArray (VarNum); ParseArray (VarNum, True);
ParseElement (VarNum, True, iString); ParseElement (VarNum, True, iString);
End; End;
End; End;
@ -1342,7 +1342,7 @@ Begin
Else Begin Else Begin
OutString (Char(opVariable)); OutString (Char(opVariable));
OutWord (VarData[VarNum]^.VarID); OutWord (VarData[VarNum]^.VarID);
ParseArray (VarNum); ParseArray (VarNum, True);
ParseElement (VarNum, True, iBool); ParseElement (VarNum, True, iBool);
End; End;
End; End;
@ -2140,18 +2140,17 @@ Begin
Error (mpsTypeMismatch, ''); Error (mpsTypeMismatch, '');
OutWord (VarData[RV]^.VarID); OutWord (VarData[RV]^.VarID);
ParseArray (RV); ParseArray (RV, False);
ParseElement (RV, VarData[VN]^.Params[Count] <> '*', VarData[RV]^.vType); ParseElement (RV, VarData[VN]^.Params[Count] <> '*', VarData[RV]^.vType);
// if = '*' and type iString then...do the string index // if = '*' and type iString then...do the string index
End Else Begin End Else Begin
// use setvariable here?? cant cuz ifile isnt processed in setvariable...
// need irecord?
If Char2VarType(VarData[VN]^.Params[Count]) in vNums Then ParseVarNumber(True) Else If Char2VarType(VarData[VN]^.Params[Count]) in vNums Then ParseVarNumber(True) Else
If Char2VarType(VarData[VN]^.Params[Count]) = iString Then ParseVarString Else If Char2VarType(VarData[VN]^.Params[Count]) = iString Then ParseVarString Else
If Char2VarType(VarData[VN]^.Params[Count]) = iChar Then ParseVarChar Else If Char2VarType(VarData[VN]^.Params[Count]) = iChar Then ParseVarChar Else
If Char2VarType(VarData[VN]^.Params[Count]) = iBool Then ParseVarBoolean Else If Char2VarType(VarData[VN]^.Params[Count]) = iBool Then ParseVarBoolean Else
If Char2VarType(VarData[VN]^.Params[Count]) = iFile Then ParseVarFile; If Char2VarType(VarData[VN]^.Params[Count]) = iFile Then ParseVarFile Else
If Char2VarType(VarData[VN]^.Params[Count]) = iRecord Then ParseVarRecord;
End; End;
OutString(Char(opParamSep)); OutString(Char(opParamSep));
@ -2183,7 +2182,7 @@ Begin
If UpdateInfo.ErrorType <> 0 Then Exit; If UpdateInfo.ErrorType <> 0 Then Exit;
OutWord (VarData[VC]^.VarID); OutWord (VarData[VC]^.VarID);
ParseArray (VC); ParseArray (VC, True);
ParseElement (VC, True, iLongInt); ParseElement (VC, True, iLongInt);
GetStr (tkw[wSetVar], True, False); GetStr (tkw[wSetVar], True, False);
@ -2576,7 +2575,7 @@ Begin
End Else Begin End Else Begin
OutString (Char(opSetVar)); OutString (Char(opSetVar));
OutWord (VarData[VarNum]^.VarID); OutWord (VarData[VarNum]^.VarID);
ParseArray (VarNum); ParseArray (VarNum, True);
VT := ParseElement (VarNum, False, iNone); VT := ParseElement (VarNum, False, iNone);

View File

@ -1218,9 +1218,12 @@ Begin
CheckArray(Param[Count].vID, ArrayData, RecInfo); CheckArray(Param[Count].vID, ArrayData, RecInfo);
Param[Count].vData := GetDataPtr(Param[Count].vID, ArrayData, RecInfo); Param[Count].vData := GetDataPtr(Param[Count].vID, ArrayData, RecInfo);
If VarData[Param[Count].vID]^.vType = iString Then
Param[Count].vSize := VarData[Param[Count].vID]^.VarSize; Param[Count].vSize := VarData[Param[Count].vID]^.VarSize;
// Case VarData[Param[Count].vID]^
// If VarData[Param[Count].vID]^.vType = iString Then
// Param[Count].vSize := VarData[Param[Count].vID]^.VarSize;
End Else Begin End Else Begin
// this should getmem dataptr and store it there instead // this should getmem dataptr and store it there instead
// will save some memory but make calling functions below a bit more // will save some memory but make calling functions below a bit more
@ -1241,6 +1244,13 @@ Begin
'l' : Param[Count].L := Trunc(EvaluateNumber); 'l' : Param[Count].L := Trunc(EvaluateNumber);
'r' : Param[Count].R := EvaluateNumber; 'r' : Param[Count].R := EvaluateNumber;
'o' : Param[Count].O := EvaluateBoolean; 'o' : Param[Count].O := EvaluateBoolean;
'x' : Begin
NextWord; // Var ID;
Param[Count].vID := FindVariable(W);
Param[Count].vSize := VarData[Param[Count].vID]^.DataSize;
Param[Count].vData := VarData[Param[Count].vID]^.Data;
End;
End; End;
End; End;
@ -1681,10 +1691,19 @@ Begin
TempStr := strStripPipe(Param[1].S); TempStr := strStripPipe(Param[1].S);
Store (TempStr, 256); Store (TempStr, 256);
End; End;
89 : Begin // neeed to figure out SIZEOF.. time to redo this PARAM garbage finally 89 : Begin
TempLong := Param[1].vSize;
Store (TempLong, 4);
End; End;
90 : FillChar (Param[1].vData^, Param[2].L, Param[3].C); 90 : FillChar (Param[1].vData^, Param[2].L, Param[3].C);
// should check vDataSize once we get that figured out 91 : Begin
BlockWrite (File(Pointer(Param[1].vData)^), Param[2].vData^, Param[2].vSize);
IoError := IoResult;
End;
92 : Begin
BlockRead (File(Pointer(Param[1].vData)^), VarData[Param[2].vID]^.Data^, VarData[Param[2].vID]^.DataSize);
IoError := IoResult;
End;
500 : Begin 500 : Begin
TempStr := Session.io.GetInput(Param[1].B, Param[2].B, Param[3].B, Param[4].S); TempStr := Session.io.GetInput(Param[1].B, Param[2].B, Param[3].B, Param[4].S);
Store (TempStr, 256); Store (TempStr, 256);

View File

@ -77,7 +77,7 @@ Type
); );
Const Const
mplVer = '11*'; mplVer = '11@';
mplVersion = '[MPX ' + mplVer +']' + #26; mplVersion = '[MPX ' + mplVer +']' + #26;
mplVerLength = 10; mplVerLength = 10;
mplExtSource = '.mps'; mplExtSource = '.mps';