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} 'sizeof', {$ENDIF} '*', iLongInt); // 89
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

View File

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

View File

@ -1218,9 +1218,12 @@ Begin
CheckArray(Param[Count].vID, ArrayData, RecInfo);
Param[Count].vData := GetDataPtr(Param[Count].vID, ArrayData, RecInfo);
Param[Count].vSize := VarData[Param[Count].vID]^.VarSize;
If VarData[Param[Count].vID]^.vType = iString Then
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
// this should getmem dataptr and store it there instead
// will save some memory but make calling functions below a bit more
@ -1241,6 +1244,13 @@ Begin
'l' : Param[Count].L := Trunc(EvaluateNumber);
'r' : Param[Count].R := EvaluateNumber;
'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;
@ -1681,10 +1691,19 @@ Begin
TempStr := strStripPipe(Param[1].S);
Store (TempStr, 256);
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;
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
TempStr := Session.io.GetInput(Param[1].B, Param[2].B, Param[3].B, Param[4].S);
Store (TempStr, 256);

View File

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