index   prev   next RISC OS Notes

BASIC

# AppBasic

to add an app, say !app to examples open !AppBasic and copy !app to ...!AppBasic.Resources.Examples NOTE !app must be in AppBasic format

# debugging BASIC - see TRACE using !Reporter

# convert textfile to basic - or EVAL blanks

StrongEd detokenises basic files when loading and tokenises them when saving. This gives rise to a problem when trying to get code in from a text file. 1 - Save as basic then change all "EVAL" to "" - preserves indents or, 2 - remove all blanks before saving as basic.

# BASIC docs soft

- don't forget HELP in BASIC environment - ADFS::HardDisc5.$.DOCZ.!Manuals.Root.BASIC - ADFS::HardDisc5.$.DOCZ.!Manuals.Root.AppBasic - ADFS::HardDisc5.$.PROGRAMZ.BASIC.APPBASIC.AppBasic/pdf - ADFS::HardDisc5.$.DOCZ.ROadjust.manuals.HTML.INDEX/HTML - !Routines has helptext and eg program !MouseInfo - DRWimp ADFS::HardDisc5.$.DOCZ.!Manuals.Root.FuncProc - DRWimp ADFS::HardDisc5.$.PROGRAMZ.DRWIMP.HTMLManual.Contents/html - DRWimp ADFS::HardDisc5.$.PROGRAMZ.DRWIMP.Documents.!Fnc'n'Prc - BBC BASIC for Windows - see web site

# BASIC docs paper

- BASIC V Mike Williams book - BBC Microcomputer User Guide - Archimedes User Guide - DR Wimp's surgery

# running a BASIC program in a task window 1

# running a BASIC program in a task window 1

easy - run !GraphTask drop basic program on iconbar icon to run another - menu on window >>Kill >>Reconnect drop basic program on window

# running a BASIC program in a task window 2

Create a text file with the code to be executed. Give it a Type of TaskExec (&FD6). Double click it and it will run in a TaskWindow eg:- echo basic 10 a$ = "The time is "+ STR$(TIME) 20 PRINT a$ RUN PRINT "We are still in BASIC mode Until we QUIT" *echo note - the star is needed as we are in BASIC LIST QUIT

# running a BASIC program in a task window 3

"Ever wanted a BASIC program or stand-alone ABSOLUTE to open in a TaskWindow without all the messing about? !InAWindow , installed in Boot.Tasks, defines two new filetypes - TskBasic and TaskApp - that perform this miracle. You will probably want to alter Zap's Types file so &AA5 is loaded into Basic mode, and &AA6 is loaded into Code mode. Yes, these filetypes and the Boot.Tasks location were officially allocated." Nemo to use:- edit the BASIC program in SEd Basemode save with type "TskBasic" and double click to run (do not just change the type form BASIC to TskBasic)

# Reading a system variable from BASIC

eg this works DIM buffer%255 var$ = "Obey$Dir" SYS"OS_ReadVarVal",var$,buffer%,255,0,3 TO ,,bytes%,type% buffer%?bytes%=13 a$=$buffer% *report a$ but read on... system variable set in the !Run:- Set MaxNumberOfFonts 32 want to read this value into a BASIC variable. first thing we need to do is to extract the value of the system variable into a string that we can manipulate. PRM volume II, eventually found OS_ReadVarVal (SWI &23) on page 750. On entry, R0 points to the name of the system variable to be read, R1 points to a suitable buffer to store the string in, R2 is the maximum length of this buffer, R3 set to 0 to use first occurrance of the named system variable R4 set to 3 so that an expanded string is returned in the buffer. On exit, we have the value of the system variable in a string. The next task is to convert this string into a number using OS_ReadUnsigned (SWI &21) on page 585. On entry, R0 set to 0 so base is 10 unless string indicates otherwise, R1 is the pointer to the string On exit: R2 contains the value of the system variable as an integer, In BASIC this can be achieved with 4 instructions: MaxBufferLength = 16 DIM Bufferptr MaxBufferLength SYS "OS_ReadVarVal","MaxNumberOfFonts",Bufferptr, MaxBufferLength,0,3 SYS "OS_ReadUnsigned",0,Bufferptr TO ,,value% To give a quick example of its use: 'SetMaxNumber OfFonts 16' gives value% = 16 'SetMaxNumber OfFonts &20' gives value% = 32 This may be of use to programmers, as it allows constants to be set up in the !Run obey file and users can modify them to fit their requirements, without having to modify the program itself. John 'Lofty' Wallace.

# write a system variable from basic and display OS level

set Sys$level dummy basic 100 REM 120 ON ERROR PROC_error 200 SYS "OS_Byte",0 300 END 500 DEFPROC_error 520 LET oslevel$=REPORT$ 525 *report oslevel$ 530 PROC_setvar 550 END 590 ENDPROC 700 DEFPROC_setvar 710 syslev$="Sys$Level" 720 SYS "OS_SetVarVal",syslev$,oslevel$,LEN(oslevel$),4 730 REM 740 REM 790 ENDPROC RUN QUIT show Sys$level

# run a star command from basic with a variable

eg 1 LET ip$ = "loopback" OSCLI ("ping -c1 " + ip$)

# ascii hex and characters in BASIC

delim$ = CHR$(9)

# concatenation of strings - use +

© JR 2013