PROMPTS.MOD 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. IMPLEMENTATION MODULE Prompts;
  2. (*
  3. * ModBase
  4. * Release 3.0
  5. * (c) Copyright 1986 - 1991 PMI
  6. * P.O. Box 8402
  7. * Green Bay Wi 53308
  8. * All Rights Reserved
  9. * by Ed Ross
  10. *)
  11. FROM BigSets IMPORT AppendSet, InitSet;
  12. FROM KbdInput IMPORT AnyKeyNum, KeyHit, KeyNumSet, YorN;
  13. FROM M2Strings IMPORT Length;
  14. FROM MsgBox2 IMPORT MsgOkay, StrMsgBox;
  15. FROM ScrnTypes IMPORT DisplayFrame, InitDisplayFrame;
  16. FROM ScrnUtl2 IMPORT CloseDisplayFrame;
  17. FROM SmartScreen IMPORT ClearPart, SetCursorHeight, WriteAt;
  18. FROM StrConv IMPORT StrToCardinal,ReturnedCard,CardinalToStr;
  19. FROM StrEdit IMPORT AssignStr,CrunchBlanks;
  20. FROM StrInput IMPORT ReadWithEdits;
  21. FROM VWindows IMPORT Compass, CurrentWindow;
  22. FROM WindowPrims IMPORT DrawBox, GetCursorCoords, PopColors,
  23. PopCursorCoords, PopCursorHeight, PushColors, PushCursorCoords,
  24. PushCursorHeight, ScreenRestore, ScreenSave;
  25. IMPORT SYSTEM;
  26. VAR
  27. CH : CHAR;
  28. B : BOOLEAN;
  29. x2 : CARDINAL;
  30. PROCEDURE SetUp;
  31. BEGIN
  32. PushCursorHeight;
  33. PushCursorCoords;
  34. PushColors;
  35. ScreenSave(StatusScr,5,10,x2,15);
  36. ClearPart(5,10,x2,15);
  37. DrawBox(5,10,x2,15);
  38. END SetUp;
  39. PROCEDURE TakeDown;
  40. BEGIN
  41. PopCursorHeight;
  42. PopColors;
  43. ScreenRestore(StatusScr,5,10);
  44. PopCursorCoords;
  45. END TakeDown;
  46. PROCEDURE Prompt(S1: ARRAY OF CHAR);
  47. VAR Key : CARDINAL;
  48. DF : DisplayFrame;
  49. BEGIN
  50. InitDisplayFrame(DF,CurrentWindow);
  51. DF^.ClearAfter := TRUE;
  52. StrMsgBox(DF,NE,S1);
  53. CloseDisplayFrame(DF);
  54. END Prompt;
  55. PROCEDURE PromptStr(S1 : ARRAY OF CHAR; VAR S2 : ARRAY OF CHAR);
  56. VAR
  57. Insert : BOOLEAN;
  58. CurPos : CARDINAL;
  59. LastKey : CARDINAL;
  60. LegalKeys,
  61. ExitKeys : KeyNumSet;
  62. BEGIN
  63. x2 := HIGH(S1) + HIGH(S2)+12;
  64. SetUp;
  65. WriteAt(12,12,S1);
  66. CurPos := 0;
  67. Insert := TRUE;
  68. LegalKeys := AnyKeyNum;
  69. InitSet(LegalKeys);
  70. InitSet(ExitKeys);
  71. AppendSet(ExitKeys,"{8,9,271,13,27,328,336,329,337}");
  72. (* Means BackSpace, TAB, BackTab, CR, ESC, and the arrow
  73. keys let you out of a field. *)
  74. ReadWithEdits(CurrentWindow,S2,13+Length(S1),12,HIGH(S2),CurPos,
  75. Insert,FALSE,LastKey,
  76. AnyKeyNum,ExitKeys);
  77. TakeDown;
  78. END PromptStr;
  79. PROCEDURE PromptNum(S1 : ARRAY OF CHAR;DefaultNbr : CARDINAL): CARDINAL;
  80. VAR
  81. ExitKeys, NumKeys : KeyNumSet;
  82. TmpStr : ARRAY[1..5] OF CHAR;
  83. R,C : CARDINAL;
  84. Len : CARDINAL;
  85. Num : CARDINAL;
  86. Pos : CARDINAL;
  87. InsertMode : BOOLEAN;
  88. LastKey : CARDINAL;
  89. BEGIN
  90. x2 := HIGH(S1) + 5 + 12; (* 5 is for the digits *)
  91. SetUp;
  92. GetCursorCoords(C,R);
  93. InitSet(ExitKeys);
  94. AppendSet(ExitKeys,"{8,9,271,13,27,328,336,329,337}");
  95. (* Means BackSpace, TAB, BackTab, CR, ESC, and the arrow
  96. keys let you out of a field. *)
  97. WriteAt(12,12,S1);
  98. InitSet(NumKeys);
  99. AppendSet(NumKeys,'{"0".."9",8,9,271,13,27,328,336,329,337,331,333,339}');
  100. Len := 5;
  101. Pos := 0;
  102. CardinalToStr(DefaultNbr,5,TmpStr);
  103. CrunchBlanks(TmpStr);
  104. ReadWithEdits( CurrentWindow,TmpStr,13+Length(S1),12,Len,Pos,InsertMode,FALSE,
  105. LastKey, NumKeys, ExitKeys );
  106. TakeDown;
  107. RETURN ReturnedCard(TmpStr)
  108. END PromptNum;
  109. PROCEDURE PromptYN(S1 : ARRAY OF CHAR; DFrame : DisplayFrame) : BOOLEAN;
  110. (* Return true for yes ; false for no *)
  111. VAR
  112. DF : DisplayFrame;
  113. Key : CARDINAL;
  114. B : BOOLEAN;
  115. BEGIN
  116. InitDisplayFrame(DF,CurrentWindow);
  117. B := MsgOkay(DF,NW,S1);
  118. CloseDisplayFrame(DF);
  119. RETURN B;
  120. END PromptYN;
  121. PROCEDURE DisplayStatus(S1 : ARRAY OF CHAR);
  122. BEGIN
  123. END DisplayStatus;
  124. PROCEDURE RemoveDisplay();
  125. BEGIN
  126. END RemoveDisplay;
  127. BEGIN
  128. END Prompts.