home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d969 / ace.lha / ACE / ACEupd240194.lha / AIDE / AIDE.b < prev    next >
Text File  |  1994-01-24  |  34KB  |  1,375 lines

  1. {*
  2. ** ACE Integrated Development Environment: AIDE.
  3. **
  4. ** Author: David J Benn
  5. **   Date: 23rd,24th,28th-31st December 1993,
  6. **       1st-3rd,5th,6th,8th,10th-12th,
  7. **       14th,15th,17th,19th,23rd,24th January 1994
  8. *}
  9.  
  10. version$ = "$VER: AIDE 1.01 (24.01.94)"
  11.  
  12. DEFLNG a-z
  13.  
  14. {*
  15. ** Menu Constants (prefixes: c=command, m=menu, i=menu item)
  16. *}
  17.  
  18. '..basic values
  19. CONST TRUE     =-1&
  20. CONST FALSE     =0&
  21. CONST NULL     =0&
  22.  
  23. '..Object file types
  24. CONST ASM     =1
  25. CONST EXE     =2
  26.  
  27. '..Modes
  28. CONST cDisable     =0
  29. CONST cEnable      =1
  30. CONST cCheck     =2
  31.  
  32. '..Project Menu
  33. CONST mProject     =1
  34. CONST iNew     =1
  35. CONST iOpen     =2
  36. CONST iView     =3
  37. CONST iSep1.1     =4
  38. CONST iDelete     =5
  39. CONST iPrint     =6
  40. CONST iExecute     =7
  41. CONST iShell     =8
  42. CONST iSep1.2     =9
  43. CONST iAbout     =10
  44. CONST iQuit     =11
  45.  
  46. '..Program Menu
  47. CONST mProgram     =2
  48. CONST iSetSource =1
  49. CONST iEdit     =2
  50. CONST iSep2.1     =3
  51. CONST iRun     =4
  52. CONST iRunInShell=5
  53. CONST iSep2.2     =6
  54. CONST iCompile     =7
  55. CONST iMake     =8
  56. CONST iBuild     =9
  57. CONST iSep2.3     =10
  58. CONST iViewAsm     =11
  59. CONST iViewPrep     =12
  60. CONST iShowErrs     =13
  61.  
  62. '..Compiler Menu
  63. CONST mCompiler     =3
  64. CONST iBreak     =1
  65. CONST iComments  =2
  66. CONST iIcon     =3
  67. CONST iListLines =4
  68. CONST iOptimise  =5
  69. CONST iWindow     =6
  70.  
  71. '..Linker
  72. CONST mLinker     =4
  73. CONST iAddModule =1
  74. CONST iRemModule =2
  75. CONST iRemAllMod =3
  76. CONST iSep4.1     =4
  77.  
  78. '..Help
  79. CONST mHelp     =5
  80. CONST iACEDoc     =1
  81. CONST iA68KDoc     =2
  82. CONST iBlinkDoc     =3
  83. CONST iSep5.1     =4
  84. CONST iACERef     =5
  85.  
  86. '..Other stuff
  87. CONST strSize    =80
  88. CONST maxModules=10
  89.  
  90.  
  91. {*
  92. ** Structure Definitions
  93. *}
  94.  
  95. STRUCT program_info
  96.   STRING   source_file SIZE strSize
  97.   STRING   source_dir  SIZE strSize
  98.   LONGINT  made
  99.   SHORTINT module_count
  100.   STRING   default_args
  101. END STRUCT
  102.  
  103. STRUCT config_info
  104.   STRING editor SIZE strSize
  105.   STRING viewer SIZE strSize
  106.   STRING tmpdir SIZE strSize
  107.   STRING docdir SIZE strSize
  108.   STRING bltdir SIZE strSize
  109.   STRING agddir SIZE strSize
  110. END STRUCT 
  111.  
  112. STRUCT options_info
  113.   LONGINT user_break
  114.   LONGINT asm_comments
  115.   LONGINT error_log
  116.   LONGINT create_icon
  117.   LONGINT list_lines
  118.   LONGINT optimise
  119.   LONGINT window_close
  120. END STRUCT
  121.  
  122. STRUCT DateStamp
  123.   LONGINT days
  124.   LONGINT mins
  125.   LONGINT ticks
  126. END STRUCT
  127.  
  128. STRUCT FileInfoBlock
  129.   longint fib_DiskKey
  130.   longint fib_DirEntryType
  131.   string  fib_FileName size 108
  132.   longint fib_Protection
  133.   longint fib_EntryType
  134.   longint fib_Size
  135.   longint fib_NumBlocks
  136.   string  fib_Date size 12
  137.   string  fib_Comment size 80
  138.   string  fib_Reserved size 36
  139. END STRUCT
  140.  
  141.  
  142. {*
  143. ** Global Variables
  144. *}
  145.  
  146. DECLARE STRUCT program_info prog
  147. DECLARE STRUCT config_info config
  148. DECLARE STRUCT options_info options
  149.  
  150. DIM module$(maxModules)
  151.  
  152. STRING default_command
  153.  
  154.  
  155. {*
  156. ** Subprogram declarations
  157. *}
  158.  
  159. SUB fexists(STRING fname)
  160.   OPEN "I",#255,fname
  161.   if HANDLE(255) then
  162.     fexists=TRUE
  163.   else
  164.     fexists=FALSE
  165.   end if
  166.   CLOSE #255
  167. END SUB
  168.  
  169. SUB get_file_datestamp(STRING fname,ADDRESS ds_addr)
  170. CONST   ACCESS_READ = -2&
  171. LONGINT mylock
  172. DECLARE STRUCT FileInfoBlock file_info
  173. DECLARE STRUCT DateStamp ds,Date
  174. DECLARE FUNCTION Lock&(filename$,accessmode&) LIBRARY
  175. DECLARE FUNCTION UnLock(filelock&) LIBRARY
  176. DECLARE FUNCTION Examine(filelock&,fib_ptr&) LIBRARY
  177.  
  178.   '..Return the datestamp of the file.
  179.   '..No checking beyond a test for NULL lock.
  180.  
  181.   ds = ds_addr
  182.   mylock = Lock(fname,ACCESS_READ) 
  183.  
  184.   if mylock <> NULL then
  185.     Examine(mylock,file_info)
  186.     Date = @file_info->fib_Date
  187.     ds->days  = Date->days
  188.     ds->mins  = Date->mins
  189.     ds->ticks = Date->ticks
  190.     UnLock(mylock)
  191.   end if
  192. END SUB
  193.  
  194. SUB SHORTINT datestamps_different(ADDRESS ds1_addr,ADDRESS ds2_addr)
  195. DECLARE STRUCT DateStamp ds1,ds2
  196.  
  197.   '..Return TRUE if the datestamps of 2 files 
  198.   '..are different.
  199.  
  200.   ds1 = ds1_addr
  201.   ds2 = ds2_addr
  202.  
  203.   '..If one file doesn't exist but the
  204.   '..other does, then the datestamps
  205.   '..are different.
  206.   IF (ds1 = NULL and ds2 <> NULL) or (ds1 <> NULL and ds2 = NULL) THEN 
  207.      datestamps_different = TRUE
  208.      EXIT SUB
  209.   END IF
  210.  
  211.   '..If neither file exists, then the
  212.   '..datestamps aren't different.
  213.   IF ds1 = NULL and ds2 = NULL THEN
  214.      datestamps_different = FALSE
  215.      EXIT SUB
  216.   END IF
  217.  
  218.   d1=ds1->days
  219.   d2=ds2->days    
  220.   m1=ds1->mins
  221.   m2=ds2->mins    
  222.   t1=ds1->ticks
  223.   t2=ds2->ticks    
  224.  
  225.   if (d1<>d2) or (m1<>m2) or (t1<>t2) then
  226.      datestamps_different=TRUE
  227.   else
  228.      datestamps_different=FALSE
  229.   end if
  230. END SUB
  231.  
  232. SUB SHORTINT older(ADDRESS ds1_addr,ADDRESS ds2_addr)
  233. DECLARE STRUCT DateStamp ds1,ds2
  234.  
  235.   '..Return TRUE if first datestamp is older than second.
  236.   ds1 = ds1_addr
  237.   ds2 = ds2_addr
  238.  
  239.   '..If first file doesn't exist it can't
  240.   '..be older than second.
  241.   IF ds1 = NULL THEN
  242.      older = FALSE
  243.      EXIT SUB
  244.   END IF
  245.  
  246.   '..If second file doesn't exist
  247.   '..but the the first file does, 
  248.   '..the first file must be older
  249.   '..than the second.
  250.   IF ds2 = NULL THEN 
  251.      older = TRUE
  252.      EXIT SUB
  253.   END IF
  254.   
  255.   d1=ds1->days
  256.   d2=ds2->days    
  257.   m1=ds1->mins
  258.   m2=ds2->mins    
  259.   t1=ds1->ticks
  260.   t2=ds2->ticks    
  261.  
  262.   IF (d1<d2) or (d1=d2 and m1<m2) or (d1=d2 and m1=m2 and t1<t2) THEN
  263.      older = TRUE
  264.   ELSE
  265.      older = FALSE
  266.   END IF  
  267. END SUB
  268.  
  269. SUB STRING quote(STRING x)
  270. '..enclose x in quotes
  271.   quote = CHR$(34)+x+CHR$(34)
  272. END SUB
  273.  
  274. {------------------------------------------------------}
  275.  
  276. SUB abort_prog(STRING fname)
  277. SINGLE  time0
  278.   BEEP
  279.   PRINT fname;" error!"
  280.   PRINT
  281.   PRINT "press 'q' key to quit."
  282.   WHILE UCASE$(INKEY$)<>"Q":WEND
  283.   WINDOW CLOSE 1
  284.   STOP
  285. END SUB
  286.  
  287. SUB STRING strip_whitespace(STRING X)
  288. SHORTINT i,j,length
  289. STRING   ch SIZE 2
  290.   '..remove leading whitespace from X.
  291.   length = LEN(X)
  292.  
  293.   i=1
  294.   repeat
  295.     ch = MID$(X,i,1)
  296.     if ch <= " " then ++i
  297.   until ch > " " or i > length
  298.  
  299.   '..return the stripped string.
  300.   strip_whitespace = MID$(X,i)
  301. END SUB
  302.  
  303. SUB append_slash(ADDRESS X_addr)
  304. STRING X ADDRESS X_addr
  305. STRING delimiter SIZE 2
  306.     delimiter = RIGHT$(X,1)
  307.     if delimiter <> "/" and delimiter <> ":" then 
  308.       X = X+"/" 
  309.     end if
  310. END SUB
  311.  
  312. SUB get_config
  313. SHARED   config
  314. CONST    words=6
  315. DIM      keyword$(words) SIZE 7
  316. SHORTINT i,posn
  317. LONGINT  abort
  318. STRING   config_file SIZE 12
  319. STRING   ln SIZE 81
  320. STRING   value SIZE strSize
  321.  
  322.   config_file = "AIDE.config"
  323.  
  324.   abort=FALSE
  325.  
  326.   '..read the config file keywords
  327.   for i=1 to words
  328.     read keyword$(i)
  329.   next
  330.   DATA EDITOR,VIEWER,TMPDIR,DOCDIR,BLTDIR,AGDDIR
  331.  
  332.   '..open the configuration file
  333.   OPEN "I",#1,config_file
  334.  
  335.   '..abort program if we can't open this!
  336.   if HANDLE(1)=NULL then CALL abort_prog(config_file)
  337.  
  338.   '..search for config keywords and set 
  339.   '..values in config structure (expects: <configvar>=<value>).
  340.   while not eof(1)
  341.     LINE INPUT #1,ln
  342.     ln = UCASE$(ln)
  343.     if LEFT$(ln,1) <> "#" then
  344.       i=1 : posn=0
  345.       while i<=words and posn=0
  346.         posn=INSTR(ln,keyword$(i))
  347.         if posn=0 then ++i
  348.       wend
  349.       if posn > 0 then     
  350.      value = strip_whitespace(MID$(ln,INSTR(ln,"=")+1))
  351.     case
  352.       i=1 : config->editor = value
  353.           i=2 : config->viewer = value
  354.           i=3 : config->tmpdir = value
  355.       i=4 : config->docdir = value
  356.       i=5 : config->bltdir = value
  357.       i=6 : config->agddir = value
  358.         end case
  359.       end if
  360.     end if
  361.   wend
  362.   CLOSE #1
  363.  
  364.   '..Check we've got all the non-optional values and 
  365.   '..make changes where necessary.
  366.  
  367.   if config->editor="" then abort=TRUE
  368.  
  369.   if config->viewer="" then abort=TRUE  
  370.  
  371.   if config->tmpdir="" then 
  372.     abort=TRUE
  373.   else
  374.     append_slash(@config->tmpdir)
  375.     '.."Ram Disk:" will cause Blink to choke
  376.     '..since it can't handle quoted args, and the 2.04
  377.     '..ASL file requester yields this name for "RAM:"
  378.     if LEFT$(config->tmpdir,9) = "RAM DISK:" then
  379.        config->tmpdir = "RAM:"+MID$(config->tmpdir,10)
  380.     end if    
  381.   end if
  382.  
  383.   if config->docdir="" then
  384.     abort=TRUE
  385.   else
  386.     append_slash(@config->docdir)  
  387.   end if
  388.  
  389.   if config->bltdir<>"" then 
  390.     append_slash(@config->bltdir)  
  391.   end if
  392.  
  393.   '..AmigaGuide is optional since no files are yet supplied for this.
  394.   if config->agddir<>"" then
  395.     append_slash(@config->agddir)  
  396.   end if
  397.  
  398.   if abort then CALL abort_prog(config_file)    
  399. END SUB
  400.  
  401. SUB initialise_config
  402. SHARED config
  403.   config->editor=""
  404.   config->viewer=""
  405.   config->tmpdir=""
  406.   config->docdir=""
  407.   config->bltdir=""
  408.   config->agddir=""
  409. END SUB
  410.  
  411. SUB initialise_program_info
  412. SHARED prog
  413.   prog->source_file=""
  414.   prog->source_dir=""
  415.   prog->made=FALSE
  416.   prog->module_count=0
  417.   prog->default_args=""
  418. END SUB
  419.  
  420. SUB initialise_options
  421. SHARED options
  422.   options->user_break=FALSE
  423.   options->asm_comments=FALSE
  424.   options->error_log=FALSE
  425.   options->create_icon=FALSE
  426.   options->list_lines=FALSE
  427.   options->optimise=TRUE
  428.   options->window_close=FALSE
  429. END SUB
  430.  
  431. SUB initialise_environment
  432. SHARED module$
  433.   PRINT "Initialising..."
  434.   initialise_config
  435.   get_config
  436.   initialise_options
  437.   initialise_program_info
  438.   '..clear link modules array
  439.   for i=1 to maxModules:module$(i)="":next
  440. END SUB
  441.  
  442. {------------------------------------------------------}
  443.  
  444. SUB setup_menus
  445.   '..Project Menu
  446.   MENU mProject,0,cEnable,           "Project"
  447.  
  448.   MENU mProject,iNew,cEnable,           "New","N"
  449.   MENU mProject,iOpen,cEnable,           "Open...","O"
  450.   MENU mProject,iView,cEnable,        "View...","V"
  451.   MENU mProject,iSep1.1,cDisable,      "-----------------"
  452.   MENU mProject,iDelete,cEnable,       "Delete...","D"
  453.   MENU mProject,iPrint,cEnable,           "Print...","P"
  454.   MENU mProject,iExecute,cEnable,      "Execute...","X"
  455.   MENU mProject,iShell,cEnable,        "Spawn Shell"
  456.   MENU mProject,iSep1.2,cDisable,      "-----------------"
  457.   MENU mProject,iAbout,cEnable,           "About..."
  458.   MENU mProject,iQuit,cEnable,           "Quit AIDE","Q"
  459.   
  460.   '..Program Menu
  461.   MENU mProgram,0,cEnable,           "Program"
  462.  
  463.   MENU mProgram,iSetSource,cEnable,      "Set Source...","S"
  464.   MENU mProgram,iEdit,cDisable,        "Edit Source","E"
  465.   MENU mProgram,iSep2.1,cDisable,       "------------------------"
  466.   MENU mProgram,iRun,cDisable,            "Run","R"
  467.   MENU mProgram,iRunInShell,cDisable,      "Run in Shell..."
  468.   MENU mProgram,iSep2.2,cDisable,      "------------------------"
  469.   MENU mProgram,iCompile,cDisable,      "Compile","C"
  470.   MENU mProgram,iMake,cDisable,      "Make Executable","M"
  471.   MENU mProgram,iBuild,cDisable,       "Build Application","B"
  472.   MENU mProgram,iSep2.3,cDisable,      "------------------------"
  473.   MENU mProgram,iViewAsm,cDisable,    "View Assembly Source"
  474.   MENU mProgram,iViewPrep,cDisable,    "View Preprocessed Source"
  475.   MENU mProgram,iShowErrs,cDisable,      "Show Compiler Errors"
  476.  
  477.   '..Compiler Menu
  478.   MENU mCompiler,0,cEnable,        "Compiler"
  479.   MENU mCompiler,iBreak,cEnable,    "    Break Trapping"
  480.   MENU mCompiler,iComments,cEnable,    "    Assembly Comments"
  481.   MENU mCompiler,iIcon,cEnable,        "    Create Icon"
  482.   MENU mCompiler,iListLines,cEnable,    "    List Source Lines"
  483.   MENU mCompiler,iOptimise,cCheck,    "    Optimise Assembly"
  484.   MENU mCompiler,iWindow,cEnable,    "    Window Trapping"
  485.  
  486.   '..Linker Menu
  487.   MENU mLinker,0,cEnable,        "Linker"
  488.   MENU mLinker,iAddModule,cEnable,    "Add Module..."
  489.   MENU mLinker,iRemModule,cDisable,    "Remove Module..."
  490.   MENU mLinker,iRemAllMod,cDisable,     "Remove All Modules"
  491.   MENU mLinker,iSep4.1,cDisable,    STRING$(18,"-")
  492.  
  493.   '..Help Menu
  494.   MENU mHelp,0,cEnable,            "Help"
  495.   MENU mHelp,iACEDoc,cEnable,        "Compiler"
  496.   MENU mHelp,iA68KDoc,cEnable,        "Assembler"
  497.   MENU mHelp,iBlinkDoc,cEnable,        "Linker"
  498.   MENU mHelp,iSep5.1,cDisable,        "------------"
  499.   MENU mHelp,iACERef,cEnable,        "ACE Language"
  500. END SUB
  501.  
  502. {------------------------------------------------------}
  503.  
  504. SUB new_file
  505. SHARED config
  506.   SYSTEM config->editor
  507. END SUB
  508.  
  509. SUB open_file
  510. SHARED config
  511. STRING file_name SIZE strSize
  512.   file_name = FileBox$("Open")  
  513.   SYSTEM config->editor+" "+quote(file_name)
  514. END SUB
  515.  
  516. SUB view_file
  517. SHARED config
  518. STRING file_name SIZE strSize
  519.   file_name = FileBox$("View") 
  520.   SYSTEM config->viewer+" "+quote(file_name)
  521. END SUB
  522.  
  523. SUB execute_command
  524. SHARED   default_command
  525. SHARED   config
  526. STRING   command, script_call
  527. STRING   title SIZE strSize
  528. STRING   prompt SIZE strSize
  529. STRING   script_name SIZE strSize
  530. SHORTINT script_count
  531.  
  532.   prompt = "Enter Command and Arguments:"
  533.   title  = "Execute Command"
  534.  
  535.   command = InputBox$(prompt,title,default_command,170,50)
  536.  
  537.   if command <> "" then 
  538.     '..construct a shell script: must have a unique name
  539.     '..since multiple shell scripts may be in use.
  540.     script_count=0
  541.     repeat
  542.       script_name=config->tmpdir+"command-script-"+MID$(STR$(script_count),2)
  543.       ++script_count
  544.     until NOT fexists(script_name)
  545.  
  546.     OPEN "O",254,script_name
  547.     PRINT #254,"failat 11"
  548.     PRINT #254,"echo "+CHR$(34)+"*E[0;0H*E[J"+CHR$(34) '..cls
  549.     PRINT #254,"prompt "+CHR$(34)+CHR$(34)
  550.     PRINT #254,"stack 40000"
  551.     PRINT #254,command
  552.     CLOSE #254
  553.  
  554.     '..Execute it!
  555.     script_call = "NewShell "+CHR$(34)+"CON:0/125/640/100/Command Window/CLOSE"
  556.     script_call = script_call+CHR$(34)+" FROM "
  557.     script_call = script_call+script_name
  558.     SYSTEM script_call
  559.  
  560.     '..Set new default command.
  561.     default_command = command
  562.   end if
  563. END SUB
  564.  
  565. SUB print_file
  566. STRING file_name SIZE strSize
  567. STRING text_line
  568.   file_name = FileBox$("Print")
  569.   OPEN "I",#1,file_name
  570.   if HANDLE(1) then
  571.     PRINT "Printing ";file_name;"..."
  572.     OPEN "O",#2,"PRT:"
  573.     while not eof(1)
  574.       LINE INPUT #1,text_line
  575.       PRINT #2,text_line
  576.     wend
  577.     CLOSE 1,2
  578.   else
  579.     if file_name<>"" then print "Unable to print ";file_name
  580.   end if 
  581. END SUB
  582.  
  583. SUB delete_file
  584. STRING file_name SIZE strSize
  585.   file_name = FileBox$("Delete")
  586.   if file_name<>"" then 
  587.     if NOT MsgBox("Really delete "+file_name+"?","Yes","No!") then 
  588.       PRINT file_name;" not deleted."
  589.       EXIT SUB
  590.     end if 
  591.     KILL file_name
  592.     if ERR then 
  593.       PRINT "Error while deleting!"
  594.     else
  595.       PRINT file_name;" deleted."
  596.     end if
  597.   else
  598.     PRINT "No file/directory specified."
  599.   end if
  600. END SUB
  601.  
  602. SUB spawn_shell
  603.   SYSTEM "NewShell CON:0/125/640/100/AIDEshell/CLOSE"
  604. END SUB
  605.  
  606. SUB about_box
  607.   x$="Written in ACE by David Benn "+CHR$(169)+" 1994"
  608.   dummy = MsgBox(x$,"OK")
  609. END SUB
  610.  
  611. SUB handle_project_menu(item)
  612. SHORTINT result
  613.   case 
  614.     item = iNew          : new_file
  615.     item = iOpen      : open_file
  616.     item = iView    : view_file
  617.     item = iPrint     : print_file
  618.     item = iExecute    : execute_command
  619.     item = iDelete    : delete_file
  620.     item = iShell    : spawn_shell
  621.     item = iAbout     : about_box
  622.   end case  
  623. END SUB
  624.  
  625. {------------------------------------------------------}
  626.  
  627. SUB set_source
  628. SHARED  prog
  629. STRING  file_name SIZE strSize
  630. STRING  tmp SIZE strSize
  631. STRING  delimiter SIZE 2
  632. STRING  extension SIZE 3
  633. LONGINT posn,ramdisk,dblslash,found
  634.  
  635.   '..get source file name
  636.   file_name = FileBox$("Select Source File")
  637.  
  638.   if file_name="" then 
  639.     PRINT "No source file specified."
  640.     EXIT SUB
  641.   end if
  642.  
  643.   '..extract directory path and file
  644.   posn=LEN(file_name)
  645.   found=FALSE
  646.   repeat
  647.     delimiter = MID$(file_name,posn,1)
  648.     if delimiter=":" or delimiter="/" then
  649.     found=TRUE
  650.     else
  651.          --posn
  652.     end if
  653.   until posn=0 or found
  654.  
  655.   if not found then 
  656.     prog->source_file = file_name
  657.     prog->source_dir = ""
  658.   else
  659.     '..source directory
  660.     prog->source_dir = LEFT$(file_name,posn)
  661.   
  662.     '..kludge for Wb 3.0 ASL requester when PARENT button
  663.     '..is selected. (??)
  664.     dblslash = INSTR(prog->source_dir,"//")
  665.     if dblslash then
  666.        tmp = prog->source_dir
  667.        prog->source_dir = MID$(tmp,1,dblslash) + MID$(tmp,dblslash+2)
  668.     end if   
  669.  
  670.     '..source file
  671.     prog->source_file = MID$(file_name,posn+1)
  672.   end if
  673.  
  674.   '..remove file extension
  675.   extension = RIGHT$(prog->source_file,2)
  676.   if ucase$(extension) <> ".B" then 
  677.     prog->source_file = ""
  678.   else
  679.     posn = INSTR(ucase$(prog->source_file),".B")
  680.      prog->source_file = LEFT$(prog->source_file,posn-1)
  681.   end if  
  682.  
  683.   '..enable inactive program menu items?
  684.   if prog->source_file <> "" then
  685.     prog->default_args=""
  686.     prog->made=FALSE
  687.     MENU mProgram,iEdit,cEnable
  688.     MENU mProgram,iRun,cEnable
  689.     MENU mProgram,iRunInShell,cEnable
  690.     MENU mProgram,iArguments,cEnable
  691.     MENU mProgram,iCompile,cEnable
  692.     MENU mProgram,iMake,cEnable
  693.     MENU mProgram,iBuild,cEnable
  694.     MENU mProgram,iViewAsm,cEnable
  695.     MENU mProgram,iViewPrep,cEnable
  696.     MENU mProgram,iShowErrs,cEnable
  697.     PRINT "Source file is ";prog->source_dir;prog->source_file;".b"
  698.   else
  699.     PRINT "No source file specified!"
  700.   end if
  701. END SUB
  702.  
  703. SUB edit_source
  704. SHARED config,prog
  705. STRING command
  706. STRING orig_file SIZE strSize
  707. DECLARE STRUCT DateStamp ds1,ds2
  708.  
  709.   orig_file = prog->source_dir+prog->source_file+".b"
  710.  
  711.   IF NOT fexists(orig_file) THEN
  712.      PRINT "Unable to edit ";orig_file
  713.      EXIT SUB
  714.   END IF
  715.  
  716.   '..Get datestamp of original file before editing
  717.   get_file_datestamp(orig_file,ds1)
  718.   
  719.   '..Edit source file
  720.   SYSTEM config->editor+" "+quote(orig_file)
  721.  
  722.   '..Get datestamp of original file after editing
  723.   get_file_datestamp(orig_file,ds2)
  724.  
  725.   '..Flag file as "unmade" if it's changed;
  726.   '..delete any existing assembly source file
  727.   '..since it is now out of date.
  728.   IF datestamps_different(ds1,ds2) THEN
  729.      KILL config->tmpdir+prog->source_file+".s"
  730.      prog->made=FALSE
  731.   END IF
  732. END SUB
  733.  
  734. SUB invoke_make_script(STRING target_dir,SHORTINT object_type)
  735. SHARED  prog,config
  736. STRING  command
  737. STRING  msg SIZE strSize     
  738. STRING  target_file SIZE strSize     
  739. LONGINT target_ok
  740. DECLARE STRUCT DateStamp old_target,new_target
  741. CONST   BOLD=2&,NORMAL=0&,ALLBITS=255&
  742. DECLARE FUNCTION SetSoftStyle(Rp&,textstyle&,bitmask&) LIBRARY
  743.  
  744.   CLS
  745.   library "graphics.library"       
  746.   SetSoftStyle(WINDOW(8),BOLD,ALLBITS)
  747.   PRINT "Making ";CHR$(34);prog->source_file;CHR$(34)
  748.   SetSoftStyle(WINDOW(8),NORMAL,ALLBITS)
  749.   library close "graphics.library"
  750.  
  751.   target_file = target_dir+prog->source_file
  752.  
  753.   '..Delete the executable from previous compilations
  754.   '..(if there were any) so we know whether the make 
  755.   '..was successful or not.
  756.   KILL target_file
  757.  
  758.   '..Rename assembly source file (if it exists) with a ".old" extension.
  759.   '..This is used below to check whether a new target file has been created.
  760.   if fexists(target_file+".s") then
  761.      NAME target_file+".s" AS target_file+".old"
  762.   else
  763.      '..Create a dummy assembly source file so
  764.      '..there is something to compare the new
  765.      '..assembly source file (about to be created) to.
  766.      OPEN "O",#1,target_file+".old"
  767.      PRINT #1,"; dummy assembly source"
  768.      PRINT #1,"END"
  769.      CLOSE #1 
  770.   end if
  771.  
  772.   '..Delete old error file in case we don't generate one now
  773.   '..(ie: don't want old ace.err to be associated with current
  774.   '..compilation).
  775.   KILL "ace.err"
  776.  
  777.   '..start asynchronous process to Make the program. 
  778.   command = "NewShell "+CHR$(34)+"CON:0/125/640/100/Make program: "
  779.   command = command + prog->source_file+CHR$(34)
  780.   command = command + " FROM " + config->tmpdir+"AIDE-newshell-startup"
  781.   SYSTEM command  
  782.  
  783.   '..**********************************
  784.   '..Display messages from Make process 
  785.   '..while waiting for it to complete.
  786.   '..**********************************
  787.   OPEN "I",#1,"PIPE:"
  788.   repeat
  789.     LINE INPUT #1,msg
  790.     if msg<>"MakeDone" and msg<>"MakeAborted" and msg<>"" then PRINT msg 
  791.   until msg = "MakeDone" or msg = "MakeAborted"
  792.   CLOSE #1
  793.  
  794.   case 
  795.     object_type = ASM : PRINT "Assembly source file ";
  796.     object_type = EXE : PRINT "Executable file ";
  797.   end case
  798.  
  799.   '..***************
  800.   '..Successful Make
  801.   '..***************
  802.   if msg = "MakeDone" then 
  803.     if object_type=ASM then
  804.        '..assembly source is target
  805.        get_file_datestamp(target_file+".old",old_target)
  806.        get_file_datestamp(target_file+".s",new_target)
  807.        if fexists(target_file+".s") and older(old_target,new_target) then
  808.       target_ok=TRUE
  809.        else
  810.       target_ok=FALSE
  811.        end if
  812.     else
  813.        '..executable is target
  814.        if object_type=EXE then
  815.           target_ok=fexists(target_file)
  816.        else
  817.       '..unknown target type!
  818.       target_ok=FALSE
  819.        end if
  820.     end if
  821.  
  822.     if  target_ok then 
  823.       PRINT "created."
  824.       prog->made=TRUE
  825.     else
  826.       PRINT "not created."
  827.     end if
  828.   end if
  829.  
  830.   '..*****************
  831.   '..Unsuccessful Make
  832.   '..*****************
  833.   if msg = "MakeAborted" then
  834.     KILL target_dir+prog->source_file
  835.     KILL target_dir+prog->source_file+".s"
  836.     KILL target_dir+prog->source_file+".old"
  837.     PRINT "not created."
  838.     prog->made=FALSE
  839.   end if
  840. END SUB
  841.  
  842. SUB make_program(STRING target_dir,SHORTINT object_type)
  843. SHARED   config,prog,options,module$
  844. SHORTINT i
  845. STRING   command,opts
  846. STRING     ace_src_name SIZE strSize
  847. STRING     asm_src_name SIZE strSize
  848. DECLARE  STRUCT DateStamp ace_src,asm_src
  849.  
  850.   '..Generate a shell script to make the program.
  851.   OPEN "O",#1,config->tmpdir+"AIDE-newshell-startup"
  852.   
  853.   PRINT #1,"failat 11"
  854.   PRINT #1,"echo "+CHR$(34)+"*E[0;0H*E[J"+CHR$(34)
  855.   PRINT #1,"alias QuitMake echo >PIPE: MakeAborted"
  856.   PRINT #1,"stack 40000"
  857.  
  858.   ace_src_name = prog->source_dir+prog->source_file+".b"
  859.   asm_src_name = target_dir+prog->source_file+".s"
  860.  
  861.   '..Compare datestamps of ACE source and assembly source (if it exists!)
  862.   get_file_datestamp(ace_src_name, ace_src)
  863.   get_file_datestamp(asm_src_name, asm_src)
  864.   
  865.   '..We only want to compile the ACE source if it hasn't already been
  866.   '..compiled (by the user selecting "Compile Program" in the past).
  867.   IF NOT fexists(asm_src_name) OR NOT older(ace_src,asm_src) THEN
  868.     '*** APP ***  
  869.     PRINT #1,"echo >PIPE: Preprocessing"
  870.     command = "ACE:bin/app "+quote(ace_src_name)
  871.     command = command +" "+quote(target_dir+prog->source_file+".b")
  872.     PRINT #1,command
  873.  
  874.     '..preprocessor errors?
  875.     PRINT #1,"IF ERROR"
  876.     PRINT #1,"   echo >PIPE: Aborted!"
  877.     PRINT #1,"   echo >PIPE: MakeAborted"
  878.     PRINT #1,"   EndCLI"
  879.     PRINT #1,"ENDIF"
  880.  
  881.     '*** ACE ***
  882.     PRINT #1,"echo >PIPE: Compiling"
  883.     command = "ACE:bin/ace -E"
  884.  
  885.     '..Compiler switches? (the "i" switch is redundant here since
  886.     '..build_application copies the icon from ACE:icons/exe.info
  887.     '..but someone MAY expect the icon to also be in the working 
  888.     '..directory when compiling/making!)
  889.     opts=""
  890.     if options->user_break then opts = opts + "b"
  891.     if options->asm_comments then opts = opts + "c"
  892.     if options->create_icon then opts = opts + "i" 
  893.     if options->list_lines then opts = opts + "l"
  894.     if options->optimise then opts = opts + "O"
  895.     if options->window_close then opts = opts + "w"
  896.     if opts <> "" then command = command + opts+" "
  897.  
  898.     command = command + quote(target_dir+prog->source_file+".b")
  899.     PRINT #1,command
  900.  
  901.     '..compile-time errors?
  902.     PRINT #1,"IF ERROR"
  903.     PRINT #1,"   echo >PIPE: Aborted!"
  904.     PRINT #1,"   echo >PIPE: MakeAborted"
  905.     PRINT #1,"   EndCLI"
  906.     PRINT #1,"ENDIF"
  907.   END IF
  908.  
  909.   IF object_type = EXE THEN
  910.     '*** A68K ***
  911.     PRINT #1,"echo >PIPE: Assembling"
  912.     command = "ACE:bin/a68k "+quote(asm_src_name)
  913.     PRINT #1,command
  914.  
  915.     '*** BLINK ***
  916.     PRINT #1,"echo >PIPE: Linking"
  917.     command = "ACE:bin/blink "+target_dir+prog->source_file+".o"
  918.     command = command + " LIB "
  919.     '..add link modules
  920.     for i=1 to prog->module_count
  921.       if module$(i)<>"" then command = command + module$(i) + "+"
  922.     next
  923.     command = command + "ACElib:startup.lib+ACElib:db.lib+ACElib:ami.lib"
  924.     'command = command + "SMALLCODE SMALLDATA" 
  925.     PRINT #1,command
  926.   END IF
  927.  
  928.   '..OK -> we're finished
  929.   PRINT #1,"echo >PIPE: MakeDone"
  930.   PRINT #1,"EndCLI"
  931.  
  932.   CLOSE #1
  933.  
  934.   '..do it!
  935.   invoke_make_script(target_dir,object_type)
  936. END SUB
  937.  
  938. SUB compile_program
  939. SHARED config,prog
  940.   if not prog->made or not fexists(config->tmpdir+prog->source_file+".s") then
  941.      make_program(config->tmpdir,ASM)
  942.   else
  943.      PRINT prog->source_file;" is up to date."    
  944.   end if
  945. END SUB
  946.  
  947. SUB make_executable
  948. SHARED config,prog
  949.   if not prog->made or not fexists(config->tmpdir+prog->source_file) then
  950.      make_program(config->tmpdir,EXE)
  951.   else
  952.      PRINT prog->source_file;" is up to date."
  953.   end if
  954. END SUB
  955.  
  956. SUB run_program
  957. SHARED config,prog
  958.  
  959.   make_executable
  960.  
  961.   if prog->made then
  962.     PRINT "Running ";prog->source_file;"..."
  963.     SYSTEM quote(config->tmpdir+prog->source_file)
  964.     CLS
  965.     PRINT prog->source_file;" finished."
  966.   else
  967.     '..There (probably) was a compile error.
  968.     PRINT "Unable to run ";prog->source_file;"."
  969.   end if
  970. END SUB
  971.  
  972. SUB run_program_in_shell
  973. SHARED   config,prog
  974. STRING   prompt SIZE strSize
  975. STRING   title SIZE strSize
  976. STRING   script_call,arguments
  977. STRING   script_name SIZE strSize
  978. SHORTINT script_count
  979.  
  980.   make_executable
  981.  
  982.   if prog->made then
  983.     '..get command-line arguments
  984.     prompt = "Command-Line Arguments?"
  985.     title = "Run in Shell"
  986.     arguments = InputBox$(prompt,title,prog->default_args,170,50)
  987.  
  988.     '..construct a shell script: script must have a unique name
  989.     '..since multiple shell scripts may be in use.
  990.     script_count=0
  991.     repeat
  992.       script_name=config->tmpdir+"command-script-"+MID$(STR$(script_count),2)
  993.       ++script_count
  994.     until NOT fexists(script_name)
  995.  
  996.     OPEN "O",254,script_name
  997.     PRINT #254,"failat 11"
  998.     PRINT #254,"echo "+CHR$(34)+"*E[0;0H*E[J"+CHR$(34) '..cls
  999.     PRINT #254,"prompt "+CHR$(34)+CHR$(34)
  1000.     PRINT #254,"stack 40000"
  1001.     PRINT #254,quote(config->tmpdir+prog->source_file)+" "+arguments
  1002.     CLOSE #254
  1003.  
  1004.     '..Execute it!
  1005.     script_call = "NewShell "+CHR$(34)
  1006.     script_call = script_call+"CON:0/125/640/100/Run Window/CLOSE"
  1007.     script_call = script_call+CHR$(34)+" FROM "
  1008.     script_call = script_call+script_name
  1009.     SYSTEM script_call
  1010.     CLS
  1011.  
  1012.     '..store default arguments for program.
  1013.     prog->default_args = arguments
  1014.   else
  1015.     '..There (probably) was a compile error.
  1016.     PRINT "Unable to run ";prog->source_file;"."
  1017.   end if
  1018. END SUB
  1019.  
  1020. SUB build_application
  1021. SHARED config,prog,options
  1022. STRING command,dest_dir
  1023.  
  1024.   make_executable
  1025.  
  1026.   '..where's the executable going?
  1027.   if config->bltdir<>"" then 
  1028.      dest_dir = config->bltdir
  1029.   else
  1030.      dest_dir = prog->source_dir
  1031.   end if
  1032.   '..copy executable
  1033.   command = "sys:c/copy >NIL: "+config->tmpdir+prog->source_file+" "
  1034.   command = command + quote(dest_dir+prog->source_file)
  1035.   SYSTEM command
  1036.   '..copy icon?
  1037.   if options->create_icon then
  1038.     command = "sys:c/copy >NIL: ACE:icons/exe.info "
  1039.     command = command + quote(dest_dir+prog->source_file+".info")
  1040.     SYSTEM command
  1041.   end if
  1042.   '..were we successful?
  1043.   if prog->made then 
  1044.     PRINT dest_dir+prog->source_file;" has been built."
  1045.   end if
  1046. END SUB
  1047.  
  1048. SUB view_assembly_source
  1049. SHARED config,prog
  1050. STRING fname SIZE strSize 
  1051.   fname = config->tmpdir+prog->source_file+".s"
  1052.   if fexists(fname) then 
  1053.     SYSTEM config->viewer+" "+quote(fname)
  1054.   else
  1055.     PRINT "No assembly source present."
  1056.   end if
  1057. END SUB
  1058.  
  1059. SUB view_preprocessed_source
  1060. SHARED config,prog
  1061. STRING fname SIZE strSize 
  1062.   fname = config->tmpdir+prog->source_file+".b"
  1063.   if fexists(fname) then 
  1064.     SYSTEM config->viewer+" "+quote(fname)
  1065.   else
  1066.     PRINT "No preprocessed source present."
  1067.   end if
  1068. END SUB
  1069.  
  1070. SUB show_compiler_errors
  1071. SHARED config
  1072.   OPEN "I",#1,"ace.err"  
  1073.   if HANDLE(1) then 
  1074.     if LOF(1)<>0 then
  1075.       SYSTEM config->viewer+" ace.err"
  1076.     else
  1077.       PRINT "There were no compilation errors."
  1078.     end if
  1079.   else
  1080.     PRINT "No ACE error log."
  1081.   end if
  1082.   CLOSE #1
  1083. END SUB
  1084.  
  1085. SUB handle_program_menu(item)
  1086.   case
  1087.     item = iSetSource    : set_source
  1088.     item = iEdit    : edit_source
  1089.     item = iRun        : run_program
  1090.     item = iRunInShell    : run_program_in_shell
  1091.     item = iCompile      : compile_program
  1092.     item = iMake    : make_executable
  1093.     item = iBuild    : build_application
  1094.     item = iViewAsm    : view_assembly_source
  1095.     item = iViewPrep    : view_preprocessed_source
  1096.     item = iShowErrs    : show_compiler_errors
  1097.   end case
  1098. END SUB
  1099.  
  1100. {------------------------------------------------------}
  1101.  
  1102. SUB change_option_state(ADDRESS opt,SHORTINT item)
  1103.   if NOT *&opt then
  1104.     *&opt:=TRUE
  1105.     MENU mCompiler,item,cCheck
  1106.   else
  1107.     *&opt:=FALSE
  1108.     MENU mCompiler,item,cEnable
  1109.   end if
  1110. END SUB
  1111.  
  1112. SUB handle_compiler_menu(item)
  1113. SHARED  options
  1114. ADDRESS opt
  1115.   case
  1116.     item = iBreak    : opt = @options->user_break
  1117.     item = iComments    : opt = @options->asm_comments
  1118.     item = iIcon    : opt = @options->create_icon
  1119.     item = iListLines    : opt = @options->list_lines
  1120.     item = iOptimise    : opt = @options->optimise
  1121.     item = iWindow    : opt = @options->window_close
  1122.   end case
  1123.  
  1124.   change_option_state(opt,item)
  1125. END SUB
  1126.  
  1127. {------------------------------------------------------}
  1128.  
  1129. SUB add_link_module
  1130. SHARED   module$,prog 
  1131. SHORTINT maxMod,i
  1132. LONGINT  found
  1133. STRING   module SIZE strSize
  1134.  
  1135.   '..add a module to the list of object files to link.
  1136.  
  1137.   maxMod = prog->module_count + 1
  1138.  
  1139.   if maxMod <= maxModules then
  1140.     '..get name of module
  1141.     module = FileBox$("Add Module")
  1142.  
  1143.     if module <> "" then 
  1144.       '..is module already in the list?
  1145.       found=FALSE
  1146.       for i=1 to prog->module_count
  1147.     if module$(i) = module then found=TRUE
  1148.       next
  1149.  
  1150.       if not found then
  1151.     '..No -> add module to list
  1152.         module$(maxMod) = module
  1153.         MENU mLinker,iSep4.1+maxMod,cEnable,module$(maxMod)
  1154.     
  1155.         '..increment module count
  1156.         prog->module_count = prog->module_count + 1
  1157.        
  1158.      '..program may need to be remade
  1159.     prog->made=FALSE
  1160.  
  1161.     PRINT module$(maxMod);" added to list."
  1162.  
  1163.         '..enable "remove" menu items when there is 1 module in the list.
  1164.         if prog->module_count = 1 then 
  1165.           MENU mLinker,iRemModule,cEnable
  1166.           MENU mLinker,iRemAllMod,cEnable
  1167.         end if
  1168.       else
  1169.         PRINT module;" already in list."
  1170.       end if
  1171.     else
  1172.       PRINT "No module specified."
  1173.     end if
  1174.   else
  1175.     PRINT "No more than";maxModules;"modules can be specified."
  1176.   end if
  1177. END SUB
  1178.  
  1179. SUB enable_menu_items
  1180. SHARED prog
  1181.   '..enable menu items disabled by setup_menus
  1182.  
  1183.   if prog->source_file = "" then exit sub
  1184.  
  1185.   MENU mProgram,iEdit,cEnable
  1186.   MENU mProgram,iRun,cEnable
  1187.   MENU mProgram,iRunInShell,cEnable
  1188.   MENU mProgram,iArguments,cEnable
  1189.   MENU mProgram,iCompile,cEnable
  1190.   MENU mProgram,iMake,cEnable
  1191.   MENU mProgram,iBuild,cEnable
  1192.   MENU mProgram,iViewAsm,cEnable
  1193.   MENU mProgram,iViewPrep,cEnable
  1194.   MENU mProgram,iShowErrs,cEnable  
  1195. END SUB
  1196.  
  1197. SUB remove_link_module
  1198. SHARED   module$,prog 
  1199. SHORTINT maxMod,n,i
  1200. LONGINT  found
  1201. STRING   module SIZE strSize
  1202.  
  1203.   '..remove a module from the list of files to link.
  1204.   maxMod = prog->module_count
  1205.  
  1206.   if maxMod > 0 then
  1207.     '..get module name
  1208.     module = FileBox$("Remove Module")
  1209.  
  1210.     '..remove module from list if it exists.
  1211.     if module <> "" then
  1212.       found=FALSE
  1213.       for n=1 to maxMod
  1214.         if module$(n) = module and not found then 
  1215.        found=TRUE 
  1216.        module$(n)=""
  1217.         end if
  1218.       next
  1219.  
  1220.       if found then
  1221.       '..restore module list
  1222.       CLS
  1223.        PRINT "Updating..."
  1224.           '..shuffle module list entries
  1225.           for n=1 to MaxMod
  1226.             for i=maxMod to 2 step -1
  1227.           if module$(i-1) = "" then 
  1228.          module$(i-1) = module$(i)  
  1229.          module$(i) = ""
  1230.           end if
  1231.             next
  1232.           next
  1233.         '.fix menus
  1234.           menu clear
  1235.           setup_menus
  1236.       enable_menu_items
  1237.            MENU mLinker,iRemModule,cEnable
  1238.       MENU mLinker,iRemAllMod,cEnable
  1239.              for i=1 to maxMod
  1240.         if module$(i)<>"" then MENU mLinker,iSep4.1+i,cEnable,module$(i)
  1241.       next
  1242.       CLS
  1243.  
  1244.       '. decrement module count
  1245.           prog->module_count = prog->module_count - 1
  1246.  
  1247.        '..program may need to be remade
  1248.       prog->made=FALSE
  1249.  
  1250.       '..disable "remove" menu items if all have been removed.
  1251.       if prog->module_count = 0 then 
  1252.          MENU mLinker,iRemModule,cDisable
  1253.          MENU mLinker,iRemAllMod,cDisable
  1254.       end if
  1255.       else
  1256.           PRINT module;" not in list."
  1257.       end if
  1258.     else
  1259.       PRINT "No module specified."
  1260.     end if
  1261.   else
  1262.     PRINT "No modules to remove."
  1263.   end if
  1264. END SUB
  1265.  
  1266. SUB remove_all_modules
  1267. SHARED   prog,module$
  1268. SHORTINT i
  1269.   CLS  
  1270.   PRINT "Updating..."
  1271.   menu clear
  1272.   setup_menus
  1273.   enable_menu_items
  1274.   for i=1 to maxModules
  1275.     module$(i)=""
  1276.   next
  1277.   CLS
  1278.   '..no modules left
  1279.   prog->module_count = 0
  1280.   '..program may need to be remade
  1281.   prog->made=FALSE
  1282. END SUB
  1283.  
  1284. SUB handle_linker_menu(item)
  1285.   case
  1286.     item = iAddModule : add_link_module 
  1287.     item = iRemModule : remove_link_module
  1288.     item = iRemAllMod : remove_all_modules
  1289.   end case
  1290. END SUB
  1291.  
  1292. {------------------------------------------------------}
  1293.  
  1294. SUB ace_doc
  1295. SHARED config
  1296.   SYSTEM config->viewer+" "+quote(config->docdir+"ace.doc")
  1297. END SUB
  1298.  
  1299. SUB a68k_doc
  1300. SHARED config
  1301.   SYSTEM config->viewer+" "+quote(config->docdir+"a68k.doc")
  1302. END SUB
  1303.  
  1304. SUB blink_doc
  1305. SHARED config
  1306.   SYSTEM config->viewer+" "+quote(config->docdir+"blink.doc")
  1307. END SUB
  1308.  
  1309. SUB ace_ref
  1310. SHARED config
  1311.   if config->agddir="" then
  1312.     '..AmigaGuide not installed -> use ref.doc
  1313.       SYSTEM config->viewer+" "+quote(config->docdir+"ref.doc")
  1314.   else
  1315.     '..AmigaGuide installed -> use ref.guide
  1316.       SYSTEM config->agddir+"AmigaGuide "+quote(config->docdir+"ref.guide")
  1317.   end if    
  1318. END SUB
  1319.  
  1320. SUB handle_help_menu(item)
  1321.   case
  1322.     item = iACEDoc     : ace_doc
  1323.     item = iA68KDoc     : a68k_doc
  1324.     item = iBlinkDoc     : blink_doc
  1325.     item = iACERef     : ace_ref
  1326.   end case
  1327. END SUB
  1328.  
  1329. {------------------------------------------------------}
  1330.  
  1331. SUB event_loop(SHORTINT first_menu_selection)
  1332. SHORTINT menuNum,itemNum
  1333.   repeat
  1334.     menu wait
  1335.     if first_menu_selection then 
  1336.     cls   '..remove initial "Select a menu option" message.
  1337.     first_menu_selection = FALSE
  1338.     end if
  1339.     menuNum = MENU(0)
  1340.     itemNum = MENU(1)
  1341.     case 
  1342.       menuNum = mProject  : handle_project_menu(itemNum)
  1343.       menuNum = mProgram  : handle_program_menu(itemNum)
  1344.       menuNum = mCompiler : handle_compiler_menu(itemNum)
  1345.       menuNum = mLinker   : handle_linker_menu(itemNum)
  1346.       menuNum = mHelp     : handle_help_menu(itemNum)
  1347.     end case
  1348.   until menuNum = mProject and itemNum = iQuit
  1349. END SUB
  1350.  
  1351. SUB clean_up
  1352. SHARED config
  1353.   '..delete tmpdir files 
  1354.   SYSTEM "delete >NIL: "+quote(config->tmpdir+"#?")
  1355.   KILL "ace.err"
  1356. END SUB
  1357.  
  1358.  
  1359. {*
  1360. ** Main Program
  1361. *}
  1362.  
  1363. window 1,"AIDE version 1.01",(0,10)-(640,125),22
  1364. if SYSTEM >= 37 then
  1365.   initialise_environment
  1366.   setup_menus
  1367.   cls
  1368.   print "Select a menu option."
  1369.   event_loop(TRUE)
  1370.   clean_up
  1371. else
  1372.   reply=MsgBox("Need Wb 2.04 or higher. See AIDE.doc for more.","OK")
  1373. end if
  1374. window close 1
  1375.