Try

From Pickwiki
Revision as of 23:48, 26 February 2015 by Conversion script (talk) (link fix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Back to BasicSource

This program allows you to compile and run basic code from the command line.

You can enter the code on the command line or just enter the command and let it prompt for multi-line input.

It writes an item TRIAL to a file called BP, and then compiles and runs it.

If you want a different file or item name, you will have to amend the source code.

      PROGRAM TRY 
 * ECL - KRJ - Run command line or multiple input lines as a program
      FOLDER = 'BP'
      ITEMID = 'TRIAL'
      THIS = @SENTENCE
      POSN = INDEX(UPCASE(THIS),'TRY',1)
      THIS = THIS[POSN+4,99999]
      OPEN FOLDER TO THAT ELSE
         CRT 'Cannot open file ':FOLDER
         CRT 'Edit the program and change the file name to suit'
         STOP
      END
      IF TRIM(THIS) = '' THEN
         THIS = ''
         CRT 'Enter lines of code or press <Enter> for help'
         LOOP
            INPUT LINE
         UNTIL LINE = '' DO
            THIS<-1> = LINE
         REPEAT
      END
      IF TRIM(THIS) = '' THEN
         CRT 'Utility to run program ccode from TCL[[/ECL]]'
         CRT
         CRT 'Syntax:'
         CRT '   TRY {BASIC COMMANDS}'
         CRT
         CRT 'Example:'
         CRT '   TRY CRT SYSTEM(3)'
         CRT
         CRT 'If you just enter TRY, then you can enter multiple lines'
         CRT 'which will be compiled and run when you enter a blank line'
         STOP
      END
      WRITE THIS ON THAT, ITEMID
      EXECUTE 'BASIC ':FOLDER:' ':ITEMID
      EXECUTE 'RUN ':FOLDER:' ':ITEMID