MODULE Test; FROM ModBase3 IMPORT UpdateDBFile,WriteDBRec,DeleteRecord,ReadDBRec, AppendBlank; FROM Scrn2DBF IMPORT FrameToDBF, DBFToFrame; FROM PosUtils IMPORT Equal; FROM StrEdit IMPORT CrunchBlanks,DeleteRightJustified,CAPstr; FROM M2Strings IMPORT Length; FROM LowLevel IMPORT Fill; FROM StringIO IMPORT PrintMessage; FROM Drectory IMPORT SetDefaultDrive,ChDir,GetCurrentDir; FROM EnvironUtils IMPORT ReadEnvironment; FROM SmartScreen IMPORT ClearScreen; FROM VWindows IMPORT ClearPart, CurrentWindow, SetCursorHeight; FROM ScrnTypes IMPORT DisplayFrame,InitDisplayFrame,AFrameName; FROM FramePainter IMPORT ShowDisplayFrame; FROM InputManager IMPORT ControlFrame; FROM FrameManager IMPORT EraseFrame; FROM Prompts IMPORT Prompt,PromptStr; FROM SYSTEM IMPORT ADR,SIZE; FROM ControlUtils IMPORT ControlSeparately, LoadFrameList,Control; FROM DspFiles IMPORT OpenDisplayFile,ReadDisplayFrame; FROM HandleIO IMPORT FileExists; FROM Prompts IMPORT Prompt; FROM LowLevel IMPORT Fill; FROM GenLists IMPORT GenList, NewList,ListLength,GetElmt; FROM ScrnTypes IMPORT AFrameName, InitDisplayFrame,DisplayFile; FROM DBFTest IMPORT TestDBF, OpenTestDBF, CloseTestDBF, FindTestByTest, NextTest,PrevTest,FirstTest,LastTest; IMPORT InitCompilerMods; VAR Status : INTEGER; Environ : ARRAY [0..60] OF CHAR; J : CARDINAL; TopMenu : GenList; FirstTime: BOOLEAN; NextFrame,EndingFrame : AFrameName; SelChar : CHAR; NoData : BOOLEAN; (* true when no data is on the screen *) TestDF : DisplayFrame; DSPFile : DisplayFile; PullDnMenu : GenList; PROCEDURE FileMenu(SelChar: CHAR); VAR B : BOOLEAN; Str : ARRAY [0..80] OF CHAR; BEGIN CASE SelChar OF 'A' : ReadDisplayFrame(DSPFile,TestDF,'Test'); (*Clear out any of the fields *) ShowDisplayFrame(TestDF,0,0,0,0); Control(TestDF); (* alow user input *) AppendBlank(TestDBF); B := FrameToDBF(TestDBF,TestDF); (* do something if couldn't add*) WriteDBRec(TestDBF); |'F' : FirstTest(); DBFToFrame(TestDBF,TestDF); ShowDisplayFrame(TestDF,0,0,0,0); |'L' : LastTest(); DBFToFrame(TestDBF,TestDF); ShowDisplayFrame(TestDF,0,0,0,0); |'N' : IF NextTest() THEN DBFToFrame(TestDBF,TestDF); ShowDisplayFrame(TestDF,0,0,0,0); END; |'P' : IF PrevTest() THEN DBFToFrame(TestDBF,TestDF); ShowDisplayFrame(TestDF,0,0,0,0); END; |'T' : (* The first unused letter in the index name or 'Q' *) Fill(ADR(Str),SIZE(Str),0); PromptStr('Enter Test Test ',Str); CrunchBlanks(Str); IF NOT FindTestByTest(Str) THEN Prompt('Test Not Found'); ELSE DBFToFrame(TestDBF,TestDF); ShowDisplayFrame(TestDF,0,0,0,0); END; END; (* end of case *) END FileMenu; PROCEDURE EditMenu(SelChar : CHAR); VAR B:BOOLEAN; BEGIN CASE SelChar OF 'U' : Control(TestDF); B:=FrameToDBF(TestDBF,TestDF); WriteDBRec(TestDBF); |'D' : DeleteRecord(TestDBF); NoData := TRUE; END; END EditMenu; BEGIN (* if there is an environment variable set to m2test=path *) (* the program will set the default drive and path *) (* this is needed because running under the debuggers the *) (* debugger will start the program with the default drive *) (* and path = c:\ - aint nothing gona work if looking for *) (* files there *) ReadEnvironment('M2TEST', Environ); CrunchBlanks(Environ); IF Length(Environ) > 0 THEN CAPstr(Environ); IF Environ[1] = ':' THEN SetDefaultDrive(Environ[0]); DeleteRightJustified(Environ,0,2); END; IF 0#ChDir(Environ) THEN (* this is bullet proof code here *) END; END; PrintMessage(GetCurrentDir('z',Environ)); (* check *) IF NOT OpenDisplayFile(DSPFile,'Test.DSP') THEN Prompt('Could not open Test.dsp file'); HALT; END; ClearScreen(); InitDisplayFrame(TestDF,CurrentWindow); NewList(PullDnMenu); LoadFrameList(DSPFile,'TopMenu',PullDnMenu); NoData := TRUE; OpenTestDBF(TRUE); ReadDisplayFrame(DSPFile,TestDF,'Test'); REPEAT NextFrame := 'TopMenu'; ControlSeparately(PullDnMenu,NextFrame,SelChar,EndingFrame); IF Equal(EndingFrame,'FileMenu') THEN FileMenu(SelChar); ELSIF Equal(EndingFrame,'EditMenu') THEN EditMenu(SelChar); END; UNTIL SelChar='X'; (* Assumes 'X' is only used to exit *) CloseTestDBF(); ClearScreen(); END Test.