TEST.MOD 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. MODULE Test;
  2. FROM ModBase3 IMPORT UpdateDBFile,WriteDBRec,DeleteRecord,ReadDBRec,
  3. AppendBlank;
  4. FROM Scrn2DBF IMPORT FrameToDBF, DBFToFrame;
  5. FROM PosUtils IMPORT Equal;
  6. FROM StrEdit IMPORT CrunchBlanks,DeleteRightJustified,CAPstr;
  7. FROM M2Strings IMPORT Length;
  8. FROM LowLevel IMPORT Fill;
  9. FROM StringIO IMPORT PrintMessage;
  10. FROM Drectory IMPORT SetDefaultDrive,ChDir,GetCurrentDir;
  11. FROM EnvironUtils IMPORT ReadEnvironment;
  12. FROM SmartScreen IMPORT ClearScreen;
  13. FROM VWindows IMPORT ClearPart, CurrentWindow, SetCursorHeight;
  14. FROM ScrnTypes IMPORT DisplayFrame,InitDisplayFrame,AFrameName;
  15. FROM FramePainter IMPORT ShowDisplayFrame;
  16. FROM InputManager IMPORT ControlFrame;
  17. FROM FrameManager IMPORT EraseFrame;
  18. FROM Prompts IMPORT Prompt,PromptStr;
  19. FROM SYSTEM IMPORT ADR,SIZE;
  20. FROM ControlUtils IMPORT ControlSeparately, LoadFrameList,Control;
  21. FROM DspFiles IMPORT OpenDisplayFile,ReadDisplayFrame;
  22. FROM HandleIO IMPORT FileExists;
  23. FROM Prompts IMPORT Prompt;
  24. FROM LowLevel IMPORT Fill;
  25. FROM GenLists IMPORT GenList, NewList,ListLength,GetElmt;
  26. FROM ScrnTypes IMPORT AFrameName, InitDisplayFrame,DisplayFile;
  27. FROM DBFTest IMPORT TestDBF, OpenTestDBF,
  28. CloseTestDBF,
  29. FindTestByTest,
  30. NextTest,PrevTest,FirstTest,LastTest;
  31. IMPORT InitCompilerMods;
  32. VAR
  33. Status : INTEGER;
  34. Environ : ARRAY [0..60] OF CHAR;
  35. J : CARDINAL;
  36. TopMenu : GenList;
  37. FirstTime: BOOLEAN;
  38. NextFrame,EndingFrame : AFrameName;
  39. SelChar : CHAR;
  40. NoData : BOOLEAN; (* true when no data is on the screen *)
  41. TestDF : DisplayFrame;
  42. DSPFile : DisplayFile;
  43. PullDnMenu : GenList;
  44. PROCEDURE FileMenu(SelChar: CHAR);
  45. VAR
  46. B : BOOLEAN;
  47. Str : ARRAY [0..80] OF CHAR;
  48. BEGIN
  49. CASE SelChar OF
  50. 'A' : ReadDisplayFrame(DSPFile,TestDF,'Test'); (*Clear out any of the fields *)
  51. ShowDisplayFrame(TestDF,0,0,0,0);
  52. Control(TestDF); (* alow user input *)
  53. AppendBlank(TestDBF);
  54. B := FrameToDBF(TestDBF,TestDF); (* do something if couldn't add*)
  55. WriteDBRec(TestDBF);
  56. |'F' : FirstTest();
  57. DBFToFrame(TestDBF,TestDF);
  58. ShowDisplayFrame(TestDF,0,0,0,0);
  59. |'L' : LastTest();
  60. DBFToFrame(TestDBF,TestDF);
  61. ShowDisplayFrame(TestDF,0,0,0,0);
  62. |'N' : IF NextTest()
  63. THEN
  64. DBFToFrame(TestDBF,TestDF);
  65. ShowDisplayFrame(TestDF,0,0,0,0);
  66. END;
  67. |'P' : IF PrevTest()
  68. THEN
  69. DBFToFrame(TestDBF,TestDF);
  70. ShowDisplayFrame(TestDF,0,0,0,0);
  71. END;
  72. |'T' : (* The first unused letter in the index name or 'Q' *)
  73. Fill(ADR(Str),SIZE(Str),0);
  74. PromptStr('Enter Test Test ',Str);
  75. CrunchBlanks(Str);
  76. IF NOT FindTestByTest(Str)
  77. THEN
  78. Prompt('Test Not Found');
  79. ELSE
  80. DBFToFrame(TestDBF,TestDF);
  81. ShowDisplayFrame(TestDF,0,0,0,0);
  82. END;
  83. END; (* end of case *)
  84. END FileMenu;
  85. PROCEDURE EditMenu(SelChar : CHAR);
  86. VAR
  87. B:BOOLEAN;
  88. BEGIN
  89. CASE SelChar OF
  90. 'U' : Control(TestDF);
  91. B:=FrameToDBF(TestDBF,TestDF);
  92. WriteDBRec(TestDBF);
  93. |'D' : DeleteRecord(TestDBF);
  94. NoData := TRUE;
  95. END;
  96. END EditMenu;
  97. BEGIN
  98. (* if there is an environment variable set to m2test=path *)
  99. (* the program will set the default drive and path *)
  100. (* this is needed because running under the debuggers the *)
  101. (* debugger will start the program with the default drive *)
  102. (* and path = c:\ - aint nothing gona work if looking for *)
  103. (* files there *)
  104. ReadEnvironment('M2TEST', Environ);
  105. CrunchBlanks(Environ);
  106. IF Length(Environ) > 0
  107. THEN
  108. CAPstr(Environ);
  109. IF Environ[1] = ':'
  110. THEN SetDefaultDrive(Environ[0]);
  111. DeleteRightJustified(Environ,0,2);
  112. END;
  113. IF 0#ChDir(Environ)
  114. THEN (* this is bullet proof code here *)
  115. END;
  116. END;
  117. PrintMessage(GetCurrentDir('z',Environ)); (* check *)
  118. IF NOT OpenDisplayFile(DSPFile,'Test.DSP')
  119. THEN
  120. Prompt('Could not open Test.dsp file');
  121. HALT;
  122. END;
  123. ClearScreen();
  124. InitDisplayFrame(TestDF,CurrentWindow);
  125. NewList(PullDnMenu);
  126. LoadFrameList(DSPFile,'TopMenu',PullDnMenu);
  127. NoData := TRUE;
  128. OpenTestDBF(TRUE);
  129. ReadDisplayFrame(DSPFile,TestDF,'Test');
  130. REPEAT
  131. NextFrame := 'TopMenu';
  132. ControlSeparately(PullDnMenu,NextFrame,SelChar,EndingFrame);
  133. IF Equal(EndingFrame,'FileMenu')
  134. THEN FileMenu(SelChar);
  135. ELSIF Equal(EndingFrame,'EditMenu')
  136. THEN EditMenu(SelChar);
  137. END;
  138. UNTIL SelChar='X'; (* Assumes 'X' is only used to exit *)
  139. CloseTestDBF();
  140. ClearScreen();
  141. END Test.