| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- 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.
|