All About [inline] Apple [inline] iigs basic page content composed, converted, compiled, edited and copyright (c) 1997 by Charles T



Download 38.17 Kb.
Date30.07.2017
Size38.17 Kb.
#24934
All About [INLINE] Apple [INLINE] IIGS BASIC _________________________________________________________________ Page content composed, converted, compiled, edited and copyright (c) 1997 by Charles T. Turley _________________________________________________________________ Apple IIGS BASIC is a RAM-based BASIC language for the Apple IIGS. Apple IIGS BASIC requires at least 512K RAM and one 3.5" disk drive. To download the Shrinkit archive of Apple IIGS BASIC click on any of the GS BASIC links in this page. Differences between Apple IIGS BASIC and Applesoft BASIC Because GS BASIC and Applesoft files are stored differently on the disk, they are not interchangeable. GS BASIC is designed to run under ProDOS 16, whereas Applesoft can run only under ProDOS 8. GS BASIC also appears to run just fine under GS/OS (all versions up to 6.0.1). Summary of Apple IIGS BASIC Features Includes all standard BASIC commands. Provides access to external routines, which allow a BASIC programmer to call the Apple IIGS's ToolBox routines (QuickDraw II, Menu Manager, Window Manager, Sound Manager, etc.). Can define and call library routines. These are loaded with the INVOKE command, and called with the PERFORM and EXFN commands. Permits formatted program listings. Users can specify how much space appears between a line number and the first statement, and the amount of indenting to perform when listing program statement within a loop. Contains built-in constants and variables, such as PI, VPOS and HPOS. Enhances the GOTO, GOSUB, and ON xxx commands by allowing the programmer to specify destination by labels instead of line numbers. Allows programmers to define specific procedures that are called with the PROC command. Not only does the PROC command perform the same functions of AppleSoft's GOSUB, but it also lets the programmer pass local parameters. Enhances the looping capabilities of Applesoft with the following looping structures: IF..THEN..ELSE FOR..NEXT..STEP DO..WHILE..UNTIL Implements PRINT USING and INPUT USING. Gives the programmer the variable types Integer, Real, String, Double Real, Double Integer, and Long Integer. Has a powerful line editor. Includes some primitives (built-in low-level commands) that let the user interact with the ToolBox routines. The commands Eventdef, Menudef, and Taskpoll are included in GS BASIC itself because they provide a tying bind between the ToolBox and BASIC line numbers. Variable Specifications Real: (+ or - 1.7E38) (less than 1.5E-45 equals 0) Double real: (+ or - 1.7E308) (less than 5.0E-324 equals 0) Integer: (%) (2 bytes) (-32768 to 32767) Double integer: (@) (4 bytes) (-2147483648 to 2147483647) Long integer: (&) (8 bytes) (-9223372036854775808 to 9223372036854775807) String: ($) 255 characters Arrays: (!) GS BASIC vs Applesoft BASIC Unlike Applesoft BASIC, GS BASIC gives programmers access to all of the new features of the Apple IIGS: Super hi-res graphics, the Ensoniq sound chip, expanded memory, the new Tools, and other enhanced ROM facilities. GS BASIC is an entirely RAM-based language. It does not rely on Applesoft, nor is it related to it in any way except that they are both BASIC languages. In fact, because of advanced features like access to all of GS RAM, more powerful I/O instructions, and access of external routines, GS BASIC is not 100% compatible with Applesoft. The number of commands is increased from 120 to over 200 (see List of GS BASIC Commands), many Applesoft BASIC commands do different things in GS BASIC, and some Applesoft commands do not appear in GS BASIC at all (PR#, IN#, and HGR for example). Applesoft and GS BASIC files are stored differently on disk, and are not interchangeable. Finally, GS BASIC is designed to run under ProDOS 16, whereas Applesoft can run only under ProDOS 8. Otherwise, GS BASIC would not be able to take advantage of the GS's powerful new features. GS BASIC gives the programmer twice the number of variable types that Applesoft has. In addition to Integer, Real, and String types, GS BASIC provides Double Real, Double Integer, and Long Integer. GS BASIC is not as fast as Applesoft. Applesoft runs the following program in 4 seconds, while GS BASIC takes 43 seconds: 10 FOR i = 1 TO 10000 60 NEXT i With longer programs, the difference is less. This program takes Applesoft 48 seconds and GS BASIC 217 seconds: 10 FOR i = 1 TO 10000 20 a=i-i 30 a=i+i 40 a=i/i 50 a=i*i 60 NEXT i Access to External Routines One of GS BASIC's main advantages is its powerful library and external routine facilities. Provided with GS BASIC are many ToolBox Definition Routines (TDFs) that let programmers call the GS's ToolBox routines (QuickDraw II, Menu Manager, Window Manager, Sound Manager, and so on). These routines are setup with the LIBRARY command, and called with the CALL and EXFN commands. Programmers can also define and call their own library routines. These are loaded with the INVOKE command, and called with the PERFORM and EXFN commands. Display Format GS BASIC offers improved formatting of listings. Users can specify how much space appears between a line number and the first statement, and how far to indent when listing program statements within a FOR...NEXT or DO...WHILE...UNTIL loop. See the List of Built-in Constants and Reserved Variables. Sound Sound is created through Sound Manager routines. Built-in Constants and Variables GS BASIC includes pi calculated to 20 digits. Also, GS BASIC stores many system parameters in reserved variables. Much of the system's status can be determined and changed by examining and setting these variables. For example, the cursor's screen position is stored in the variables VPOS and HPOS. You can move the cursor simply by assigning new values to these variables. Labels GOTO, GOSUB, and ON xxx commands can point to labels instead of line numbers, making programs much easier to follow. Instead of: 1234 GOSUB 50: REM Read a character from the modem the programmer can type: 1234 GOSUB READ_MODEM Looping GS BASIC includes three looping structures not in Applesoft: IF...THEN...ELSE FOR...NEXT...STEP DO...WHILE...UNTIL These structures, common in other languages such as Pascal and Fortran, give the programmer greater flexibility in program control. In addition, the IF...THEN structure has multi-line capabilities. This means that all statements that appear between the IF and the THEN do not have to appear on the same line. PRINT USING and INPUT USING PRINT USING and INPUT USING have long been a features of BASICs other than Applesoft. GS BASIC implements them with a vengeance, making them nearly as powerful as FORTRAN format statements. A programmer has many ways to specify how to print data to a screen and read it from a keyboard or other device. When defining a USING statement, a programmer can specify it in many ways. The first way is to specify the format on the same line, right after the USING statement. The second way is to assign the formatting string to a variable (such as FMT$), and then enter that variable after the USING statement. This allows the programmer to use the same formatting in many PRINT statements. Or, if the programmer doesn't want to use variable space to store a formatting string, he can use the IMAGE command to define it. The programmer can then simply refer to the line on which it appears in the PRINT USING statement. All of these options apply to INPUT USING as well. PRINT and and INPUT USING don't merely have to work with the text screen. With optional device extensions, a programmer can PRINT or INPUT to or from a file, or PRINT to a printer or even the Super-Hi-res graphics screen. Finally, GS BASIC offers many formatting commands that are to be placed in the formatting strings. These are divided into three groups: String Spec, Literal Spec, and Numeric Spec. Numeric Spec is further divided into three sub-sections: FIXSPEC, SCISPEC, and ENGRSPEC. The SCALE command can be used to accurately reposition a decimal point in a floating point number. GS BASIC includes primitives (built-in, low-level commands) that let the user interact with the ToolBox routines. Whereas most other ToolBox routines are implemented in external libraries that need to be explicitly called up, these commands -- Eventdef, Menudef, and Taskpoll -- are included in GS BASIC itself because they bind the ToolBox and BASIC line numbers. Eventdef. The structure of Macintosh-like programs, as implemented by the Apple IIGS and its ToolBox routines, requires that programs be event-driven. This means that the heart of a program is a main loop that constantly monitors what events -- mouse clicks, keyboard presses, window update events, network activity, and so on -- have taken place. Eventdef associates BASIC line numbers with these events: whenever one of these events occurs, GS BASIC starts running the instructions specified in a table set up by the programmer and maintained by Eventdef. Menudef. One of the places a mouse click can occur is in the menu bar. When this happens, a menu is displayed, letting the user select a menu item. The user specifies that a certain function is to be performed. Like Eventdef, Menudef associates BASIC line numbers with menu items, so that when a menu item is selected, GS BASIC can easily determine what statements to run, and run them. Taskpoll. Programs shouldn't start fielding events and responding to them until all the ToolBox libraries are loaded and the tables that Menudef and Eventdef maintain are initialized. The Taskpoll command lets the programmer turn off the interrupting feature of GS BASIC and turn them on when ready for them. Procedures and Functions The most convenient structure of of any program is a procedure, function, or subroutine. In most BASICs, including Applesoft, subroutines are implemented in a very straightforward fashion. GS BASIC provides a more powerful way to specify and call procedures. Applesoft lets programmers call subroutines with the GOSUB xxx command, where xxx is the line number to which control branches. Statements are then executed until a RETURN command is executed, at which time the program returns to the line that called the subroutines, and continues from there. GS BASIC allows programmers to define specific procedures that are called with the PROC command. The PROC command performs the same functions as Applesoft's GOSUB, and lets the programmer pass local parameters as well. Editing Commands GS BASIC has a more powerful line editor than Applesoft's. Access it by typing EDIT linnum[-linnum] CONTROL-D delete character to the left of cursor; moves line to left CONTROL-F delete character under the cursor; moves line left CONTROL-X delete entire line CONTROL-Y delete line to left and under cursor CONTROL-E toggle insert mode RETURN accept entire line (even characters to right of cursor) DELETE same as CONTROL-D GS BASIC Commands _ (underscore) ERRLIN LOG( SCALB( ABS( ERROR LOG1( SCALE( AND ERRTOOL LOG2( SECONDS@ ANU( ERRTXT$( LOGB%( SET APPEND EVENTDEF MENUDEF SGN( AS EXCEPTION MID$( SHOWDIGITS ASC( EXEC MOD SIN( ASSIGN EXEVENT@( NEGATE( SPACE$( ATN( EXFN NEW SPC( AUTO EXP( NEXT SQR( AUXID@ EXP1( NORMAL SRC BASIC@( EXP2( NOT STEP BDF FILE( NOTRACE STOP BREAK FILTYP( OFF STR$( BTN( FILTYP= ON SUB$( CALL FIX( OPEN SWAP CALL% FN OR TAB( CAT FOR OPUTPUT TAN( CATALOG FRE OUTREC TASKPOLL CHAIN FREMEM( PDL( TASKREC%( CHR$( GET PEEK( TASKREC@( CLEAR GOSUB PERFORM TEN( CLOSE GOTO PFX$( TEXT COMPI( GRAF PI TEXTPORT CONT HEX$( POKE THEN CONV( HLIST PREFIX TIME$ CONV@( HOME PREFIX$ TIME( CONV#( HPOS PRINT TIMER CONV$( IF PROC TO CONV%( IMAGE PROGNAM$ TRACE CONV&( INDENT PUT TXT COPY INIT QUIT TYPE COS( INPUT R.STACK%( TYP( CREATE INSTR( R.STACK@( UBOUND( DATA INT( R.STACK&( UCASE$( DATE$ INVERSE RANDOMIZE UIR( DATE( INVOKE READ UNLOCK DEF JOYX( REC( UNTIL DEL JOYY( RELATION( UPDATE DELETE KBD REM USING DIM LEFT$( REMDR VAL( DIR LEN( RENAME VAR( DIV LET REP$( VAR$( DO LIBFIND RESTORE VARPTR( EDIT LIBRARY RESUME VARPTR$( ELSE LIST RETURN VOLUMES END LISTTAB RIGHT$( VPOS EOF LOAD RND( WHILE EOFMARK( LOCAL ROUND( WRITE ERASE LOCATE RUN XOR ERR LOCK SAVE Toolbox Definition Files (TDFs) QuickDraw ADB Desk Dialog Event Font Intmath LineEdit List Loader Locater Memory Menu MiscTool NoteSyn Print QDAux Scheduler Scrap StdFile Text Window Control Built-in Constants and Reserved Variables PI to 20 digits LISTTAB number of spaces between line number and first statement INDENT controls indenting of FOR...NEXT and WHILE...UNTIL loops OUTREC maximum line length VPOS vertical cursor position HPOS horizontal cursor position FRE amount of memory available SHOWDIGITS specifies the number of digits to display for REAL numbers KBD holds value of last key pressed ERR contains error number ERRLIN contains line where error occurred Variable Specifications Real: (+ or - 1.7E38) (less than 1.5E-45 equals 0) Double real: (+ or - 1.7E308) (less than 5.0E-324 equals 0) Integer: (%) (2 bytes) (-32768 to 32767) Double integer: (@) (4 bytes) (-2147483648 to 2147483647) Long integer: (&) (8 bytes) (-9223372036854775808 to 9223372036854775807) String: ($) 255 characters Arrays: (!) __________________________________________________________________ GS BASIC text, information and ref. materials obtained from Apple Tech Info Library - Search. All graphics, brand and product names 'used' are the trademarks and/or registered trademarks of their respective holders. __________________________________________________________________ Return to GS WorldView 'PARENT DIRECTORY'
Download 38.17 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page