home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / BASIC / MKFORM / MAKEFORM.DEM < prev    next >
Text File  |  1994-04-06  |  4KB  |  106 lines

  1. DEFINT A-Z
  2. 'This is your MAIN module
  3.  
  4. '$INCLUDE: 'MFM_COMM.BI'          'common stuff
  5. '$INCLUDE: 'MERLIN.DCL'           'Merlin assembler library subset
  6. '$INCLUDE: 'MAKEFORM.BI'          'your own form fields and constants
  7.  
  8. 'Check the files that are loaded:
  9. 'If you use no scroll bars, load NO_SCRLB.BAS instead of SCROLLB.BAS
  10. 'If you use no list boxes, load NO_LISTB.BAS instead of LISTBOX.BAS
  11.  
  12. DECLARE SUB Cleanup ()
  13. DECLARE SUB EditForm (Fld() AS ANY, Form$(), Frm AS ANY)
  14. DECLARE SUB GetEvent ()
  15. DECLARE SUB Startup (FormName$, FontName$, MouseChar%, Frm AS ANY, Fld() AS
  16. ANY, Form$())
  17. DECLARE SUB ShowForm (Fld() AS ANY, Frm AS ANY, SetPal)
  18.  
  19. '*********************************'
  20. 'Block 1: Housekeeping
  21.  
  22. 'All program variables and constants go here:
  23. 'COMMON SHARED ....
  24. '(RE)DIM SHARED ....
  25. 'Some COMMON variables are in MFM_COMM.BI - be sure to check that file!
  26.  
  27. 'Initialise your MAIN LOCAL and COMMON variables here:
  28.  
  29.  
  30. '*********************************'
  31. 'Block 2: Current program
  32.  
  33. 'Variables to work with a FORM
  34. DIM SHARED Frm AS FormType
  35. REDIM SHARED Fld(0) AS FieldType
  36. REDIM SHARED Form$(0, 0)
  37.  
  38. FormName$ = "MAKEFORM"
  39. FontName$ = "HELV8X12.MFN"
  40. MouseChar = 8
  41. 'The file Helv8x12.MFN and the file Mouse.MFN are
  42. 'supposed to be in this subdir too!
  43.  
  44. Startup FormName$, FontName$, MouseChar, Frm, Fld(), Form$()
  45.  
  46. '*********************************'
  47. 'Main loop:
  48. ShowForm Fld(), Frm, FadeSpeed    'Show PCX file and load field defs
  49.          'FadeSpeed contains palette fade out speed in high byte, 
  50.          'fade in speed in low byte. Set in MF_COMM.BI.
  51.  
  52. MouseOn  
  53. Frm.Flags = Frm.Flags OR 4        'initialise form
  54. Frm.NextFld = 1                   'begin at first field
  55. ProgStage = pRunning              'program is running
  56.  
  57. DO: 'Get Click, MouseX, MouseY, KeyVal, KeyFlags, ClickMem, KeyMem
  58.     GetEvent
  59.  
  60.     EditForm Fld(), Form$(), Frm
  61.     'Return EventNotUsed and Fld.HotK upon release of object.
  62.     'EventNotUsed = -1: haven't used it at all
  63.     'EventNotUsed = -2: want to use event again - GetEvent skips itself.
  64.  
  65.     'Completed press on item with key or mouse
  66.     IF KeyVal = Fld(Frm.CurrFld).HotK THEN
  67.         'Normally Fld.HotK is always set (to 255 if not defined)
  68.         SELECT CASE Frm.CurrFld
  69.             'Enter CASE statements for all
  70.             'buttons, list boxes and mouse fields.
  71.             'Use the list of CONST from your own .BI file
  72.             'Scroll bars return their hotkey too upon changing the slide
  73.         CASE ELSE: END SELECT
  74.     END IF
  75.  
  76.     'Going to a new field
  77.     IF Frm.NextFld <> Frm.CurrFld THEN
  78.         SELECT CASE Frm.CurrFld
  79.             'You may need to check something. Validation of
  80.             'numeric input and dates is done by EditForm.
  81.             'Field entries may also lead to updating other fields,
  82.             'which is done by calling PrintArray.
  83.             'CASE ...
  84.         CASE ELSE: END SELECT
  85.     END IF
  86.  
  87.     'Same field running checks
  88.     IF Frm.NextFld = Frm.CurrFld THEN
  89.         SELECT CASE Frm.CurrFld
  90.           'You may want to update other fields when
  91.           'a scroll bar pointer is moved for example
  92.           'or update row/column status bar on screen, etc.
  93.           'Listbox scrollbars do everything themselves!
  94.           'CASE ...
  95.         CASE ELSE: END SELECT
  96.     END IF
  97.  
  98. LOOP UNTIL QuitProgram OR KeyVal = kbCtrlC OR KeyVal = kbEscape
  99. 'The KeyVal exits here are just for safety. Set QuitProgram = true
  100. 'when your Exit button is used and remove the rest later.
  101.  
  102. Cleanup
  103.  
  104. 'That's all folks! Have fun!
  105.  
  106.