Upload
lythuan
View
222
Download
1
Embed Size (px)
Citation preview
2
FUZE BASIC
Programmer’sReference Guide
Introduction
Immediate Mode Commands
Functions, Constants & Procedures
Joystick and Gamepad commands
Keycodes (scanKeyboard)
Notes & Octaves for Sound command
For new commands, features and projects visit;
www.fuze.co.uk
Published in the United Kingdom ©2016 - 2016 FUZE Technologies Ltd. FUZE, FUZE BASIC,FUZE logos, designs, documentation and associated materials are Copyright FUZE Technologies Ltd.No part of this document may be copied, reproduced and or distributed without written consent fromFUZE Technologies Ltd. All rights reserved.
With many thanks and a great deal of respect to Gordon Henderson for his work on RTB where FUZE BASIC originated.
FUZE BASIC is developed by FUZE Technologies Ltd in the UK. The team consists of;
Jon Silvera - Project managerLuke Mulcahy - Lead programmerDavid Silvera - FUZE Product managerColin Bodley - DocumentationAdditional information – www.fuze.co.uk
Manual Version: Date: 17th June 2016 FUZE BASIC Version: 3.5
3
4
12
131
132
133
3main index
IntroductionThis reference guide aims to provide a comprehensive anddetailed explanation of every command in the FUZE BASIClibrary.
It is an evolving document because FUZE BASIC is constantlybeing updated and improved. To download the latest versionplease visit the resources section on the www.fuze.co.ukwebsite.
FUZE BASIC is currently available for Microsoft Windows®,Raspberry Pi, The FUZE and Linux. We hope to add Android inthe coming months and possibly Mac OSx & iOS versions too.
Listed alongside each command is a series of operating systemicons highlighted to show which OS the command iscompatible with. For example;
ANALOGREAD
The direct analog commands require the FUZE IO Boardbecause it has a built in analog chip whereas the Raspberry Pidoes not have one as standard.
SENSEPLOT
..because this command will work on a standalone Pi and aFUZE with a senseHAT connected.
Installing FUZE BASICFor details on installing and getting started we highlyrecommend you begin with the FUZE BASIC Project Workbookwhich can be downloaded for free from the FUZE website.
The website also has many other tutorials, examples andprojects. You are encouraged to contribute more to help fellowcoding students.
Introduction
displays
displays
Here at FUZE we’re constantly adding new commands andfeatures so it is worth checking the resource pages on the FUZEwebsite for new versions from time to time.
CommunityWe really hope you enjoy using FUZE BASIC as much as we do.While it is intended as a language to learn coding with ratherthan one you would expect to use in a professional environment,it is unquestionably very powerful and flexible. As such it makesan ideal steppingstone between visual coding platforms likeScratch and more complex professional languages like C++, Java,PHP and so on.
If you find yourself becoming quite proficient at FUZE BASIC thenwhy not show off er.. share your work on the FUZE website. Atthe very least you’ll be helping others to progress.
Many thanks from teamFUZE
4main index
Immediate mode Commands455667778899
10101111
CLEARCLSCONTCONTINUEDIREDITEXITL ISTL ISTGAMEPADSLOADNEWRUNSAVETROFFTRONVERSION
CLEARPurposeClear variable memory.
SyntaxCLEAR
DescriptionClears all variables and deletes all arrays. It also removesany active sprites from the screen. Stopped programs maynot be continued after a CLEAR command.
ExampleREM Immediate ModeVARIABLE=10PRINT VARIABLECLEARREM Unassigned variable error!PRINT VARIABLE
AssociatedNEW
5main index
CLSPurposeClear the video display screen.
SyntaxCLS
DescriptionClears the video display screen and places the cursor inthe top left corner. The background is set to the currentbackground (PAPER) colour.
ExamplePAPER=WHITEINK=BLACKCLSPRINT "Hello World"END
AssociatedCLS2, INK, PAPER, UPDATE
Immediate mode Commands
CONTPurposeContinue running a program that has been stopped.
SyntaxCONT
DescriptionContinues program execution after a STOP instruction.Variables are not cleared.
ExampleREM Immediate modeCONT
AssociatedSTOP
6main index
CONTINUEPurposeContinue a loop.
SyntaxCONTINUE
DescriptionWill cause the loop to re-start at the line containing theLOOP instruction, continuing a FOR instruction and re-evaluating any WHILE or UNTIL instructions.
ExampleREM Prints 1 to 10 but skips over 5FOR I=1 to 10 LOOP
IF (I=5) THEN CONTINUEPRINT I
REPEATEND
AssociatedBREAK, LOOP, LOOP REPEAT, FOR REPEAT, REPEATUNTIL, UNTIL REPEAT, WHILE REPEAT
Immediate mode Commands
DIRPurposeList FUZE BASIC program files in the current or specifieddirectory.
SyntaxDIR [directory]
DescriptionLists the program files in your current working directory orthe optional specified directory. These will have the .fuzefile extension.
ExampleREM Immediate ModeDIR
AssociatedLOAD, SAVE
7main index
EDITPurposeEdit the program in memory.
SyntaxEDIT
DescriptionEdits the program in memory using a full screen editor.
ExampleREM Immediate modeEDIT
EXITPurposeExit FUZE BASIC and return to the environment.
SyntaxEXIT
DescriptionExit FUZE BASIC and return to the environment you started itin.
ExampleREM Immediate modeEXIT
Immediate mode Commands
LISTPurposeList the program stored in memory to the screen.
SyntaxLIST
DescriptionThis lists the program stored in memory to the screen.You can pause the listing with the space-bar andterminate it with the escape key.
ExampleREM Immediate ModeLIST
8main index
LISTGAMEPADSPurposeTo display any connected joysticks and gamepads.
SyntaxLISTGAMEPADS
DescriptionThis lists, by name, any attached joystick devices thatare currently connected via USB or wireless USB, ifsupported by the OS.
ExampleREM Immediate ModeLISTGAMEPADS
LOADPurposeLoad a program into memory.
SyntaxLOAD filename$
DescriptionLoads in a program from the local non-volatile storage. Aswith SAVE, you need to supply the filename without anyquotes. Do not include the .fuze file extension. Note, ifyour filename has spaces then you must enter it withinquoatation marks. LOAD "my game" for example.
ExampleREM Immediate ModeLOAD demos/ballRUN
AssociatedSAVE
Immediate mode Commands
9main index
NEWPurposeStart a new program
SyntaxNEW
DescriptionDeletes the program in memory. There is no verificationand once it’s gone, it’s gone. Remember to save first!
ExampleREM Immediate ModeNEWREM List will now be emptyLIST
AssociatedCLEAR
RUNPurposeRuns the program in memory.
SyntaxRUN
DescriptionRuns the program in memory. Note that using RUN willclear all variables.
ExampleREM Immediate ModeRUN
Immediate mode Commands
10main index
SAVEPurposeSaves your program to the local non-volatile storage.
SyntaxSAVE filename$
DescriptionSaves your program to the local non-volatile storage. Thefilename$ is the name of the file you wish to save andmay not contain spaces. If you have already saved a file,then you can subsequently execute SAVE without thefilename and it will overwrite the last file saved. (This isreset when you load a new program or use the NEWcommand)
ExampleREM Immediate ModeSAVE testprog
AssociatedLOAD
Immediate mode Commands
TROFFPurposeDisables TRON
SyntaxTROFF
DescriptionIf TRON is enabled then TROFF switches it off.
ExampleREM Immediate ModeTROFF
AssociatedTRON
11main index
TRONPurposeEnables TRON mode for debugging.
SyntaxTRON
DescriptionSwitching TRON on has a very dramatic effect. Running yourprogram when TRON is enabled displays a section of code onscreen to show exactly which line is being executed.
You can adjust TRON settings with the following controls;
CTRL+ UP / DOWN to change speedCTRL+ LEFT to Pause (hold down)CTRL+ LEFT + RIGHT to stepCTRL+ RIGHT toggle transparentCTRL+ SHIFT + UP toggle TRON displayCTRL+ PAGEUP increase number of lines displayedCTRL+ PAGEDOWN decrease number of lines displayedCTRL+ SHIFT + PAGEUP move TRON display upCTRL+ SHIFT + PAGEDOWN move TRON display down
ExampleREM Immediate ModeTROFF
AssociatedTRON
VERSIONPurposePrint the current version of FUZE BASIC.
SyntaxVERSION
DescriptionPrint the current version of FUZE BASIC.
ExampleREM Immediate ModeVERSION
Immediate mode Commands
12main index
Functions, Constants & ProceduresABSACOSADVANCESPRITEANALOGREADANALOGWRITEARMBODYARMELBOWARMGRIPPERARMLIGHTARMRESETARMSHOULDERARMWRISTASCASINATANBREAKCHR$CIRCLECLEARKEYBOARDCLOCKCLONESPRITECLOSECLSCLS2COLOURCOPYREGIONCOS
LOOPLOOP REPEATDATADATE$DEF FNDEF PROCDEFCHARDEGDIGITALREADDIGITALWRITEDIMDRCANALOGREADDRCCLOSEDRCDIGITALREADDRCDIGITALWRITEDRCOPENDRCPINMODEDRCPWMWRITEELLIPSEELSEENDENDIFENDPROCENVELOPEEOFEXPFADEOFF
FADEONFADINGFALSEFFWDFNFONTSIZEFOR REPEATFREEIMAGEFULLSCREENGETGET$GETIMAGEHGETIMAGEWGETMOUSEGETPIXELGETPIXELRGBGETSPRITEANGLEGETSPRITEHGETSPRITEWGETSPRITEXGETSPRITEYGHEIGHTGRABREGIONGWIDTHHIDESPRITEHLINEHTABHVTABIF THEN
INKINKEYINPUTINPUT#INTLEFTLEFT$LENLINELINETOLOADIMAGELOADMUSICLOADSAMPLELOADSPRITELOCALLOGMAXMID$MINMOUSEOFFMOUSEONMOUSEXMOUSEYMOVEMOVETONEWSPRITENUMFORMATOPENORIGIN
141415151616171718181919202021212222232324242525262728
282929303131323233333435353636373738383939404041424243
4344444545464647474848494950505151525253535454555556565757
5858595960606161626263636464656566666767686869697070717272
13main index
SENSEHUMIDITYSENSELINESENSEPLOTSENSEPRESSURESENSERECTSENSERGBCOLOURSENSESCROLLSENSETEMPERATURESENSEVFLIPSETCHANVOLSETMODESETMOUSESETMUSICVOLSETSPRITEALPHASETSPRITEANGLESETSPRITEFLIPSETSPRITEORIGINSETSPRITESIZESETSPRITETRANSSGETSGET$SGNSHOWKEYSSINSOFTPWMWRITESOPENSOUNDSPACE$SPRITECOLLIDESPRITECOLLIDEPP
REWINDRGBCOLOURRIGHTRIGHT$ROTATEIMAGERNDSAVEREGIONSAVESCREENSCALEIMAGESCANKEYBOARDSCLOSESCROLLDOWNSCROLLLEFTSCROLLRIGHTSCROLLUPSEEDSEEKSENSEACCELXSENSEACCELYSENSEACCELZSENSECLSSENSECOMPASSXSENSECOMPASSYSENSECOMPASSZSENSEGETRGBSENSEGYROXSENSEGYROYSENSEGYROZSENSEHEIGHTSENSEHFLIP
PAPERPAPEROFFPAPERONPAUSECHANPAUSEMUSICPENDOWNPENUPPIPINMODEPLAYMUSICPLAYSAMPLEPLOTPLOTIMAGEPLOTSPRITEPOLYENDPOLYPLOTPOLYSTARTPLOTTEXTPRINTPRINT#PRINTATPROCPWMWRITERADREADRECTREPEAT UNTILRESTORERESUMECHANRESUMEMUSIC
SPRITEOUTSPUTSPUT$SQRTSREADYSTOPSTOPCHANSTOPMUSICSTR$SWAPSWITCHTANTANGLETHEIGHTTIMETIME$TONETRIANGLETRUETWIDTHUPDATEMODEUNTIL REPEATUPDATEVALVLINEVTABWAITWHILE REPEAT
737374747575767677777878797980808181828283838484858586868787
888889899090919292939394949494959596969696979797979898989899
99100100101101102102103103104104105105106106107107108108109110110111111112112113113114115
116116117117118118119119120120121122122123123124124125125126126127127128128129129130
14main index
ABSPurposeReturn the absolute value of the argument.
Syntaxpositivenumber=ABS(number)
DescriptionReturns the absolute value of the supplied argumentnumber i.e. If the argument is negative, make it positive.
ExamplePRINT FN ElapsedYears(1966,2013)PRINT FN ElapsedYears(2013,1966)ENDREM Return Number of years elapsedREM Between two datesDEF FN ElapsedYears(Year1, Year2)=ABS(Year1-Year2)
AssociatedSGN
ACOSPurposeReturns the arc cosine of the supplied argument.
Syntaxangle=ACOS(cosine)
DescriptionThis is the inverse of the COS function returning the anglefor a given cosine.
ExamplePRINT "Angle with cosine = 0.5: "DEGREM 60 DegreesPRINT "In Degrees: ";ACOS(0.5)RADREM PI/3 RadiansPRINT "In Radians: "; ACOS(0.5)CLOCKPRINT "In Minutes: "; ACOS(0.5)END
AssociatedATAN, COS, SIN, TAN
Functions, Constants & Procedures
15main index
ADVANCESPRITEPurposeAdvances a sprite a specified amount
SyntaxADVANCESPRITE( sprite, distance )
DescriptionMoves a sprite forward by the specified distance. Thedirection is set by the SETSPRITEANGLE function. This isvery useful when used with rotating sprites.
Examplepic = NEWSPRITE( 1 )LOADSPRITE("logo.bmp", pic,0)PLOTSPRITE( pic, gWidth / 2, gHeight / 2, 0 )FOR angle = 0 TO 360 LOOPSETSPRITEANGLE( pic, angle )ADVANCESPRITE( pic, 5 )UPDATEREPEATEND
AssociatedPLOTSPRITE, SETSPRITEANGLE
ANALOGREADPurposeReturns the value from an analog input.
SyntaxANALOGREAD(0)
Description
Returns the a value of between 0 and 255 (0V & 3.3V) fromthe specified analog pin. There are four inputs, 0 to 3.
ExampleREM Attach an LDR to 3.3V and analog pin 0PRINT analogRead(0)REM cover the LDR and run again.END
AssociatedANALOGREAD, ANALOGWRITE
Functions, Constants & Procedures
16main index
ARMBODYPurposeMove the robot arm body.
SyntaxARMBODY(direction)
DescriptionActivates the motor in the base of the robot armaccording to the direction argument as follows:1 Move clockwise0 Stop-1 Move anti-clockwise.
ExampleREM Move the body for 2 seconds clockwiseARMBODY(1)WAIT(2)ARMBODY(0)END
AssociatedARMELBOW, ARMGRIPPER, ARMLIGHT, ARMRESET,ARMSHOULDER, ARMWRIST
ANALOGWRITEPurposeSends a value to the analog output.
SyntaxANALOGWRITE(0,value)
Description
Sends a voltage between 0V and 3.3V (as a value of 0 to255) to analog pin 0. There is one analog output.
ExampleREM Attach an LED to analog OUT pin 0 (thelonger leg) and the shorter leg to GNDLOOPFOR volt= 0 TO 255 LOOPanalogWrite(0,volt)REPEATREPEATEND
AssociatedANALOGREAD, ANALOGWRITE
Functions, Constants & Procedures
17main index
ARMELBOWPurposeMove the robot arm elbow.
SyntaxARMELBOW(direction)
DescriptionActivates the motor in the elbow of the robot armaccording to the direction argument as follows:1 Move clockwise0 Stop-1 Move anti-clockwise.
ExampleREM Move the elbow for 1s anti-clockwiseARMELBOW(-1)WAIT(1)ARMELBOW(0)END
AssociatedARMBODY, ARMGRIPPER, ARMLIGHT, ARMRESET,ARMSHOULDER, ARMWRIST
ARMGRIPPERPurposeOpen or close the robot arm gripper.
SyntaxARMGRIPPER(direction)
DescriptionActivates the motor in the gripper of the robot armaccording to the direction argument as follows:1 Open gripper0 Stop-1 Close gripper
ExampleREM Open the gripper for 1 secondsARMGRIPPER(1)WAIT(1)ARMGRIPPER(0)END
AssociatedARMBODY, ARMELBOW, ARMLIGHT, ARMRESET,ARMSHOULDER, ARMWRIST
Functions, Constants & Procedures
18main index
ARMLIGHTPurposeSwitch the robot's LED on or off.
SyntaxARMLIGHT(switch)
DescriptionIf the switch argument is 1 then the LED is illuminated andif it is 0 it is switched off.
ExampleREM Flash the LED with 1 second intervalLOOP
ARMLIGHT(1)WAIT(1)ARMLIGHT(0)WAIT(1)
REPEAT
AssociatedARMBODY, ARMELBOW, ARMGRIPPER, ARMRESET,ARMSHOULDER, ARMWRIST
ARMRESETPurposeReset the robot arm.
SyntaxARMRESET
DescriptionStops any moving motors on the robot arm and switchesoff the LED.
ExampleARMLIGHT(1)ARMELBOW(1)WAIT(2)ARMRESETEND
AssociatedARMBODY, ARMELBOW, ARMGRIPPER, ARMLIGHT,ARMSHOULDER, ARMWRIST
Functions, Constants & Procedures
19main index
ARMSHOULDERPurposeMove the robot arm shoulder.
SyntaxARMSHOULDER(direction)
DescriptionActivates the motor in the shoulder of the robot armaccording to the direction argument as follows:1 Move clockwise0 Stop-1 Move anti-clockwise.
ExampleREM Move shoulder for 1s clockwise & backARMSHOULDER(1)WAIT(1)ARMSHOULDER(-1)WAIT(1)ARMSHOULDER(0)END
AssociatedARMBODY, ARMELBOW, ARMGRIPPER, ARMLIGHT,ARMRESET, ARMWRIST
ARMWRISTPurposeMove the robot arm wrist.
SyntaxARMWRIST(direction)
DescriptionActivates the motor in the wrist of the robot armaccording to the direction argument as follows:1 Move clockwise0 Stop-1 Move anti-clockwise.
ExampleREM Move wrist for 1s clockwise & backARMWRIST(1)WAIT(1)ARMWRIST(-1)WAIT(1)ARMWRIST(0)END
AssociatedARMBODY, ARMELBOW, ARMGRIPPER, ARMLIGHT,ARMRESET, ARMSHOULDER
Functions, Constants & Procedures
20main index
ASCPurposeReturn the ASCII code for a string character.
Syntaxasciicode=ASC(string$)
DescriptionReturns the ASCII value represented by the first characterof string$ e.g. "A" would return 65. It is the opposite ofthe CHR$ function.
Examplecode=ASC("A")PRINT "ASCII value of letter A is: "; codePRINT "ASCII char of code 65: "; CHR$(code)END
AssociatedCHR$
ASINPurposeReturns the arc sine of the supplied argument.
Syntaxangle = ASIN(sine)
DescriptionThis is the inverse of the SIN function returning the anglefor a given sine.
ExamplePRINT "Angle with sine = 0.5: "DEGREM 30 DegreesPRINT "In Degrees: ";ASIN(0.5)RADREM PI/6 RadiansPRINT "In Radians: ";ASIN(0.5)CLOCKPRINT "In Minutes: ";ASIN(0.5)END
AssociatedACOS, ATAN, COS, SIN, TAN
Functions, Constants & Procedures
21main index
ATANPurposeReturns the arc tangent of the supplied argument.
Syntaxangle=ATN(tangent)
DescriptionThis is the inverse of the TAN function returning the anglefor a given tangent.
ExamplePRINT "Angle with tangent equal to 1: "DEGREM 45 DegreesPRINT "In Degrees: ";ATAN(1)RADREM PI/4 RadiansPRINT "In Radians: ";ATAN(1)CLOCKPRINT "In Minutes: ";ATAN(1)END
AssociatedACOS, ASIN, COS, SIN, TAN
BREAKPurposeProvide an early exit from a loop.
SyntaxBREAK
DescriptionTerminates a loop before the terminating condition ismet.
ExampleREM Loop until the space bar is pressedPRINT "Press the space bar to continue"LOOP
IF INKEY=32 THEN BREAKREPEATEND
AssociatedCONTINUE, LOOP, LOOP REPEAT, FOR REPEAT, REPEATUNTIL, UNTIL REPEAT, WHILE REPEAT
Functions, Constants & Procedures
22main index
CHR$PurposeReturns the string character for the specified ASCII code.
Syntaxcharacter$=CHR$(asciicode)
DescriptionReturns a one-character string consisting of the charactercorresponding to the ASCII code indicated by the asciicodeargument. This is the opposite of the ASC function.
ExamplePRINT "The following print the letter A"PRINT CHR$(65)PRINT CHR$(ASC("A"))PRINT "The following print the number 3"PRINT CHR$(51)PRINT CHR$(ASC("0") + 3)END
AssociatedASC
CIRCLEPurposeDraw a circle on the screen.
SyntaxCIRCLE(centrex,centrey,radius,fill)
DescriptionDraws a circle at position (centrex,centrey) with thespecified radius in the current foreground COLOUR. Thefinal parameter fill is either TRUE or FALSE, and specifiesfilled (TRUE) or outline (FALSE).
ExampleCLSPRINT "Draw a filled yellow circle ";PRINT "In the centre of the screen"COLOUR=yellowCIRCLE(GWIDTH/2,GHEIGHT/2,100,TRUE)UPDATEEND
AssociatedELLIPSE, RECT, TRIANGLE
Functions, Constants & Procedures
23main index
CLEARKEYBOARDPurposeClear all pending keyboard input.
SyntaxCLEARKEYBOARD
DescriptionClears the keyboard input buffer.
ExamplePRINT "Press space to continue"WHILE NOT SCANKEYBOARD(scanSpace) LOOPREPEATCLEARKEYBOARDEND
AssociatedSCANKEYBOARD
CLOCKPurposeSet angle units to minutes.
SyntaxCLOCK
DescriptionSwitches the internal angle system to clock mode. Thereare 60 minutes in a full circle.
ExamplePRINT "ATAN(1) = "DEGPRINT ATAN(1); " Degrees"CLOCKPRINT ATAN(1); " Minutes"RADPRINT ATAN(1); " Radians"END
AssociatedDEG, RAD
Functions, Constants & Procedures
24main index
CLOSEPurposeClose a file after use.
SyntaxCLOSE(handle)
DescriptionThe CLOSE instruction closes the file specified by handleafter use and makes sure all data is securely written to thestorage medium.
Examplehandle = OPEN("testfile.txt")PRINT# handle, "Colin"CLOSE(handle)handle = OPEN("testfile.txt")INPUT# handle, Name$CLOSE(handle)PRINT "Name: " + Name$END
AssociatedEOF, FFWD, INPUT#, OPEN, PRINT#, REWIND, SEEK
Functions, Constants & Procedures
CLONESPRITEPurposeCreate a new sprite from an existing one.
SyntaxCLONESPRITE ( sprite handle )
DescriptionCopies a sprite and its settings from an existing one(sprite handle) into a new one.
Example
sprite = newSprite (1)loadSprite (“ballBlue.png”, sprite, 0)sprite2 = cloneSprite (sprite)LOOP PlotSprite (sprite, 100, 100, 0) PlotSprite (sprite2, 200, 200, 0)REPEAT
AssociatednewSprite, loadSprite
25main index
CLS2PurposeClear screen without an update.
SyntaxCLS2
DescriptionIdeally suited to games and graphical programming. CLS2clears the background or buffer screen and does not issue anupdate command. This means you can wipe the screen buffer,redraw on it and then issue an update. This ensures flicker freeupdates. It is also much faster than CLS.
Exampley = GHEIGHT / 2radius = GWIDTH / 10FOR x = 0 TO GWIDTH STEP radius LOOPCLS
COLOUR = PINKCIRCLE (x, y, radius, 1)UPDATE
REPEATFOR x = GWIDTH TO 0 STEP -10 LOOP
CLS2COLOUR = YELLOWCIRCLE (x, y, radius, 1)UPDATE
REPEAT
AssociatedCLS, UPDATE
CLSPurposeClear screen.
SyntaxCLS
DescriptionCompletely clear the screen of text and graphics. Note, thisdoes not clear sprites from the screen.
ExamplePRINT “Hello World”WAIT (1)CLSEND
AssociatedCLS, UPDATE
Functions, Constants & Procedures
26main index
COLOURPurposeSet/Read the current graphics plot colour.
SyntaxCOLOUR=setcolour
DescriptionSet/Read the current graphics plot colour as follows:
ExampleCLSFOR c=0 TO 29 LOOP
COLOUR=cCIRCLE(50,GHEIGHT-c*40-50,20,TRUE)COLOUR=WHITECIRCLE(50,GHEIGHT-c*40-50,20,FALSE)READ NameOfColour$HVTAB(5,c*2+2)PRINT NameOfColour$;" ";c
REPEATUPDATEDATA "Black", "DarkGrey", "Grey", "Silver"DATA "LightGrey", "White", "Maroon", "Red"DATA "Purple", "Raspberry", "Pink", "LightPink"DATA "DarkGreen", "Green", "BrightGreen", "Olive"DATA "Lime", "LightGreen", "Navy", "Blue", "Teal"DATA "Cyan", "Aqua", "LightBlue", "Brown"DATA "LightBrown", "Orange", "Gold", "Yellow"DATA "LightYellow"END
AssociatedINK, PAPER, RGBCOLOUR
0 Black1 DarkGrey2 Grey3 Silver4 LightGrey5 White6 Maroon7 Red8 Purple9 Raspberry
10 Pink11 LightPink12 DarkGreen13 Green14 BrightGreen15 Olive16 Lime17 LightGreen18 Navy19 Blue
20 Teal21 Cyan22 Aqua23 LightBlue24 Brown25 LightBrown26 Orange27 Gold28 Yellow29 LightYellow
Functions, Constants & Procedures
27main index
COPYREGIONPurposeCopy a region of the screen from one location to another.
SyntaxCOPYREGION(oldx,oldy,width,height,newX,newY)
DescriptionThis enables you to duplicate the contents of a section ofthe screen from one place to another. This could be usedfor example to create a background for a game bydrawing an image and then duplicating it. The region to becopied is specified by the rectangle at coordinates(oldx,oldy) width pixels wide and height pixelshigh. The region is copied to coordinates (newx,newy)
ExampleREM Draws a Brick WallCOLOUR=REDRECT(0,0,50,50,TRUE)COLOUR=WHITELINE(0,50,50,50)LINE(0,25,50,25)LINE(0,25,0,50)LINE(50,25,50,50)LINE(25,0,25,25)LINE(0,0,50,0)FOR X=0 TO GWIDTH STEP 50 LOOP
FOR Y=0 TO GHEIGHT STEP 50 LOOPCOPYREGION(0,0,50,50,X,Y)
REPEATREPEATUPDATEEND
AssociatedGRABREGION
Functions, Constants & Procedures
28main index
COSPurposeReturns the cosine of the given angle.
Syntaxcosine=COS(angle)
DescriptionReturns the cosine of the argument angle. This is the ratioof the side of a right angled triangle, that is adjacent tothe angle, to the hypotenuse (the longest side).
ExampleCLSPRINT "Draw ellipse in screen centre"DEGFOR Angle=0 TO 360 LOOP
Xpos=100*COS(Angle)+GWIDTH / 2Ypos=50*SIN(Angle)+GHEIGHT / 2PLOT(Xpos, Ypos)
REPEATEND
AssociatedACOS, ASIN, ATAN, SIN, TAN
LOOPPurposeDefines the start of a block of code to be repeated.
SyntaxLOOP
DescriptionMarks the start of a block of repeating code (called aloop). The number of times that the loop is executeddepends on the command used before LOOP or at theend of the loop.
ExampleREM See Associated commands below.
AssociatedBREAK, CONTINUE, LOOP REPEAT, FOR REPEAT, REPEATUNTIL, UNTIL REPEAT, WHILE REPEAT
Functions, Constants & Procedures
29main index
LOOP REPEATPurposeCreate an infinite loop.
SyntaxLOOP
{statements}REPEAT
DescriptionExecute the statements again and again forever.The BREAK command can be used to terminate the loopor control can be explicitly transferred to somewhereoutside of the loop by commands like GOTO (notrecommended).Pressing the Esc key will also interrupt the loop (andprogram).
ExampleREM Loop until the space bar is pressedPRINT "Press the space bar to continue"LOOP
IF INKEY = 32 THEN BREAKREPEATEND
AssociatedBREAK, CONTINUE, LOOP, FOR REPEAT, REPEAT UNTIL,UNTIL REPEAT, WHILE REPEAT
DATAPurposeStore constant data.
SyntaxDATA constant{,constant}
DescriptionStores numerical and string constants for later retrievalusing the READ command.
ExampleREM Load the name of the days of theREM week into a string arrayDATA "Monday", "Tuesday", "Wednesday"DATA "Thursday", "Friday", "Saturday"DATA "Sunday"DIM DaysOfWeek$(7)FOR DayNo=1 TO 7 LOOP
READ DaysOfWeek$(DayNo)REPEATFOR DayNo=1 TO 7 LOOP
PRINT "Day of the week number ";DayNo;PRINT " is ";DaysOfWeek$(DayNo)
REPEATEND
AssociatedREAD, RESTORE
Functions, Constants & Procedures
30main index
DATE$PurposeReturn the current date.
Syntaxtodaysdate$ = DATE$
DescriptionThis returns a string with the current date in the format:YYYY-MM-DD. For example: 2015-03-24.
ExamplePRINT "Today is ";FN FormatDate(DATE$)END
DEF FN FormatDate()DayNo=VAL(RIGHT$(DATE$, 2))MonthNo=VAL(MID$(DATE$, 5, 2))Year$=LEFT$(DATE$,4)SWITCH (DayNo MOD 10)
CASE 1DaySuffix$ = "st"
ENDCASECASE 2DaySuffix$ = "nd"
ENDCASECASE 3DaySuffix$ = "rd"
ENDCASEDEFAULTDaySuffix$ = "th"
ENDCASEENDSWITCHFOR I=1 TO MonthNo LOOP
READ MonthName$REPEATResult$=STR$(DayNo)+DaySuffix$+" "
=Result$+MonthName$+" "+Year$DATA "January","February","March","April"DATA "May","June","July","August"DATA "September","October","November"DATA "December"
AssociatedTIME$
Functions, Constants & Procedures
31main index
DEF FNPurposeCreate a user defined function.
SyntaxDEF FN name({parameter}{,parameter})
{commands}=value
DescriptionUser defined functions are similar to user definedprocedures except that they can return a value. This canbe either a number or a character string.
ExampleREM Function test - print squaresFOR I=1 TO 10 LOOP
x=FN square(I)PRINT I; " squared is "; xREPEATENDDEF FN square(num)
LOCAL resultresult=num*num
=result
AssociatedFN, LOCAL
DEF PROCPurposeCreate a user defined procedure.
SyntaxDEF PROC name({parameter}{,parameter})
{commands}ENDPROC
DescriptionAllows you to create your own routines that can be called bytheir label. Once you have written a procedure to do aparticular task you can copy it into other programs that requireit. Procedures are usually defined after the END of theprogram.
ExampleCLSPROC Hexagon(200,200,100,Red)UPDATEENDDEF PROC Hexagon(x,y,l,c)
PENUPMOVETO(x-l*COS(30),y+l/2)COLOUR = cPENDOWNFOR I=1 to 6 LOOPRIGHT(60)MOVE(l)
REPEATENDPROC
AssociatedLOCAL, PROC
Functions, Constants & Procedures
32main index
DEFCHARPurposeDefine a new font character.
SyntaxDEFCHAR(char,line1 … line10)
DescriptionCreate a user defined font character. The char parameteris the position of the character within the font (0-255) e.g.65 is the capital letter A in ASCII. The character consists of10 lines with 8 pixels in each line. These are set by thecorresponding bits in each of the line parameters. So forexample decimal 170 (binary 10101010) would setalternate pixels on the corresponding line of the character.
ExampleREM Define Chessboard CharacterFONTSIZE(10)DEFCHAR(2,0,85,170,85,170,85,170,85,170,0)PRINT CHR$(2)END
AssociatedCHR$
DEGPurposeSet angle units to degrees.
SyntaxDEG
DescriptionSwitches the internal angle system to degree mode. Thereare 360 degrees in a full circle.
ExampleREM Draw an ellipse in the screen centreCLSDEGFOR Angle = 0 TO 360 LOOP
Xpos=100*COS(Angle)+GWIDTH / 2Ypos=50*SIN(Angle)+GHEIGHT / 2PLOT(Xpos, Ypos)
REPEATEND
AssociatedCLOCK, RAD
Functions, Constants & Procedures
33main index
DIGITALREADPurposeRead the state of a digital pin on the Raspberry Pi.
Syntaxpinvalue=DIGITALREAD(pinno)
DescriptionReads the state of a digital pin on the Raspberry Pi. Youmay need to set the pin mode beforehand to make sureit’s configured as an input device. It will return TRUE orFALSE to indicate an input being high or low respectively.
ExampleREM Set pin 12 to inputPINMODE(12,0)REM Wait for button to be pushedUNTIL DIGITALREAD(12) LOOPREPEATPRINT "Button Pushed"END
AssociatedDIGITALWRITE, PINMODE, PWMWRITE
DIGITALWRITEPurposeSet the state of a digital pin on the Raspberry Pi.
SyntaxDIGITALWRITE(pinno,pinvalue)
DescriptionThis procedure sets a digital pin to the supplied value - 0for off or 1 for on. As with DigitalRead, you may need toset the pin mode (to output) beforehand.
ExampleREM Flash LED attached to pin2 of GPIOREM Set pin 2 to output modePINMODE(2,1)LOOP
REM Set output High (on)DIGITALWRITE(2,1)WAIT(1)REM Set output Low (off)DIGITALWRITE(2,0)WAIT(1)
REPEATEND
AssociatedDIGITALREAD, PINMODE, PWMWRITE
Functions, Constants & Procedures
34main index
DIMPurposeDimension an array of variables.
SyntaxDIM variable(dimension{,dimension})
DescriptionCreates an indexed variable with one or more dimensions.The variable can be either a numeric or character stringtype (they cannot hold mixed values). The index is anumber from 0 to the size of the dimension.Associative arrays (sometimes called maps) are anotherway to refer to the individual elements of an array. In theexample below we use a number, however strings arealso allowed. They can be multi-dimensional and you canfreely mix numbers and strings for the array indices.
ExampleREM Initialise the squares of a chessREM board to black or whiteDIM ChessBoard(8,8)Count=0FOR Row=1 TO 8 LOOP
FOR Col=1 TO 8 LOOPCount=Count+1IF Count MOD 2=1 THEN
ChessBoard(Row,Col) = BlackELSE
ChessBoard(Row,Col) = WhiteENDIF
REPEATREPEATPRINT ChessBoard(1,4)END
Functions, Constants & Procedures
35main index
DRCANALOGREADPurposeRead an analog channel on a DRC device.
Syntaxvoltage=DRCANALOGREAD(handle,pin)
DescriptionThis function reads an analog channel on a DRCcompatible device specified by handle and returns theresult. The value returned will depend on the hardwareyou’re connected to - for example the Arduino will returna number from 0 to 1023 representing an input voltagebetween 0 and 5 volts. Other devices may have differentranges.
Examplearduino=DRCOPEN("/dev/ttyUSB0")REM Get voltage on pin 4voltage=DRCANALOGREAD(arduino, 4)/1023*5PRINT "Voltage= "; voltageDRCCLOSE(arduino)END
AssociatedDRCCLOSE, DRCDIGITALREAD, DRCDIGITALWRITE,DRCOPEN, DRCPINMODE, DRCPWMWRITE
DRCCLOSEPurposeClose a connection to a DRC compatible device.
SyntaxDRCCLOSE(handle)
DescriptionThis closes a connection to a DRC device and frees up anyresources used by it. It’s not strictly necessary to do thiswhen you end your program, but it is considered goodpractice.
Examplearduino = DRCOPEN("/dev/ttyUSB0")REM Set pin 12 to inputDRCPINMODE(arduino, 12, 0)LOOPREPEAT UNTIL DRCDIGITALREAD(arduino, 12)PRINT "Button Pushed"DRCCLOSE(arduino)END
AssociatedDRCANALOGREAD, DRCDIGITALREAD, DRCDIGITALWRITE,DRCOPEN, DRCPINMODE, DRCPWMWRITE
Functions, Constants & Procedures
36main index
DRCDIGITALREADPurposeRead the state of a digital pin on a remote DRC device.
Syntaxstate=DRCDIGITALREAD(handle,pin)
DescriptionThis function allows you to read the state of a digital pinon a DRC device specified by handle. You may need to setthe pin mode beforehand to make sure it’s configured asan input device. It will return TRUE or FALSE to indicate aninput being high or low respectively.
Examplearduino = DRCOPEN("/dev/ttyUSB0")REM Set pin 12 to inputDRCPINMODE(arduino, 12, 0)LOOPREPEAT UNTIL DRCDIGITALREAD(arduino, 12)PRINT "Button Pushed"DRCCLOSE(arduino)END
AssociatedDRCANALOGREAD, DRCCLOSE, DRCDIGITALWRITE,DRCOPEN, DRCPINMODE, DRCPWMWRITE
DRCDIGITALWRITEPurposeSet a digital pin on a remote DRC device to the suppliedvalue.
SyntaxDRCDIGITALWRITE(handle,pin,value)
DescriptionThis procedure sets a digital pin on a DRC device specifiedby handle to the supplied value - 0 for off or 1 for on. Aswith DrcDigitalRead, you may need to set the pin modebeforehand.
Examplearduino=DRCOPEN("/dev/ttyUSB0")REM Set pin 2 to output modeDRCPINMODE(arduino, 2, 1)REM Set Output High (on)DRCDIGITALWRITE(arduino, 2, 1)REM Pause for 1 secondWAIT(1)REM Set output Low (off)DRCDIGITALWRITE(arduino, 2, 0)DRCCLOSE(arduino)END
AssociatedDRCANALOGREAD, DRCCLOSE, DRCDIGITALREAD,DRCOPEN, DRCPINMODE, DRCPWMWRITE
Functions, Constants & Procedures
37main index
DRCOPENPurposeOpen a connection to a DRC compatible device.
Syntaxhandle=DRCOPEN(drcdevice)
DescriptionThis opens a connection to a DRC compatible device andmakes it available for our use. It takes the name of thedevice as an argument and returns a number (the handle)of the device. We can use this handle to reference thedevice and allow us to open several devices at once. Someimplementations may have IO devices with fixed names.
Examplearduino = DRCOPEN("/dev/ttyUSB0")REM Set pin 12 to inputDRCPINMODE(arduino, 12, 0)LOOPREPEAT UNTIL DRCDIGITALREAD(arduino, 12)PRINT "Button Pushed"DRCCLOSE(arduino)END
AssociatedDRCANALOGREAD, DRCCLOSE, DRCDIGITALREAD,DRCDIGITALWRITE, DRCPINMODE, DRCPWMWRITE
DRCPINMODEPurposeConfigure the mode of a pin on a remote DRC device.
SyntaxDRCPINMODE(handle,pin,mode)
DescriptionThis configures the mode of a pin on the DRC device specifiedby handle. It takes an argument which specifies the mode ofthe specified pin - input, output or PWM output. Other modesmay be available, depending on the device and its capabilities.Note that not all devices support all functions. The modes are:0 pinINPUT1 pinOUTPUT2 pinPWM
Examplearduino = DRCOPEN("/dev/ttyUSB0")REM Set pin 12 to inputDRCPINMODE(arduino, 12, 0)LOOPREPEAT UNTIL DRCDIGITALREAD(arduino, 12)PRINT "Button Pushed"DRCCLOSE(arduino)END
AssociatedDRCANALOGREAD, DRCCLOSE, DRCDIGITALREAD,DRCDIGITALWRITE, DRCOPEN, DRCPWMWRITE
Functions, Constants & Procedures
38main index
DRCPWMWRITEPurposeOutput a PWM waveform on the selected pin of a DRCdevice.
SyntaxDRCPWMWRITE(handle,pin,value)
DescriptionThis procedure outputs a PWM waveform on the specifiedpin of a DRC compatible device specified by handle. Thepin must be configured for PWM mode beforehand, anddepending on the device you are using, then not all pinson a device may support PWM mode. The value setshould be between 0 and 255.
Examplearduino=DRCOPEN("/dev/ttyUSB0")REM Set pin 11 to PWM output modeDRCPINMODE(arduino, 11, 2)DRCPWMWRITE(arduino, 11, 200)DRCCLOSE(arduino)END
AssociatedDRCANALOGREAD, DRCCLOSE, DRCDIGITALREAD,DRCDIGITALWRITE, DRCOPEN, DRCPINMODE
ELLIPSEPurposeDraw an ellipse on the screen.
SyntaxELLIPSE(xpos,ypos,xradius,yradius,fill)
DescriptionDraws an ellipse centred at position (xpos,ypos) with thespecified xradius and yradius in the current foregroundCOLOUR. The final parameter fill is either TRUE or FALSE,and specifies filled (TRUE) or outline (FALSE).
ExampleCLSREM Draw a filled red ellipse atREM location 200,200COLOUR=redELLIPSE(200,200,100,50,TRUE)UPDATEEND
AssociatedCIRCLE, RECT, TRIANGLE
Functions, Constants & Procedures
39main index
ELSEPurposeExecute statement(s) when a tested condition is False.
SyntaxIF condition THEN{statements}ELSE{statements}ENDIF
ExampleNumber = 13IF Number MOD 2 = 0 THEN
PRINT "Number is Even"ELSE
PRINT "Number is Odd"ENDIFEND
AssociatedENDIF, IF THEN
ENDPurposeEnd program execution.
SyntaxEND
DescriptionProgram execution is ended. Programs must terminatewith the END or STOP commands or an error will occur.
ExamplePRINT "Hello World"END
Functions, Constants & Procedures
40main index
ENDIFPurposeTerminate a multiline conditional statement.
SyntaxIF condition THEN{statements}ENDIF
DescriptionWe can extend the IF statement over multiple lines, ifrequired. The way you do this is by making sure there isnothing after the THEN statement and ending it all withthe ENDIF statement.
ExampleDayOfWeek = 5IF DayOfWeek < 6 THEN
PRINT "It is a Weekday"PRINT "Go to Work!"
ENDIFEND
AssociatedELSE, IF THEN
ENDPROCPurposeDefines the end of a PROCedure
SyntaxENDPROC
DescriptionEnd a PROCedure and return to the next command afterthe procedure was called.
ExampleCLSPROC helloENDDEF PROC helloPRINTAT (10,10); "Hello"ENDPROC
AssociatedPROC
Functions, Constants & Procedures
41main index
ENVELOPEPurposeEmulate the BBC BASIC sound envelope command.
SyntaxENVELOPE(N,T,PI1,P12,PI3,PN1,PN2,PN3,AA,AD,AS,AR,ALA,ALD)
DescriptionNOTE: This is an experimental function. It might notperform entirely as expected. It is also prone to crashingif incorrect values are used. Use with caution!
N 1 to 8 Envelope number.
T 0 to 127 Length of each step in hundredths of a second.Add 128 to cancel auto repeat of the pitch envelope.
PI1 −128 to 127 Pitch change per step in section 3PI2 −128 to 127 Change of pitch per step in section 2PI3 −128 to 127 Change of pitch per step in section 1PN1 0 to 255 Number of steps in section 1PN2 0 to 255 Number of steps in section 2PN3 0 to 255 Number of steps in section 3AA −127 to 127 Change of attack amplitude per stepAD −127 to 127 Change of decay amplitude per stepAS −127 to 0 Change of sustain amplitude per stepAR −127 to 0 Change of release amplitude per stepALA 0 to 126 Level at end of the attack phaseALD 0 to 126 Level at end of the decay phase
ExampleENVELOPE(1,2,-2,10,1,80,40,40,127,0,0,0,126,126)SOUND(1, 1, 53, 64)END
AssociatedSOUND
Functions, Constants & Procedures
42main index
EOFPurposeReturn true if the end of an input file has been reached.
Syntaxendoffile=EOF(handle)
DescriptionThe EOF function returns a TRUE or FALSE indication ofthe state of the file pointer when reading the file. It is anerror to try to read past the end of the file, so if you arereading a file with unknown data in it, then you mustcheck at well defined intervals (e.g. Before each INPUT#).
Examplehandle=OPEN("eoftest.txt")FOR r = 0 TO 10 LOOP
PRINT# handle, "Record "; rREPEATCLOSE (handle)handle = OPEN("eoftest.txt")WHILE NOT EOF (handle) LOOP
INPUT# handle, record$PRINT record$
REPEATCLOSE (handle)END
AssociatedCLOSE, FFWD, INPUT#, OPEN, PRINT#, REWIND, SEEK
EXPPurposeReturn the exponential value of the specified number.
Syntaxexponential=EXP(number)
DescriptionReturns the exponential value of the specified number.This is e to the power of number where e is theexponential constant (approximately 2.718281828). Theexponential function arises whenever a quantity grows ordecays at a rate proportional to its current value. This isthe opposite of the LOG function i.e. EXP(LOG(X)) = X
ExampleREM prints 2.718281828PRINT EXP(1)REM prints 22026.46579PRINT EXP(10)REM prints 10PRINT LOG(EXP(10))END
AssociatedLOG
Functions, Constants & Procedures
43main index
FADEOFFPurposeFade the display from light to dark
SyntaxFADEOFF
DescriptionFADEOFF initiates a fade from light to dark. The entirescreen display is affected.
ExamplePAPER=0INK=1CLSPRINT "LOADING..."FADEOFFWHILE FADING = true LOOP
UPDATEREPEATFADEONWHILE FADING = true LOOP
UPDATEREPEATEND
AssociatedFADEON, FADING
FADEONPurposeFade the display from dark to light
SyntaxFADEON
DescriptionFADEON initiates a fade from dark to light. The entirescreen display is affected.
ExamplePAPER=0INK=1CLSPRINT "LOADING..."FADEOFFWHILE FADING = true LOOOP
UPDATEREPEATFADEONWHILE FADING = true LOOP
UPDATEREPEATEND
AssociatedFADEOFF, FADING
Functions, Constants & Procedures
44main index
FADINGPurposeCheck if the display is fading
SyntaxFADING
DescriptionReturns either TRUE (if fade in progress) or FALSE (nofade active)
ExamplePAPER=0INK=1CLSPRINT "LOADING..."FADEOFFWHILE FADING = true LOOP
UPDATEREPEATFADEONWHILE FADING = true LOOP
UPDATEREPEATEND
AssociatedFADEON, FADING
FALSEPurposeRepresent the logical "false" value.
SyntaxFALSE
DescriptionRepresents a Boolean value that fails a conditional test. Itis equivalent to a numeric value of 0.
Examplecondition = FALSEIF condition = FALSE THEN
PRINT "Condition is FALSE"ENDIFIF NOT condition THEN
PRINT "Condition is FALSE"ENDIFPRINT "Condition= ";conditionEND
AssociatedTRUE
Functions, Constants & Procedures
45main index
FFWDPurposeMove the file pointer to the end of a file.
SyntaxFFWD(handle)
DescriptionMove the file pointer back to the end of the file specifiedby handle. If you want to append data to the end of anexisting file, then you need to call FFWD before writingthe data.
Examplehandle=OPEN("ffwdtest.txt")PRINT# handle, "First Line"CLOSE (handle)handle = OPEN ("ffwdtest.txt")FFWD (handle)PRINT# handle, "Appended line"CLOSE (handle)handle = OPEN("ffwdtest.txt")WHILE NOT EOF (handle) LOOP
INPUT# handle, record$PRINT record$
REPEATCLOSE (handle)END
AssociatedCLOSE, EOF, INPUT#, OPEN, PRINT#, REWIND, SEEK
FNPurposeCall a user defined function.
Syntaxresult=FN name({argument}{,argument})
DescriptionCalls the specified user defined function called name withthe specfied arguments. The returned result can then beused by the program. Once the function has beenexecuted control returns to the command following.
ExamplePRINT FN SphereVolume(10)ENDREM Function calculate volume of a sphereREM with radius rDEF FN SphereVolume(r)= (4/3)*PI*r*r*r
AssociatedDEF FN
Functions, Constants & Procedures
46main index
FONTSIZEPurposeScale the text font.
SyntaxFONTSIZE(scale)
DescriptionChange the size of the text font.
ExampleFOR S=1 TO 10 LOOP
FONTSIZE(S)PRINT "Hello World"
REPEATEND
AssociatedPRINTAT, LOADFONT
FOR LOOPPurposeLoop a specified number of times using a counter.
SyntaxFOR count=start TO end [STEP step] LOOP
statementsREPEAT
DescriptionThe count variable is initially set to start and changes by stepeach time around the loop until count is greater than or equalto end. The optional step, which defaults to 1 may be lessthan zero to count backwards. The end of the loop is indicatedusing the REPEAT.
ExampleREM year into a string arrayDATA "January", "February", "March"DATA "April", "May", "June"DATA "July", "August", "September"DATA "October", "November", "December"DIM Months$(12)FOR Month = 1 TO 12 LOOP
READ Months$(Month)REPEATPRINT "The seventh month is ";Months$(7)END
AssociatedBREAK, CONTINUE, LOOP, LOOP REPEAT, REPEAT UNTIL,UNTIL REPEAT, WHILE REPEAT
Functions, Constants & Procedures
47main index
FREEIMAGEPurposeRelease an image from memory
SyntaxFREEIMAGE(handle)
DescriptionFrees up the memory space taken up by a stored image
Examplehandle = LOADIMAGE( "sprite1.bmp" )PLOTIMAGE( handle, 0, 0 )UPDATEFREEIMAGE( handle )handle = LOADIMAGE( "sprite2.bmp" )PLOTIMAGE( handle, 100, 100 )UPDATEEND
AssociatedLOADIMAGE, PLOTIMAGE
FULLSCREENPurposeSets the display to full screen mode.
SyntaxFULLSCREEN={TRUE/FALSE}
DescriptionSwitches between full screen or windowed mode. Notethis does not set the resolution to the screen displaymode so unless you set the mode manually you will get aborder.
ExampleSETMODE(800,600)FULLSCREEN=0COLOUR=REDRECT(0,0,GWIDTH, GHEIGHT,0)UPDATEWAIT(2)FULLSCREEN=1WAIT(2)END
AssociatedSETMODE
Functions, Constants & Procedures
48main index
GETPurposeGet a single character code from the keyboard.
Syntaxasciicode=GET
DescriptionThis pauses program execution and waits for you to type asingle character on the keyboard, then returns the valueof the key pressed as a numeric variable (ASCII).
ExamplePRINT "Press a key"key = GETPRINT "ASCII Value of key = "; keyEND
AssociatedGET$, INKEY
GET$PurposeGet a single character from the keyboard.
Syntaxkey$ = GET$
DescriptionThis pauses program execution and waits for you to type asingle character on the keyboard, then returns the key asa string variable.
ExamplePRINT "Press a key"key$ = GET$PRINT "You Pressed Key: "; key$END
AssociatedGET, INKEY
Functions, Constants & Procedures
49main index
GETIMAGEHPurposeGet the pixel height of a loaded image.
SyntaxGETIMAGEH(handle)
DescriptionGets the height in pixels of a loaded image
ExampleREM Centre image on screenlogo=LOADIMAGE("/usr/share/fuze/logo.bmp")imageW=GETIMAGEW(logo)imageH=GETIMAGEH(logo)X=(GWIDTH-imageW)/2Y=(GHEIGHT-imageH)/2PLOTIMAGE(logo,X,Y)UPDATEEND
AssociatedGETIMAGEW, LOADIMAGE, PLOTIMAGE
GETIMAGEWPurposeGet the pixel width of a loaded image.
SyntaxGETIMAGEW(handle)
DescriptionGets the width in pixels of an image previously loadedusing LOADIMAGE (using the handle returned byLOADIMAGE).
ExampleREM Centre image on screenlogo=LOADIMAGE("/usr/share/fuze/logo.bmp")imageW=GETIMAGEW(logo)imageH=GETIMAGEH(logo)X=(GWIDTH-imageW)/2Y=(GHEIGHT-imageH)/2PLOTIMAGE(logo,X,Y)UPDATEEND
AssociatedGETIMAGEH, LOADIMAGE, PLOTIMAGE
Functions, Constants & Procedures
50main index
GETMOUSEPurposeRead values from an attached mouse
SyntaxGETMOUSE(xpos,ypos,buttons)
DescriptionThis reads values for the current state of the mouse. xpos is thehorizontal mouse position, ypos is the vertical position andbuttons is the state of the mouse buttons. You can testwhether the left button has been pressed by using the logical &operator to see if bit 0 of the buttons value is set: buttons & 1will be TRUE. Likewise if the right button is pressed then bit 3will be set and buttons & 4 will be TRUE.
ExampleCLSMOUSEONLOOP
GETMOUSE(x,y,b)LINETO(x,y)UPDATEREM LOOP colour if left button pressedIF b & 1 THEN
COLOUR = COLOUR MOD 16 + 1ENDIFREM Exit if right button pressed
REPEAT UNTIL b & 4MOUSEOFFENDAssociatedMOUSEOFF, MOUSEON, MOUSEX, MOUSEY, SETMOUSE
GETPIXELPurposeReturn the colour of the specified pixel.
Syntaxcolour = GETPIXEL(xpos, ypos)
DescriptionThis returns the internal colour code (0-15) of the pixel atthe specified point (xpos,ypos). This is for the "named"colours - e.g. Red, Green etc. It returns -1 if the pixelcolour is not a standard colour - in which case, you needto use GETPIXELRGB.
ExampleCLSCOLOUR = REDXpos = GWIDTH / 2Ypos = GHEIGHT / 2PLOT(Xpos, Ypos)PRINT GETPIXEL(Xpos, Ypos)END
AssociatedGETPIXELRGB
Functions, Constants & Procedures
51main index
GETPIXELRGBPurposeReturn the RGB colour of the specified pixel.
SyntaxRGBcolour = GETPIXELRGB(xpos, ypos)
DescriptionThis returns the RGB colour of the pixel at the specified point(xpos,ypos). This will return a 24-bit value.
ExampleCLSRGBCOLOUR(49, 101, 206)Xpos = GWIDTH / 2Ypos = GHEIGHT / 2CIRCLE(Xpos, Ypos, 50, TRUE)pixel = GETPIXELRGB(Xpos, Ypos)PRINT "RGB = "; pixelPRINT "Red = "; (pixel >> 16) & 0xFFPRINT "Green = "; (pixel >> 8) & 0xFFPRINT "Blue = "; (pixel >> 0) & 0xFFEND
AssociatedGETPIXEL
GETSPRITEANGLEPurposeReturns a sprite’s current angle
SyntaxGETSPRITEANGLE(spriteIndex)
DescriptionReturns the angle of the sprite with the specifiedspriteIndex.
Examplesprite = newSprite (1)loadSprite ("logo.png", sprite, 0)angle = 0plotSprite (sprite, gWidth / 2, gHeight / 2, 0)LOOPcls2 setSpriteAngle (sprite, angle) angle = angle + 1 if angle>359 THEN angle=0 printat(0,0);getspriteangle(sprite) UPDATEREPEAT
AssociatedGETSPRITEW, HIDESPRITE, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITETRANS, SPRITECOLLIDE,SPRITECOLLIDEPP
Functions, Constants & Procedures
52main index
GETSPRITEHPurposeGet the pixel height of a sprite.
SyntaxGETSPRITEH(spriteIndex)
DescriptionReturns the height in pixels of the sprite with the specifiedspriteIndex.
ExampleREM Centre sprite on the screenindex=NEWSPRITE(1)fuzelogo$="/usr/share/fuze/logo.bmp"LOADSPRITE(fuzelogo$,index,0)spriteW=GETSPRITEW(index)spriteH=GETSPRITEH(index)X=(GWIDTH-spriteW)/2Y=(GHEIGHT-spriteH)/2PLOTSPRITE(index,X,Y,0)UPDATEEND
AssociatedGETSPRITEW, HIDESPRITE, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITETRANS, SPRITECOLLIDE,SPRITECOLLIDEPP
GETSPRITEWPurposeGet the pixel width of a sprite.
SyntaxGETSPRITEW(spriteIndex)
DescriptionReturns the width in pixels of the sprite with the specifiedspriteIndex.
ExampleREM Centre sprite on the screenindex=NEWSPRITE(1)fuzelogo$="/usr/share/fuze/logo.bmp"LOADSPRITE(fuzelogo$,index,0)spriteW=GETSPRITEW(index)spriteH=GETSPRITEH(index)X=(GWIDTH-spriteW)/2Y=(GHEIGHT-spriteH)/2PLOTSPRITE(index,X,Y,0)UPDATEEND
AssociatedGETSPRITEH, HIDESPRITE, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITETRANS, SPRITECOLLIDE,SPRITECOLLIDEPP
Functions, Constants & Procedures
53main index
GETSPRITEXPurposeGet the X position of a sprite.
SyntaxGETSPRITEX(spriteIndex)
DescriptionReturns the X position in pixels of the sprite with thespecified spriteIndex.
ExampleupdateMode = 0sprite = newSprite (1)loadSprite ("logo.png", sprite, 0)LOOP
CLS2plotSprite (sprite, gWidth / 2, gHeight / 2, 0)PRINT getSpriteX (sprite)PRINT getSpriteY (sprite)UPDATE
REPEAT
AssociatedGETSPRITEW, HIDESPRITE, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITETRANS, SPRITECOLLIDE,SPRITECOLLIDEPP
GETSPRITEYPurposeGet the Y position of a sprite.
SyntaxGETSPRITEY(spriteIndex)
DescriptionReturns the Y position in pixels of the sprite with thespecified spriteIndex.
ExampleupdateMode = 0sprite = newSprite (1)loadSprite ("logo.png", sprite, 0)LOOP
CLS2plotSprite (sprite, gWidth / 2, gHeight / 2, 0)PRINT getSpriteX (sprite)PRINT getSpriteY (sprite)UPDATE
REPEAT
AssociatedGETSPRITEH, HIDESPRITE, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITETRANS, SPRITECOLLIDE,SPRITECOLLIDEPP
Functions, Constants & Procedures
54main index
GHEIGHTPurposeFind the current height of the display.
Syntaxheight=GHEIGHT
DescriptionThis can be read to find the current height of the displayin either high resolution or low resolution pixels.
ExampleREM Draw a circle in the centre of thescreenCLSCOLOUR = blueCIRCLE(GWIDTH/2,GHEIGHT/2,50,TRUE)UPDATEEND
AssociatedGWIDTH, ORIGIN, SETMODE
GRABREGIONPurposeGrab a region of the screen to a temporary buffer
Syntaxhandle = GRABREGION(x, y, width, height)
DescriptionGrab a region of the screen with x and y as the locationand with width and height in pixels. The region can berecalled by its handle and pasted using PLOTIMAGE.
ExampleFOR n = 0 TO 15 LOOPRECT(0,n*GHEIGHT/16, GWIDTH, GHEIGHT/16,1)REPEAThandle=GRABREGION(0,0,200,200)CLSPLOTIMAGE(handle, GWIDTH/2, GHEIGHT/2)UPDATEEND
AssociatedCOPYREGION, FREEIMAGE, LOADIMAGE, PLOTIMAGE,SAVEREGION, SAVESCREEN, SCROLLDOWN, SCROLLLEFT,SCROLLRIGHT, SCROLLUP
Functions, Constants & Procedures
55main index
HIDESPRITEPurposeRemove a sprite from the screen.
SyntaxHIDESPRITE(spriteindex)
DescriptionThis removes the sprite at the specified spriteindex from thescreen. You do not have to erase a sprite from the screen whenyou move it, just call PLOTSPRITE with the new coordinates.
ExampleCLSfuzelogo$="logo.bmp"s1=NEWSPRITE (1)s2=NEWSPRITE (1)LOADSPRITE (fuzelogo$,s1,0)LOADSPRITE (fuzelogo$,s2,0)PLOTSPRITE (s1,100,100,0)PLOTSPRITE (s2,200,200,0)UPDATEWAIT(2)REM Remove a sprite from the screenHIDESPRITE (s2)UPDATEEND
AssociatedGETSPRITEH, GETSPRITEW, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SPRITECOLLIDE, SPRITECOLLIDEPP, SPRITEOUT
GWIDTHPurposeReturns the current width of the display.
Syntaxwidth=GWIDTH
DescriptionThis can be read to find current width of the display ineither high resolution or low resolution pixels.
ExampleREM Draw a circle in the centre of thescreenCLSCOLOUR = blueCIRCLE(GWIDTH/2,GHEIGHT/2,50,TRUE)UPDATEEND
AssociatedGHEIGHT, ORIGIN, SETMODE
Functions, Constants & Procedures
56main index
HLINEPurposeDraw a horizontal line.
SyntaxHLINE(xpos1, xpos2, ypos)
DescriptionDraws a horizontal line on row y, from column xpos1to column xpos2.
ExampleCLSCOLOUR=redFOR ypos=0 TO GHEIGHT STEP 100 LOOP
HLINE(0,GWIDTH,ypos)REPEATUPDATEEND
AssociatedLINE, LINETO, VLINE
HTABPurposeSet/Read the current text cursor horizontal position.
SyntaxHTAB=valuevalue=HTAB
DescriptionSet/Read the current text cursor horizontal position.
ExampleCLSFOR xpos = 0 TO TWIDTH STEP 2 LOOP
HTAB=xposPRINT HTAB
REPEATEND
AssociatedHVTAB, VTAB, PRINTAT
Functions, Constants & Procedures
57main index
HVTABPurposeMove the current text cursor to the specified position.
SyntaxHVTAB(xpos,ypos)
DescriptionThe cursor is moved to the supplied column xpos and lineypos. Note that (0,0) is top-left of the text screen.
ExampleCLSHVTAB(TWIDTH/2-3,THEIGHT/2)PRINT "CENTRE"HVTAB(0,0)END
AssociatedHTAB, VTAB, PRINTAT
IF THENPurposeExecute a statement conditionally.
SyntaxIF condition THEN {statement}
DescriptionThe statement is executed when the condition evaluatesto TRUE (not 0). Unlike some implementations of BASICthe THEN is required.
ExamplePRINT "Press Space Bar to Continue"LOOP
IF INKEY = 32 THEN BREAKREPEATPRINT "Space Bar Pressed"END
AssociatedELSE, ENDIF, SWITCH
Functions, Constants & Procedures
58main index
INKEYPurposeGet a single character code from the keyboard withoutpausing.
Syntaxasciicode=INKEY
DescriptionThis is similar to GET except that program execution is notpaused; If no key is pressed, then -1 is returned. The followingconstants are predefined to test for special keys: KeyUp,KeyDown, KeyLeft, KeyRight, KeyIns, KeyHome, KeyDel,KeyEnd, KeyPgUp, KeyPgDn, KeyF1, KeyF2, KeyF3, KeyF4,KeyF5, KeyF6, KeyF7, KeyF8, KeyF9, KeyF10, KeyF11, KeyF12.
ExampleREM Show the ASCII code for the last keypressedLastKey = -1REM Press Esc to QuitLOOP
Key=INKEYIF Key<>-1 AND Key<>LastKey THEN
PRINT "Key Pressed: "; KeyLastKey = Key
ENDIFREPEAT
AssociatedGET, INPUT, SCANKEYBOARD
INKPurposeSet/Read the current text foreground colour.
Syntaxforegroundcolour=INKINK=foregroundcolour
DescriptionSet/Read the current text foreground (ink) colour.
ExamplePAPER=blackCLSstring$="This is multicoloured text"FOR I=1 TO LEN(string$) LOOP
INK=I MOD 15 + 1PRINT MID$(string$,I-1,1);
REPEATINK=whitePRINTEND
AssociatedPAPER
Functions, Constants & Procedures
59main index
INPUTPurposeRead data from the keyboard into a variable.
SyntaxINPUT [prompt$,] variable
DescriptionWhen FUZE BASIC encounters the INPUT statement,program execution stops, a question mark(?) is printedand it waits for you to type something. It then assignswhat you typed to the variable. If you typed in a stringwhen it was expecting a number, then it will assign zero tothe number. To stop it printing the question mark, youcan optionally give it a string to print.
ExampleINPUT "What is your Name? ", Name$PRINT "Hello " + Name$END
AssociatedINKEY
INPUT#PurposeRead data from a file.
SyntaxINPUT# handle,variable
DescriptionThis works similarly to the regular INPUT instruction, butreads from the file identified by the supplied handlerather than from the keyboard. Note that unlike theregular keyboard INPUT instruction, INPUT# can only readone variable at a time.
Examplehandle=OPEN("testfile.txt")PRINT# handle,"Hello World"REWIND(handle)INPUT# handle,record$PRINT record$CLOSE (handle)END
AssociatedCLOSE, EOF, FFWD, OPEN, PRINT#, REWIND, SEEK
Functions, Constants & Procedures
60main index
INTPurposeReturn the integer part of a number.
Syntaxintegerpart=INT(number)
DescriptionReturns the integer part of the specified number.
ExamplePRINT "The integer part of PI is ";PRINT INT(PI)END
LEFTPurposeTurns the turtle to the left (counter clockwise) by thegiven angle.
SyntaxLEFT(angle)
DescriptionTurns the virtual graphics turtle to the left (counterclockwise) by the given angle in the current angle units.
ExampleREM Draw a box using turtle graphicsCLSCOLOUR=REDMOVE(50)DEGLEFT(90)MOVE(50)PENDOWNFOR I = 1 TO 4 LOOP
LEFT(90)MOVE(100)
REPEATUPDATEEND
AssociatedMOVE, MOVETO, PENDOWN, PENUP, RIGHT, TANGLE
Functions, Constants & Procedures
61main index
LEFT$PurposeReturn the specified leftmost number of a characters froma string.
Syntaxsubstring$=LEFT$(string$,number)
DescriptionReturns a substring of string$ with number charactersfrom the left (start) of the string. If number is greater thanor equal to the length of string$ then the whole string isreturned.
Examplestring$="The quick brown fox"FOR I=1 TO 20 LOOP
PRINT LEFT$(string$, I)REPEATEND
AssociatedMID$, RIGHT$
LENPurposeReturn the length of the specified character string.
Syntaxlength=LEN(string$)
DescriptionReturns the number of characters in the specified string$.
ExampleString$="The Quick Brown Fox"Chars=LEN(String$)PRINT "String Length is: ";CharsFOR I=0 TO Chars - 1 LOOP
Char$=MID$(String$,I,1)PRINT "Character No. ";I;" is "+Char$
REPEATEND
Functions, Constants & Procedures
62main index
LINEPurposeDraw a line between two points
SyntaxLINE(xpos1,ypos1,xpos2,ypos2)
DescriptionDraw a line between point (xpos1,ypos1) and point(xpos2,ypos2) in the current COLOUR.
ExampleCLSCOLOUR = limeGH=GHEIGHTGW=GWIDTHLINE(10,10,10,GH-10)LINE(10,GH-10,GW-10,GH-10)LINE(GW-10,GH-10,GW-10,10)LINE(GW-10,10,10,10)UPDATEEND
AssociatedHLINE, LINETO, VLINE
LINETOPurposeDraw a line from the last point plotted.
SyntaxLINETO(xpos1,ypos1)
DescriptionDraws a line from the last point plotted (by the PLOT orLINE procedures) to point (xpos1,ypos1).
ExampleCLSCOLOUR = yellowORIGIN(10,10)GH=GHEIGHTGW=GWIDTHLINETO(0,GH-20)LINETO(GW-20,GH-20)LINETO(GW-20, 0)LINETO(0,0)UPDATEEND
AssociatedHLINE, LINE, VLINE
Functions, Constants & Procedures
63main index
LOADIMAGEPurposeLoad an image file into memory.
Syntaxhandle=LOADIMAGE(filename)
DescriptionLoad an image from a file with the specified filename. Thereturned handle can then be used to plot it on the screen withPLOTIMAGE.
ExampleCOLOUR=REDRECT(0,0,50,50,TRUE)COLOUR=WHITELINE(0,50,50,50)LINE(0,25,50,25)LINE(0,25,0,50)LINE(50,25,50,50)LINE(25,0,25,25)LINE(0,0,50,0)SAVEREGION("bricks.bmp",0,0,50,50)handle=LOADIMAGE("bricks.bmp")FOR X=0 TO GWIDTH STEP 50 LOOP
FOR Y=0 TO GHEIGHT STEP 50 LOOPPLOTIMAGE(handle,X,Y)
REPEATREPEATUPDATEEND
AssociatedGETIMAGEH, GETIMAGEW, PLOTIMAGE, FREEIMAGE
LOADMUSICPurposeLoad a music file into memory ready to be played.
Syntaxhandle=LOADMUSIC(filename)
DescriptionLoads an uncompressed music file in wav format (fileextension .wav) from the file filename into memory andreturns a handle which can then be used to play the musicusing the PLAYMUSIC function.
Examplehandle=LOADMUSIC("takeoff.wav")SETMUSICVOL(70)PLAYMUSIC(handle,1)END
AssociatedPAUSEMUSIC, RESUMEMUSIC, SETMUSICVOL, STOPMUSIC
Functions, Constants & Procedures
64main index
LOADSAMPLEPurposeLoad a sound sample into memory ready to be played.
Syntaxhandle=LOADSAMPLE(filename)
DescriptionThe LOADSAMPLE function loads a sound sample from theuncompressed WAV format file called filename andreturns a handle to it so that it can be played using thePLAYSAMPLE function. You can load up to 32 soundsamples into memory at the same time.
Examplechannel=0volume=70SETCHANVOL(channel,volume)intro=LOADSAMPLE("pacman_intro.wav")PLAYSAMPLE(intro,channel,0)WAIT(4.5)END
AssociatedPAUSECHAN, PLAYSAMPLE, RESUMECHAN, SETCHANVOL,STOPCHAN
LOADSPRITEPurposeLoad a sprite from a file into memory.
SyntaxLOADSPRITE(filename$,index,subindex)
DescriptionThis loads a sprite from the supplied filename$ into memoryand associates it with the given sprite index and subindex. Theindex is the handle returned by a call to NewSprite and thesubindex is the version of the sprite to allow for animation. Thefirst subindex is 0.
ExampleCLSREM Create a new sprite with 1 versionSpriteIndex=NEWSPRITE(1)REM Load a sprite from a filefuzelogo$="logo.bmp"LOADSPRITE(fuzelogo$,SpriteIndex,0)REM Draw the sprite on the screenPLOTSPRITE(SpriteIndex,200,200,0)UPDATEEND
AssociatedGETSPRITEH, GETSPRITEW, HIDESPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITETRANS, SPRITECOLLIDE,SPRITECOLLIDEPP
Functions, Constants & Procedures
65main index
LOCALPurposeDefine variables to be local to a user defined procedure orfunction.
SyntaxLOCAL variable
DescriptionAllows a variable name to be reused in a procedure orfunction without affecting its value in the calling program.
ExampleX=10PRINT "Global X="+STR$(X)Proc Test()PRINT "Global X="+STR$(X)ENDDEF PROC Test()
PRINT "Global X="+STR$(X)LOCAL XX=5PRINT "Local X="+STR$(X)
ENDPROC
AssociatedDEF FN, DEF PROC
LOGPurposeReturn the natural logarithm of the specified number.
Syntaxnaturallogarithm = LOG(number)
DescriptionReturns the natural logarithm of the specified number.This is the opposite of the EXP function i.e. LOG(EXP(X)) =X. Logarithms are used in science to solve exponentialradioactive decay problems and in finance to solveproblems involving compound interest.
ExampleX = EXP(10)PRINT X // Will print 22026.46579PRINT LOG(X) // Will print 10END
AssociatedEXP
Functions, Constants & Procedures
66main index
MAXPurposeReturns the larger of two numbers.
Syntaxmaxvalue=MAX(number1,number2)
DescriptionReturns the larger (highest value) of number1 or number2.
ExampleREM Prints the value of number2number1=12.26number2=27.45PRINT MAX(number1, number2)END
AssociatedMIN
MID$PurposeReturn characters from the middle of a string.
SyntaxMID$(string$, start, length)
DescriptionReturns the middle length characters of string$ startingfrom position start. The first character of the string isposition number 0.
ExampleREM Prints Quickstring$="The Quick Brown Fox"PRINT MID$(string$,4,5)END
AssociatedLEFT$, RIGHT$
Functions, Constants & Procedures
67main index
MINPurposeReturns the smaller of two numbers.
Syntaxminvalue=MIN(number1,number2)
DescriptionReturns the smaller (lowest value) of number1 ornumber2.
ExampleREM Prints the value of number1number1=12.26number2=27.45PRINT MIN(number1, number2)END
AssociatedMAX
MOUSEOFFPurposeMake the mouse cursor invisible.
SyntaxMOUSEOFF
DescriptionMake the mouse cursor invisible within the FUZE BASICwindow. This is the default value.
ExampleCLSMOUSEONLOOP
GETMOUSE(x,y,b)LINETO(x,y)UPDATEREM LOOP colour if left button pressedIF b & 1 THEN
COLOUR = COLOUR MOD 16 + 1ENDIFREM Exit if right button pressed
REPEAT UNTIL b & 4MOUSEOFFEND
AssociatedGETMOUSE, MOUSEON, MOUSEX, MOUSEY, SETMOUSE
Functions, Constants & Procedures
68main index
MOUSEONPurposeMake the mouse cursor visible.
SyntaxMOUSEON
DescriptionMake the mouse cursor visible within the FUZE BASICwindow. It is invisible by default.
ExampleCLSMOUSEONLOOP
GETMOUSE(x,y,b)LINETO(x,y)UPDATEREM LOOP colour if left button pressedIF b & 1 THEN
COLOUR = COLOUR MOD 16 + 1ENDIFREM Exit if right button pressed
REPEAT UNTIL b & 4MOUSEOFFEND
AssociatedGETMOUSE, MOUSEOFF, MOUSEX, MOUSEY, SETMOUSE
MOUSEXPurposeTo find the mouse X position
Syntaxvalue = MOUSEX
DescriptionReturns the X position of the current mouse location
ExampleLOOPPRINTAT(0,0); "Mouse X Position="; MOUSEX;" "REPEAT
AssociatedGETMOUSE, MOUSEOFF, MOUSEON, MOUSEY,SETMOUSE
Functions, Constants & Procedures
69main index
MOVEPurposeMove the graphics turtle forward
SyntaxMOVE(distance)
DescriptionThis causes the virtual graphics turtle to move forwardsdistance in screen pixels. A line will be drawn if the penisdown.
ExampleCLSCOLOUR=REDMOVE(50)DEGLEFT(90)MOVE(50)PENDOWNFOR I = 1 TO 4 LOOP
LEFT(90)MOVE(100)
REPEATUPDATEEND
AssociatedLEFT, MOVETO, PENDOWN, PENUP, RIGHT, TANGLE
MOUSEYPurposeTo find the mouse Y position
Syntaxvalue = MOUSEY
DescriptionReturns the Y position of the current mouse location
ExampleLOOPPRINTAT(0,0); "Mouse Y Position="; MOUSEY;" "REPEAT
AssociatedGETMOUSE, MOUSEOFF, MOUSEON, MOUSEX,SETMOUSE
Functions, Constants & Procedures
70main index
MOVETOPurposeMove the graphics turtle to a point on the screen.
SyntaxMOVETO(xpos,ypos)
DescriptionThis moves the virtual graphics turtle to the absolutelocation (xpos,ypos). A line will be drawn if the pen isdown.
ExampleREM Draw a spiral in the centre of thescreenCLSCOLOUR=REDPENUPMOVETO(GWIDTH/2,GHEIGHT/2)PENDOWNFOR I=2 TO GWIDTH LOOP
MOVE(I)RIGHT(30)
REPEATUPDATEEND
AssociatedLEFT, MOVE, PENDOWN, PENUP, RIGHT, TANGLE
NEWSPRITEPurposeCreate a new sprite.
Syntaxindex=NEWSPRITE(count)
DescriptionThis returns an index (or handle) to the internal spritedata. You need to use the index returned in all futuresprite handling functions/procedures. The countargument specifies the number of different versions ofthe sprite.
Example overleaf…
Functions, Constants & Procedures
71main index
ExampleCLSCOLOUR=YELLOWCIRCLE(100,100,50,TRUE)SAVEREGION("pac1.bmp",50,50,101,101)COLOUR=BLACKTRIANGLE(100,100,150,125,150,75,TRUE)SAVEREGION("pac2.bmp",50,50,101,101)TRIANGLE(100,100,150,150,150,50,TRUE)SAVEREGION("pac3.bmp",50,50,101,101)CLSpacman=NEWSPRITE(3)LOADSPRITE("pac1.bmp",pacman,0)LOADSPRITE("pac2.bmp",pacman,1)LOADSPRITE("pac3.bmp",pacman,2)FOR X=1 TO GWIDTH STEP 25 LOOP
FOR S=0 TO 2 LOOPPLOTSPRITE(pacman,X,GHEIGHT/2,S)UPDATEWAIT(.1)
REPEATREPEATHIDESPRITE(pacman)END
AssociatedGETSPRITEH, GETSPRITEW, HIDESPRITE, LOADSPRITE,PLOTSPRITE, SETSPRITETRANS, SPRITECOLLIDE,SPRITECOLLIDEPP
NUMFORMATPurposeControl how numbers are formatted.
SyntaxNUMFORMAT(width,decimals)
DescriptionYou can affect the way numbers are printed using theNUMFORMAT procedure. This takes 2 arguments, thewidth specifying the total number of characters to printand the decimals the number of characters after thedecimal point. Numbers printed this way are right-justified with leading spaces inserted if required.NUMFORMAT (0,0) restores the output to the generalpurpose format used by default.
ExampleNUMFORMAT(6,4)REM Prints 3.1416PRINT PINUMFORMAT(0,0)REM Prints 3.141592654PRINT PIEND
AssociatedPRINT, PRINTAT
Functions, Constants & Procedures
72main index
OPENPurposeOpen a file for read or write.
Syntaxhandle=OPEN(filename$)
DescriptionThe OPEN function opens a file and makes it available forreading or writing and returns the numeric handleassociated with the file. The file is created if it doesn’texist, or if it does exist the file pointer is positioned at thestart of the file.
Examplehandle = OPEN("testfile.txt")PRINT# handle, "Colin"PRINT# handle, 47CLOSE(handle)handle = OPEN("testfile.txt")INPUT# handle, Name$INPUT# handle, AgeCLOSE(handle)PRINT "Name: " + Name$PRINT "Age: "; AgeEND
AssociatedCLOSE, EOF, FFWD, INPUT#, PRINT#, REWIND, SEEK
ORIGINPurposeMove the graphics origin.
SyntaxORIGIN(xpos,ypos)
DescriptionThis changes the graphics origin for the Cartesian plottingprocedures. The xpos, ypos coordinates are alwaysabsolute coordinates with (0,0) being bottom left (thedefault).
ExampleCLSCOLOUR=yellowREM Move the origin to the screen centreORIGIN(GWIDTH/2, GHEIGHT/2)PLOT(-100,-100)LINETO(-100,100)LINETO(100,100)LINETO(100,-100)LINETO(-100,-100)UPDATEORIGIN(0,0)END
AssociatedGHEIGHT, GWIDTH
Functions, Constants & Procedures
73main index
PAPERPurposeSet/Read the current text background colour.
Syntaxbackgroundcolour=PAPERPAPER=backgroundcolour
DescriptionSet/Read the current text background (paper) colour.Clear screen (CLS) will set the entire background to thiscolour.
ExamplePRINT "Text background colour "; PAPERPAPER=REDPRINT "Text background colour "; PAPERPAPER=7PRINT "Text background colour "; PAPEREND
AssociatedINK, PAPERON, PAPEROFF
PAPEROFFPurposeSwitches the text background colour off.
SyntaxPAPEROFF
DescriptionThis function switches the background text colour off. Itcan be turned on or off so that the text background doesnot obscure whatever is behind it.
ExampleLOOP INK = Orange PaperOn fontSize (RND (10) + 1) printAt (RND(tWidth), RND(tHeight - 1)); "ON"; WAIT(.3) INK = Yellow PaperOff fontSize (RND (10) + 1) printAt (RND(tWidth), RND(tHeight - 1)); "OFF"; WAIT(.3)REPEAT
AssociatedINK, PAPER, PAPERON
Functions, Constants & Procedures
74main index
PAPERONPurposeSets text background colour to display
SyntaxPAPERON
DescriptionThis function switches the background text colour on.It can be turned on or off so that the text backgrounddoes not obscure whatever is behind it.
ExampleLOOP INK = Orange PaperOn fontSize (RND (10) + 1) printAt (RND(tWidth), RND(tHeight - 1)); "ON"; WAIT(.3) INK = Yellow PaperOff fontSize (RND (10) + 1) printAt (RND(tWidth), RND(tHeight - 1)); "OFF"; WAIT(.3)REPEAT
AssociatedINK, PAPER, PAPEROFF
PAUSECHANPurposePause the playing of a sound sample.
SyntaxPAUSECHAN(handle)
DescriptionThis function pauses the playing of the sound sampleassociated with the handle returned by LOADSAMPLEthat has been started using PLAYSAMPLE. The samplecan be resumed where it left off using RESUMECHAN
Examplechannel=0volume=70SETCHANVOL(channel,volume)intro=LOADSAMPLE("pacman_intro.wav")PLAYSAMPLE(intro,channel,0)WAIT(3)PAUSECHAN(intro)Wait(2)RESUMECHAN(intro)END
AssociatedLOADSAMPLE, PLAYSAMPLE, RESUMECHAN,SETCHANVOL, STOPCHAN
Functions, Constants & Procedures
75main index
PAUSEMUSICPurposePause a playing music file
SyntaxPAUSEMUSIC
DescriptionPauses a playing music track which can them be restartedusing RESUMEMUSIC.
Examplehandle=LOADMUSIC("takeoff.wav")SETMUSICVOL(70)PLAYMUSIC(handle,1)PAUSEMUSIC
AssociatedLOADMUSIC, RESUMEMUSIC, SETMUSICVOL, STOPMUSIC
PENDOWNPurposeStart drawing using the graphics turtle.
SyntaxPENDOWN
DescriptionThis lowers the “pen” that the virtual graphics turtle isusing to draw with. Nothing will be drawn until youexecute this procedure.
ExampleREM Draw a spiral in the centre of thescreenCLSCOLOUR=REDPENUPMOVETO(GWIDTH/2,GHEIGHT/2)PENDOWNFOR I=2 TO GWIDTH LOOP
MOVE(I)RIGHT(30)
REPEATUPDATEEND
AssociatedLEFT, MOVE, MOVETO, PENUP, RIGHT, TANGLE
Functions, Constants & Procedures
76main index
PENUPPurposeStop drawing using the graphics turtle.
SyntaxPENUP
DescriptionThis lifts the “pen” that the virtual graphics turtle uses todraw. You can move the turtle without drawing while thepen is up.
ExampleREM Draw a spiral in the centre of thescreenCLSCOLOUR=REDPENUPMOVETO(GWIDTH/2,GHEIGHT/2)PENDOWNFOR I=2 TO GWIDTH LOOP
MOVE(I)RIGHT(30)
REPEATUPDATEEND
AssociatedLEFT, MOVE, MOVETO, PENDOWN, RIGHT, TANGLE
PIPurposeReturns the value of the constant pi.
Syntaxvalueofpi=PI
DescriptionReturns an approximation of the value of the constant piwhich is the ratio of a circle’s circumference to itsdiameter (approximately 3.141592654) which is widelyused in mathematics, specifically trigonometry andgeometry.
ExamplePRINT FN AreaOfCircle(12)ENDDEF FN AreaOfCircle(withRadius)
LOCAL resultresult=PI*withRadius*withRadius
= result
Functions, Constants & Procedures
77main index
PINMODEPurposeConfigure the mode of a pin on the Pi’s GPIO.
SyntaxPINMODE(pinno,pinmode)
DescriptionConfigures the mode of a pin on the Pi’s GPIO. It takes anargument which specifies the mode of the pin - input,output or PWM output. The modes are:0 pinINPUT1 pinOUTPUT2 pinPWM
ExampleREM Set pin 12 to inputPINMODE(12,1)REM Wait for button to be pushedUNTIL DIGITALREAD(12) LOOPREPEATPRINT "Button Pushed"END
AssociatedDIGITALREAD, DIGITALWRITE, PWMWRITE,SOFTPWMWRITE
PLAYMUSICPurposeStart playing a music track.
SyntaxPLAYMUSIC(handle,repeats)
DescriptionThis function plays a music track previously loaded usingthe LOADMUSIC function which returns the handle. Therepeats are the number of times to play the track.
Examplehandle=LOADMUSIC("takeoff.wav")SETMUSICVOL(70)PLAYMUSIC(handle,1)END
AssociatedLOADMUSIC, PAUSEMUSIC, RESUMEMUSIC,SETMUSICVOL, STOPMUSIC
Functions, Constants & Procedures
78main index
PLAYSAMPLEPurposeStart playing a sound sample.
SyntaxPLAYSAMPLE(handle,channel,loops)
DescriptionThis function plays a sound previously loaded using theLOADSAMPLE function which returns the handle. Thechannel is 0, 1, 2 or 3 which lets you play up to 4concurrent samples. The loops parameter is different tothe repeats one in the PLAYMUSIC function. Here it meansthe number of times to loop the sample – zero means noloops which means play it ONCE.
Examplechannel=0volume=70SETCHANVOL(channel,volume)intro=LOADSAMPLE("pacman_intro.wav")PLAYSAMPLE(intro,channel,0)WAIT(4.5)END
AssociatedLOADSAMPLE, PAUSECHAN, RESUMECHAN, SETCHANVOL,STOPCHAN
PLOTPurposeDraw a single point on the screen.
SyntaxPLOT(xpos,ypos)
DescriptionThis plots a single pixel at screen location (xpos,ypos) inthe selected graphics mode in the selected colour. Notethat (0,0) is bottom left by default.
ExampleCLSLOOP
IF INKEY<>-1 THEN BREAKxpos=RND(GWIDTH)ypos=RND(GHEIGHT)COLOUR=RND(16)PLOT(xpos, ypos)UPDATE
REPEATEND
Functions, Constants & Procedures
79main index
PLOTIMAGEPurposeDisplay a loaded image on the screen.
SyntaxPLOTIMAGE(handle,xpos,ypos)
DescriptionPlot an image previously loaded using LOADIMAGE(using the handle returned by LOADIMAGE) on thescreen at coordinates (xpos,ypos).
ExampleCOLOUR=REDRECT(0,0,50,50,TRUE)COLOUR=WHITELINE(0,50,50,50)LINE(0,25,50,25)LINE(0,25,0,50)LINE(50,25,50,50)LINE(25,0,25,25)LINE(0,0,50,0)SAVEREGION("bricks.bmp",0,0,50,50)handle=LOADIMAGE("bricks.bmp")FOR X=0 TO GWIDTH STEP 50 LOOP
FOR Y=0 TO GHEIGHT STEP 50 LOOPPLOTIMAGE(handle,X,Y)
REPEATREPEATUPDATEEND
AssociatedGETIMAGEH, GETIMAGEW, LOADIMAGE, FREEIMAGE
PLOTSPRITEPurposeDraw a sprite on the screen.
SyntaxPLOTSPRITE(index,xpos,ypos,subindex)
DescriptionThis plots the sprite index and version subindex at thecoordinates (xpos, ypos). The coordinates specify the bottom-left corner of the bounding rectangle of the sprite.
ExampleCLSREM Create a new sprite with 1 versionSpriteIndex=NEWSPRITE(1)REM Load a sprite from a filefuzelogo$="/usr/share/fuze/logo.bmp"LOADSPRITE(fuzelogo$,SpriteIndex,0)REM Draw the sprite on the screenPLOTSPRITE(SpriteIndex,200,200,0)UPDATEEND
AssociatedGETSPRITEH, GETSPRITEW, HIDESPRITE, LOADSPRITE,NEWSPRITE, SETSPRITEALPHA, SETSPRITEANGLE,SETSPRITEFLIP, SETSPRITESIZE, SETSPRITETRANS,SPRITECOLLIDE, SPRITECOLLIDEPP, SPRITEOUT
Functions, Constants & Procedures
80main index
POLYENDPurposeDraw the filled polygon started by PolyStart.
SyntaxPOLYEND
DescriptionThis marks the end of drawing a polygon. When this iscalled, the stored points will be plotted on the screen andthe polygon will be filled.
ExampleCLSPROC Hexagon(200,200,50,Red)UPDATEENDDEF Proc Hexagon(x,y,l,c)
COLOUR=cPOLYSTARTPOLYPLOT(x+l,y)POLYPLOT(x+l/2,y-l*SQRT(3/2))POLYPLOT(x-l/2,y-l*SQRT(3/2))POLYPLOT(x-l,y)POLYPLOT(x-l/2,y+l*SQRT(3/2))POLYPLOT(x+l/2,y+l*SQRT(3/2))POLYEND
ENDPROC
AssociatedPOLYPLOT, POLYSTART
POLYPLOTPurposeAdd a point to a filled polygon.
SyntaxPOLYPLOT(xpos,ypos)
DescriptionThis remembers the given xpos,ypos coordinates as part of afilled polygon. Nothing is actually drawn on the screen until thePolyEnd instruction is executed. Polygons can have a maximumof 64 points.
ExampleCLSPROC Hexagon(200,200,50,Red)UPDATEENDDEF Proc Hexagon(x,y,l,c)
COLOUR=cPOLYSTARTPOLYPLOT(x+l,y)POLYPLOT(x+l/2,y-l*SQRT(3/2))POLYPLOT(x-l/2,y-l*SQRT(3/2))POLYPLOT(x-l,y)POLYPLOT(x-l/2,y+l*SQRT(3/2))POLYPLOT(x+l/2,y+l*SQRT(3/2))POLYEND
ENDPROC
AssociatedPOLYEND, POLYSTART
Functions, Constants & Procedures
81main index
POLYSTARTPurposeStart drawing a filled polygon.
SyntaxPOLYSTART
DescriptionThis marks the start of drawing a filled polygon.
ExampleCLSPROC Hexagon(200,200,50,Red)UPDATEENDDEF Proc Hexagon(x,y,l,c)
COLOUR=cPOLYSTARTPOLYPLOT(x+l,y)POLYPLOT(x+l/2,y-l*SQRT(3/2))POLYPLOT(x-l/2,y-l*SQRT(3/2))POLYPLOT(x-l,y)POLYPLOT(x-l/2,y+l*SQRT(3/2))POLYPLOT(x+l/2,y+l*SQRT(3/2))POLYEND
ENDPROC
AssociatedPOLYEND, POLYPLOT
PLOTTEXTPurposeDisplay text using graphic coordinates.
SyntaxPLOTTEXT(“text”, xpos, ypos)
DescriptionThe PRINT command uses the cursor coordinates todisplay text whereas PLOTTEXT can position text at aspecified pixel location
ExampleLOOP INK = RND (30) fontSize (RND (10) + 1) plotText("HELLO", RND(gWidth), RND(gHeight-1)) UPDATEREPEAT
AssociatedPRINT, PRINTAT
Functions, Constants & Procedures
82main index
PRINTPurposeOutput text to the screen
SyntaxPRINT {text}{;text}
DescriptionOutputting text to the screen is done via the PRINTcommand. The PRINT command is quite versatile and willprint any combination of numbers and strings separatedby the semi-colon (;). A trailing semi-colon will suppressthe printing of a new line.
ExamplePRINT "Hello Colin"PRINT "Hello ";name$="Colin"PRINT name$PRINT "Hello "; name$END
AssociatedNUMFORMAT, PRINTAT
PRINT#PurposePrint data to a file.
SyntaxPRINT# handle,data
DescriptionThe PRINT# instruction acts just like the regular PRINTinstruction except that it sends data to the file identifiedby the supplied file-handle rather than to the screen.Numbers are formatted according to the settings ofNUMFORMAT. It is strongly recommended to only printone item per line if you are going to read those items backinto a FUZE BASIC program again.
Examplehandle = OPEN("testfile.txt")PRINT# handle, "Hello World"CLOSE (handle)END
AssociatedCLOSE, EOF, FFWD, INPUT#, OPEN, REWIND, SEEK
Functions, Constants & Procedures
83main index
PRINTATPurposeSet the text cursor position and print
SyntaxPRINTAT( x, y ); "text"
DescriptionUse to position the text cursor at the specified locationand print. Useful for laying out text and or variables atany preferred screen location.
Examplename$ = "Sam"age = 10PRINTAT( 0, 5 ); "My name is "; name$PRINTAT( 5, 10 ); "I am "; age ; " yearsold"END
AssociatedCHR$, HTAB, HVTAB, INK,PAPER, PRINT, PRINT, THEIGHT, TWIDTH, VTAB
PROCPurposeCall a user defined procedure.
SyntaxPROC name({argument}{,argument})
DescriptionCalls the specified user defined procedure called namewith the specified arguments. Once the procedure hasbeen executed control returns to the command following.
ExampleCLSLOOP
x=RND(TWIDTH)y=RND(THEIGHT)c=RND(15)Text$=”Blossom”PROC text(text$, x, y, c)
REPEATENDDEF PROC text(text$, x, y, c) INK=c PRINTAT(x,y); text$ENDPROC
AssociatedDEF PROC, ENDPROC
Functions, Constants & Procedures
84main index
PWMWRITEPurposeOutput a PWM waveform on the selected pin.
SyntaxPWMWRITE(pinno,pinvalue)
DescriptionThis procedure outputs a PWM waveform on the selectedpin. The pin must be configured for PWM modebeforehand. The value set should be between 0 and 100.
ExampleREM Set pin 1 to PWM output modePINMODE(1,2)PWMWRITE (1,50)END
AssociatedDIGITALREAD, DIGITALWRITE, PINMODE
RADPurposeSet angle units to radians.
SyntaxRAD
DescriptionSwitches the internal angle system to radians. There are 2* PI radians in a full circle.
ExampleREM Draw an ellipse in the screen centreCLSRADFOR Angle=0 TO 2 * PI STEP 0.01 LOOP
Xpos=100*COS(Angle)+GWIDTH / 2Ypos=50*SIN(Angle)+GHEIGHT / 2PLOT(Xpos,Ypos)
REPEATEND
AssociatedCLOCK, DEG
Functions, Constants & Procedures
85main index
READPurposeRead data into program variables.
SyntaxREAD variable {,variable}
DescriptionTo get data into your program variables, we use the READinstruction. We can read one, or many items of data at atime.
ExampleREM Load the name of the days of theREM week into a string arrayDATA "Monday", "Tuesday", "Wednesday"DATA "Thursday", "Friday", "Saturday"DATA "Sunday"DIM DaysOfWeek$(7)FOR Day = 1 TO 7 LOOP
READ DaysOfWeek$(Day)REPEATPRINT "The third day of the week is ";PRINT DaysOfWeek$(3)END
AssociatedDATA, RESTORE
RECTPurposeDraw a rectangle on the screen.
SyntaxRECT(xpos,ypos,width,height,fill)
DescriptionDraws a rectangle at position (xpos,ypos) with width andheight. The final parameter, fill is either TRUE or FALSE,and specifies filled (TRUE) or outline (FALSE).
ExampleCLSLOOP
COLOUR=RND(16)x=RND(GWIDTH)y=RND(GHEIGHT)w=RND(GWIDTH / 4)h=RND(GHEIGHT / 4)f=RND(2)RECT(x,y,w,h,f)UPDATEIF INKEY<>-1 THEN BREAK
REPEATEND
AssociatedCIRCLE, ELLIPSE, TRIANGLE
Functions, Constants & Procedures
86main index
REPEAT UNTILPurposeLoop until the specified condition is met.
SyntaxLOOP
{statements}REPEAT UNTIL condition
DescriptionExecute the statements one or more times until thecondition is TRUE (not 0).
ExampleNumber=INT(RND(10)) + 1Guess=0REM Guessing GamePRINT "Guess a Number Between 1 and 10"LOOP
INPUT "Enter Your Guess: ", GuessIF (Number<>Guess) THEN
PRINT "Incorrect Guess Again"ENDIF
REPEAT UNTIL Number = GuessPRINT "You are Correct!"END
AssociatedBREAK, CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT,UNTIL REPEAT, WHILE REPEAT
RESTOREPurposeReset the DATA pointer.
SyntaxRESTORE
DescriptionWith no lineno specified resets the READ command to thevery first DATA statement in the program.
ExampleDATA "Monday", "Tuesday", "Wednesday"DATA "Thursday", "Friday", "Saturday","Sunday"FOR Day = 1 TO 3 LOOP
READ DayOfWeek$REPEATPRINT DayOfWeek$RESTOREFOR Day = 1 TO 4 LOOP
READ DayOfWeek$REPEATPRINT DayOfWeek$END
AssociatedDATA, READ
Functions, Constants & Procedures
87main index
RESUMECHANPurposeResume the playing of a sound sample.
SyntaxRESUMECHAN(handle)
DescriptionThis function resumes the playing of the sound sampleassociated with the handle returned by LOADSAMPLEthat has been started using PLAYSAMPLE and pausedusing PAUSECHAN.
Examplechannel=0volume=70SETCHANVOL(channel,volume)intro=LOADSAMPLE("pacman_intro.wav")PLAYSAMPLE(intro,channel,0)WAIT(3)PAUSECHAN(intro)WAIT(2)RESUMECHAN(intro)END
AssociatedLOADSAMPLE, PAUSECHAN, PLAYSAMPLE, SETCHANVOL,STOPCHAN
RESUMEMUSICPurposeResumes music playing after it has been paused.
SyntaxRESUMEMUSIC
DescriptionResumes the playing of a music track previously pausedusing PAUSEMUSIC.
Examplehandle=LOADMUSIC("takeoff.wav")SETMUSICVOL(70)PLAYMUSIC(handle,1)PAUSEMUSICWAIT(1)RESUMEMUSIC
AssociatedLOADMUSIC, PAUSEMUSIC, SETMUSICVOL, STOPMUSIC
Functions, Constants & Procedures
88main index
REWINDPurposeMove the file pointer to the start of a file.
SyntaxREWIND(handle)
DescriptionMove the file pointer to the start of the file specified byhandle.
Examplehandle=OPEN ("rewindtest.txt")PRINT# handle,"First Record"PRINT# handle,"Second Record"CLOSE(handle)handle=OPEN("rewindtest.txt")INPUT# handle, record$PRINT record$REWIND(handle)REM reads the first record againINPUT# handle, record$PRINT record$CLOSE (handle)END
AssociatedCLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, SEEK
RGBCOLOURPurposeSet the current graphical plot colour to an RGB(Red,Green, Blue) value.
SyntaxRGBCOLOUR(red,green,blue)
DescriptionThis sets the current graphical plot colour to an RGB(Red,Green, Blue) value. The values should be from 0 to 255.
ExampleCLSPRINT "Draw Spectrum"FOR v = 0 TO 255 LOOP
RGBCOLOUR(255,v,0)LINE(v,300,v,400)RGBCOLOUR(v,255,0)LINE(511-v,300,511-v,400)RGBCOLOUR(0,255-v,v)LINE(512+v,300,512+v,400)RGBCOLOUR(0,v,255)LINE(768+v,300,768+v,400)
REPEATUPDATEEND
AssociatedCOLOUR, INK, PAPER
Functions, Constants & Procedures
89main index
RIGHTPurposeTurns the turtle to the right (clockwise) by the given angle.
SyntaxRIGHT(angle)
DescriptionTurns the virtual graphics turtle to the right (clockwise) bythe given angle in the current angle units.
ExampleCLSPRINT "Draw Pink Hexagon"PENUPCOLOUR = PINKPENDOWNFOR I = 1 TO 6 LOOP
RIGHT(60)MOVE(100)
REPEATEND
AssociatedLEFT, MOVE, MOVETO, PENDOWN, PENUP, TANGLE
RIGHT$PurposeReturn the specified rightmost number of a charactersfrom a string.
Syntaxsubstring$=RIGHT$(string$,number)
DescriptionReturns a substring of string$ with number charactersfrom the right (end) of the string. If number is greaterthan or equal to the length of string$ then the wholestring is returned.
ExampleString$="The quick brown fox"FOR I=1 TO 20 LOOP
PRINT RIGHT$(String$, I)REPEATEND
AssociatedLEFT$, MID$
Functions, Constants & Procedures
90main index
ROTATEIMAGEPurposeReturn the specified rightmost number of a charactersfrom a string.
Syntaxsubstring$=RIGHT$(string$,number)
DescriptionReturns a substring of string$ with number charactersfrom the right (end) of the string. If number is greaterthan or equal to the length of string$ then the wholestring is returned.
Exampleimage = loadImage ("screen.png")plotImage (image, 0, 0)UPDATEWAIT (2)CLSrotateImage (image, 90)plotImage (image, 0, 0)UPDATEWAIT (2)END
AssociatedLOADIMAGE, SCALEIMAGE
RNDPurposeGenerate a random number in a given range.
Syntaxrandom=RND(range)
DescriptionThis function returns a random number based on thevalue of range. If range is zero, then the last randomnumber generated is returned, if range is 1, then arandom number from 0 to 1 is returned, otherwise arandom number from 0 up to, but not including range isreturned.
ExampleDiceRoll=RND(6)+1PRINT "Dice Roll: "; DiceRollCoinToss=RND(2)IF CoinToss=0 THEN
PRINT "Heads"ELSE
PRINT "Tails"ENDIFEND
AssociatedSEED
Functions, Constants & Procedures
91main index
SAVEREGIONPurposeSave a snapshot of an area of the screen to an image file.
SyntaxSAVEREGION(file$,xpos,ypos,width,height)
DescriptionThis takes a snapshot of an area of the current screen,specified by the rectangle with bottom left at coordinates(xpos,ypos) of specified width and height, and saves it tothe file named file$ in a bitmap (.bmp) format.
Example (overleaf)
SAVEREGION Example
CLSCOLOUR=YELLOWCIRCLE(100,100,50,TRUE)SAVEREGION("pac1.bmp",50,50,101,101)COLOUR=BLACKTRIANGLE(100,100,150,125,150,75,TRUE)SAVEREGION("pac2.bmp",50,50,101,101)TRIANGLE(100,100,150,150,150,50,TRUE)SAVEREGION("pac3.bmp",50,50,101,101)CLSpacman=NEWSPRITE(3)LOADSPRITE("pac1.bmp",pacman,0)LOADSPRITE("pac2.bmp",pacman,1)LOADSPRITE("pac3.bmp",pacman,2)FOR X=1 TO GWIDTH STEP 25 LOOP
FOR S=0 TO 2 LOOPPLOTSPRITE(pacman,X,GHEIGHT/2,S)UPDATEWAIT(.1)
REPEATREPEATHideSprite(pacman)END
AssociatedSAVESCREEN
Functions, Constants & Procedures
92main index
SAVESCREENPurposeSave a snapshot of the screen to an image file.
SyntaxSAVESCREEN(filename$)
DescriptionThis takes a snapshot of the current screen and saves it tothe filename given in a bitmap (.bmp) format file.
ExampleCLSPRINT "Draw Spectrum"FOR v = 0 TO 255 LOOP
RGBCOLOUR(255,v,0)LINE(v,300,v,400)RGBCOLOUR(v,255,0)LINE(511-v,300,511-v,400)RGBCOLOUR(0,255-v,v)LINE(512+v,300,512+v,400)RGBCOLOUR(0,v,255)LINE(768+v,300,768+v,400)
REPEATUPDATESAVESCREEN("screenshot.bmp")END
AssociatedSAVEREGION
SCALEIMAGEPurposeResize a loaded image.
SyntaxSCALEIMAGE(handle, percent)
DescriptionScales a preloaded image by a specified percentage.
Exampleimage = loadImage ("screen.png")plotImage (image, 0, 0)UPDATEWAIT (2)CLSscaleImage (image, 50)plotImage (image, 0, 0)UPDATEWAIT (2)END
AssociatedLOADIMAGE, ROTATEIMAGE
Functions, Constants & Procedures
93main index
SCANKEYBOARDPurposeScan for a key pressed down.
SyntaxSCANKEYBOARD(keycode)
DescriptionAllows you to detect that any of the keys have beenpressed (including special keys) and also to detect mutiplekeys pressed at the same time. The keycode parameterindicates the key press to be scanned for e.g scanSpace isthe space bar. See the end of this guide for a full list ofSCANKEYBOARD keycodes.
ExamplePRINT "Press Ctrl-Alt-Delete"LOOP
LCtrl = SCANKEYBOARD(scanLCtrl)LAlt = SCANKEYBOARD(scanLAlt)Delete = SCANKEYBOARD(scanDelete)Reboot = LCtrl AND LAlt AND Delete
REPEAT UNTIL RebootPRINT "Rebooting…"CLEARKEYBOARDEND
AssociatedCLEARKEYBOARD, GET, INKEY, INPUT
SCLOSEPurposeClose an open serial port.
SyntaxSCLOSE(handle)
DescriptionThis closes a serial port and frees up any resources usedby it. It’s not strictly necessary to do this when you endyour program, but it is considered good practice.
ExampleREM Read a character from a serial portarduino=SOPEN("/dev/ttyUSB0", 115200)char$=SGET$(arduino)PRINT char$SCLOSE(arduino)END
AssociatedSGET, SGET$, SOPEN, SPUT, SPUT$, SREADY
Functions, Constants & Procedures
94main index
SCROLLDOWNSCROLLLEFTSCROLLRIGHTSCROLLUPPurposeScroll a region of the screen down.
SyntaxSCROLLDOWN(xpos,ypos,width,height,pixels)
DescriptionScroll the region of the screen specified by the rectangleat position (xpos,ypos) with dimensions width X heightdown by the specified number of pixels.
Example overleaf
ExampleCLSW=100 // WidthS=2 // Step SizeX=(GWIDTH-W)/2Y=(GHEIGHT-W)/2COLOUR=WHITERECT(X,Y,W,W,TRUE)RECT(X+W,Y+W,W,W,TRUE)RECT(X-2,Y-2,W*2+4,W*2+4,FALSE)UPDATECOLOUR=BLACKFOR I=1 TO W STEP S LOOP
SCROLLUP(X,Y,W,W*2,S)SCROLLDOWN(X+W,Y,W,W*2,S)UPDATEWAIT(0.01)
REPEATFOR I = 1 TO W STEP S LOOP
SCROLLRIGHT(X,Y+W,W*2,W,S)SCROLLLEFT(X,Y,W*2,W,S)WAIT(0.01)
UPDATEREPEATEND
AssociatedSCROLLLEFT, SCROLLRIGHT, SCROLLUP
Functions, Constants & Procedures
95main index
SEEDPurposeSeed the random number generator.
SyntaxSEED=value
DescriptionThis can be assigned to initialise the random numbergenerator, or you can read it to find the current seed.
ExampleSEED=10PRINT RND(100)SEED=10REM Will print the same numberPRINT RND(100)REM Will print a different numberPRINT RND(100)END
AssociatedRND
SEEKPurposeMove the file pointer to any place in the file.
SyntaxSEEK(handle,offset)
DescriptionThe SEEK instruction moves the file pointer to any place in thefile. It can even move the file pointer beyond the end of the filein which case the file is extended. The argument supplied toSEEK is an absolute number of bytes from the start of the file. Ifyou are using random access files and want to access the 7threcord in the file, then you need to multiply your record size by7 to get the final location to seek to.
Examplehandle=OPEN("TestFile.txt")recSize = 20FOR recNo=0 TO 10 LOOP
record$ = "Record " + STR$(recNo)pad = recSize - LEN(record$)PRINT# handle,record$;SPACE$(pad)
REPEATREM read the 7th recordSEEK (handle,(recSize+1)*7)INPUT# handle,record$PRINT record$CLOSE(handle)END
AssociatedCLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND
Functions, Constants & Procedures
96main index
SENSEACCELX / Y / ZPurposeReturns the value of the Raspberry Pi senseHATaccelerometer.
Syntaxvalue=SENSEACCELXvalue=SENSEACCELYvalue=SENSEACCELZ
Description
The Raspberry Pi senseHAT has a number of built insensors. The accelerometer can be accessed with thisfunction.
ExampleCLSLOOPPRINT “Sense Accelerometer X=”; senseAccelXPRINT “Sense Accelerometer Y=”; senseAccelYPRINT “Sense Accelerometer Z=”; senseAccelZREPEATEND
AssociatedsenseCompass, senseGyro
SENSECLSPurposeSets all of the LEDs on the Raspberry Pi senseHAT to off.
SyntaxSENSECLS
Description
Sets an RGB value of 0, 0, 0 to all of the matrix LEDsthereby clearing the display.
ExampleCLSsensePlot(2,2)WAIT (1)senseClsEND
AssociatedsensePlot, senseRect, senseScroll, senseHFlip,senseVflip, senseRGBcolour, senseGetRGB, senseLine
Functions, Constants & Procedures
97main index
SENSECOMPASSX / Y / ZPurposeReturns the value of the Raspberry Pi senseHATcompass.
Syntaxvalue=SENSECOMPASSXvalue=SENSECOMPASSYvalue=SENSECOMPASSZ
Description
The Raspberry Pi senseHAT has a number of built insensors. The compass can be accessed with this function.
ExampleCLSLOOPPRINT “Sense Compass X=”; senseCompassXPRINT “Sense Compass Y=”; senseCompassYPRINT “Sense Compass Z=”; senseCompassZREPEATEND
AssociatedsenseAccel, senseGyro,
SENSEGETRGBPurposeReturn the values used by a Raspberry Pi senseHAT LED
SyntaxSENSEGETRGB(xpos, ypos, red, green, blue)
Description
Returns the Red, Green and Blue values from a given LEDat the specified matrix coordinates. It is possible to usethis for collision detection in games using the senseHAT.
ExampleCLSsenseRGBcolour (0, 0, 255)sensePlot (0, 0)SenseGetRGB (0, 0, R, G, B)PRINT “Red=”; RPRINT “Green=”; GPRINT “Blue=”; BEND
AssociatedsenseCls, sensePlot, senseRect, senseScroll, senseHFlip,senseVflip, senseRGBcolour, , senseLine
Functions, Constants & Procedures
98main index
SENSEGYROX / Y / ZPurposeReturns the value of the Raspberry Pi senseHAT gyro.
Syntaxvalue=SENSEGYROXvalue=SENSEGYROYvalue=SENSEGYROZ
Description
The Raspberry Pi senseHAT has a number of built insensors. The gyro can be accessed with this function.
ExampleCLSLOOPPRINT “Sense Gyro X=”; senseGyroXPRINT “Sense Gyro Y=”; senseGyroYPRINT “Sense Gyro Z=”; senseGyroZREPEATEND
AssociatedsenseAccel, senseCompass
SENSEHEIGHTPurposeReturns the value of the Raspberry Pi senseHAT heightsensor.
Syntaxvalue=SENSEHEIGHT
Description
The Raspberry Pi senseHAT has a number of built insensors. Height above sea level can be accessed with thisfunction. Note, this does not work well indoors.
ExampleCLSLOOPPRINT “Height”; senseHeightREPEATEND
AssociatedsenseHumidity, sensePressure, senseTemperature
Functions, Constants & Procedures
99main index
SENSEHFLIPPurposeHorizontally flips the Raspberry Pi senseHAT LED matrix.
SyntaxSENSEHFLIP
Description
Reverses (flips) the LED matrix display horizontally.
ExampleCLSSenseRGBcolour(255,0,0)senseLine(0,0,0,7)SenseRGBcolour(0,255,0)senseLine(0,7,7,7)LOOPsenseHflipWAIT(1)SenseVflipWAIT(1)END
AssociatedsenseCls, sensePlot, senseRect, senseScroll, senseVflip,senseRGBcolour, senseGetRGB, , senseLine
SENSEHUMIDITYPurposeReturns the value of the Raspberry Pi senseHAThumidity sensor.
Syntaxvalue=SENSEHUMIDITY
Description
The Raspberry Pi senseHAT has a number of built insensors. Humidity can be accessed with this function.
ExampleCLSLOOPPRINT “Humidity”; senseHumidityREPEATEND
AssociatedsenseHeight, sensePressure, senseTemperature
Functions, Constants & Procedures
100main index
SENSELINEPurposeLights a line on the Raspberry Pi senseHAT LED matrix.
SyntaxSENSELINE(x1, y1, x2, y2)
Description
Sets the RGB values, defined by senseRGBcolour, to a lineof LEDs on the Raspberry Pi senseHAT LED matrix. Theline is displayed from x1, y1 to x2, y2.
ExampleCLSSenseRGBcolour(255,0,0)senseLine(0,0,0,7)SenseRGBcolour(0,255,0)senseLine(0,7,7,7)LOOPsenseHflipWAIT(1)SenseVflipWAIT(1)END
AssociatedsenseCls, sensePlot, senseRect, senseScroll, senseVflip,senseRGBcolour, senseGetRGB
SENSEPLOTPurposeLights an LED on the Raspberry Pi senseHAT LED matrix.
SyntaxSENSEPLOT(xpos, ypos)
Description
Sets the RGB values, defined by senseRGBcolour, to asingle LED on the Raspberry Pi senseHAT LED matrix.
ExampleCLSSenseRGBcolour(255,0,0)sensePlot(0,0)SenseRGBcolour(0,255,0)sensePlot(7,7)END
AssociatedsenseCls, senseHflip, senseRect, senseScroll, senseVflip,senseRGBcolour, senseGetRGB, senseLine
Functions, Constants & Procedures
101main index
SENSEPRESSUREPurposeReturns the value of the Raspberry Pi senseHAT airpressure sensor.
Syntaxvalue=SENSEPRESSURE
Description
The Raspberry Pi senseHAT has a number of built insensors. Air pressure can be accessed with this function.
ExampleCLSLOOPPRINT “Pressure”; sensePressureREPEATEND
AssociatedsenseHumidity, senseHeight, senseTemperature
SENSERECTPurposeLights a rectangle on the Raspberry Pi senseHAT LEDmatrix.
SyntaxSENSERECT(xpos, ypos, width, height, fill)
Description
Sets the RGB values, defined by senseRGBcolour, to arectangle of LEDs on the Raspberry Pi senseHAT LEDmatrix. The rectangle is displayed from xpos, ypos with awidth and height as specified. Fill can be either 0 for anoutline or 1 for filled in.
ExampleCLSSenseRGBcolour(255,0,0)senseRect(0,0,7,7,1)SenseRGBcolour(0,255,0)senseRect(0,0,7,7,0)END
AssociatedsenseCls, sensePlot, senseLine, senseScroll, senseVflip,senseRGBcolour, senseGetRGB
Functions, Constants & Procedures
102main index
SENSERGBCOLOURPurposeSet the Red, Green and Blue values used by a RaspberryPi senseHAT LED.
SyntaxSENSERGBCOLOUR(red, green, blue)
Description
Sets the Red, Green and Blue values to be used by thesenseHAT FUZE BASIC drawing commands.
ExampleCLSsenseRGBcolour (255, 0, 0)sensePlot (0, 0)senseRGBcolour (0, 255, 0)sensePlot (3, 3)senseRGBcolour (0, 0, 255)sensePlot (7, 7)END
AssociatedsenseCls, sensePlot, senseRect, senseScroll, senseHFlip,senseVflip, senseLine, senseGetRGB
SENSESCROLLPurposeScrolls the Raspberry Pi senseHAT LED matrix.
SyntaxSENSESCROLL(direction, direction)
DescriptionShifts the Raspberry Pi senseHAT LED matrix in thespecified direction by the number of pixels indicated.
ExamplesenseCLSsensePlot (2, 2)sensePlot (2, 3)LOOPSenseScroll (0, 2) // two upWAIT(0.1)SenseScroll (2, 0) // two rightWAIT(0.1)SenseScroll (0, -2) // two downWAIT(0.1)SenseScroll (-2, 0) // two leftWAIT(0.1)REPEATEND
AssociatedsenseCls, sensePlot, senseRect, senseRGBcolour,senseHFlip, senseVflip, senseLine, senseGetRGB
Functions, Constants & Procedures
103main index
SENSETEMPERATUREPurposeReturns the value of the Raspberry Pi senseHAT heatsensor.
Syntaxvalue=SENSETEMPERATURE
Description
The Raspberry Pi senseHAT has a number of built insensors. Temperature, in degrees, can be accessed withthis function.
ExampleCLSLOOPPRINT “Temperature”; senseTemperatureREPEATEND
AssociatedsenseHumidity, senseHeight, sensePressure
SENSEVFLIPPurposeVertically flips the Raspberry Pi senseHAT LED matrix.
SyntaxSENSEHFLIP
Description
Reverses (flips) the LED matrix display vertically.
ExampleCLSSenseRGBcolour(255,0,0)senseLine(0,0,0,7)SenseRGBcolour(0,255,0)senseLine(0,7,7,7)LOOPsenseHflipWAIT(1)SenseVflipWAIT(1)END
AssociatedsenseCls, sensePlot, senseRect, senseScroll, senseVflip,senseRGBcolour, senseGetRGB, senseLine
Functions, Constants & Procedures
104main index
SETCHANVOLPurposeSet the volume of a sound sample.
SyntaxSETCHANVOL(channel,volume)
DescriptionSets the sound sample playback volume on the specifiedchannel where volume is a percentage of the maximum(0-100)
Examplechannel=0chomp=LOADSAMPLE("pacman_chomp.wav")FOR volume=10 TO 100 STEP 10 LOOP
SETCHANVOL(channel,volume)PLAYSAMPLE(chomp,0,0)WAIT(1)
REPEATEND
AssociatedLOADSAMPLE, PAUSECHAN, PLAYSAMPLE, RESUMECHAN,STOPCHAN
SETMODEPurposeSet display width and height
SyntaxSETMODE( width, height )
DescriptionSets the display width and height to the specified. It isgenerally sensible to use standard screen display sizes
ExampleSETMODE( 1280, 720 )PRINT "Hello World"WAIT( 2 )SETMODE( 640, 480 )PRINT "Hello Another World"END
AssociatedGHEIGHT, GWIDTH
Functions, Constants & Procedures
105main index
SETMOUSEPurposeMove the mouse pointer to the specified point.
SyntaxSETMOUSE(xpos,ypos)
DescriptionMoves the mouse pointer to the screen coordinate (xpos,ypos)
ExampleCLSMOUSEONCOLOUR=WHITERECT(100,100,150,50,TRUE)INK=BLACKPAPER=WHITEPRINTAT(7,38); PRINT "Click Me"UPDATEClicked=FALSELOOPGETMOUSE(X,Y,Z)IF Z <> 0 THENIF (X > 100 AND X < 250) THEN
IF (Y > 100 AND Y < 150) THENClicked=TRUE
ENDIFENDIF
ENDIFREPEAT UNTIL ClickedSETMOUSE(GWIDTH/2,GHEIGHT/2)END
AssociatedGETMOUSE, MOUSEOFF, MOUSEON, MOUSEX, MOUSEY
SETMUSICVOLPurposeSets the music playback volume.
SyntaxSETMUSICVOL(level)
DescriptionSets the music playback volume where level is apercentage of the maximum (0-100)
Examplehandle=LOADMUSIC("takeoff.wav")SETMUSICVOL(70)PLAYMUSIC(handle,1)
AssociatedLOADMUSIC, PAUSEMUSIC, RESUMEMUSIC, STOPMUSIC
Functions, Constants & Procedures
106main index
SETSPRITEALPHAPurposeSets the transparency of a sprite
SyntaxSETSPRITEALPHA( sprite, alpha )
DescriptionSets how transparent a sprite is. An alpha of 0 means it'sinvisible and 255 means it's completely opaque, or solid.
Examplepic = NEWSPRITE( 1 )LOADSPRITE( "/usr/share/fuze/logo.bmp",pic, 0 )FOR alpha = 0 TO 255 LOOPSETSPRITEALPHA( pic, alpha )PLOTSPRITE( pic, GWIDTH / 2, GHEIGHT / 2, 0)UPDATEREPEATEND
AssociatedGETSPRITEH, GETSPRITEW, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITEANGLE, SETSPRITEFLIP,SETSPRITEORIGIN, GETSPRITEX, GETSPRITEY
SETSPRITEANGLEPurposeRotate a sprite to the given angle
SyntaxSETSPRITEANGLE( sprite, angle )
DescriptionUse to rotate the specified sprite to the given angle indegrees. 0 is default.
Examplepic = NEWSPRITE( 1 )LOADSPRITE( "/usr/share/fuze/logo.bmp",pic, 0 )FOR angle = 0 TO 360 LOOPSETSPRITEANGLE( pic, angle )PLOTSPRITE( pic, GWIDTH / 2, GHEIGHT / 2, 0)UPDATEREPEATEND
AssociatedGETSPRITEH, GETSPRITEW, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITESIZE, SETSPRITEFLIP,SETSPRITEORIGIN, GETSPRITEX, GETSPRITEY
Functions, Constants & Procedures
107main index
SETSPRITEFLIPPurposeMirror a sprite in the specified direction
SyntaxSETSPRITEFLIP( sprite, flip )
DescriptionGraphically mirrors (flips) the specified sprite.
0 Reset to default1 mirrored vertically2 mirrored horizontally3 mirrored vertically & horizontally
Examplepic = NEWSPRITE( 1 )LOADSPRITE("/usr/share/fuze/logo.bmp",pic, 0)PLOTSPRITE(pic, gWidth / 2, gHeight / 2, 0)FOR a=3 TO 0 step -1 LOOPSETSPRITEFLIP( pic, a )UPDATEWAIT( 1 )REPEAT
AssociatedGETSPRITEH, GETSPRITEW, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITEANGLE, SETSPRITESIZE,SETSPRITEORIGIN, GETSPRITEX, GETSPRITEY
SETSPRITEORIGINPurposeSets the anchor point of a sprite
SyntaxSETSPRITEorigin( sprite, xpos, ypos )
DescriptionUse to set the origin of a specified sprite. When plotting asprite its default origin is bottom left. You can change this toany point on the sprite. This example sets it to the middle.
Examplepic = NEWSPRITE( 1 )LOADSPRITE( "logo.png", pic, 0 )LOOPSETSPRITEORIGIN( pic, 0, 0 )Plotsprite( pic, 0, 0, 0)UpdateWait(1)MiddleX=GETSPRITEW(pic)/2MiddleY=GETSPRITEH(pic)/2SETSPRITEORIGIN( pic, MiddleX, MiddleY )PLOTSPRITE( pic, 0, 0, 0)UPDATEREPEAT
AssociatedGETSPRITEH, GETSPRITEW, LOADSPRITE, NEWSPRITE, PLOTSPRITE,SETSPRITEANGLE, SETSPRITEFLIP, SETSPRITESIZE, GETSPRITEX, GETSPRITEY
Functions, Constants & Procedures
108main index
SETSPRITESIZEPurposeChange the size of a sprite
SyntaxSETSPRITESIZE( sprite, size )
DescriptionSets the sprite to the specified size in percent. 100 is thedefault, therefore 50 is half the size and 300 is three timesas big as the original.
Examplepic = NEWSPRITE( 1 )LOADSPRITE("/usr/share/fuze/logo.bmp",pic, 0)FOR angle = 50 TO 200 LOOPSETSPRITESIZE( pic, size )PLOTSPRITE( pic, GWIDTH / 2, GHEIGHT / 2, 0)UPDATEREPEATEND
AssociatedGETSPRITEH, GETSPRITEW, LOADSPRITE, NEWSPRITE,PLOTSPRITE, SETSPRITEANGLE, SETSPRITEFLIP,SETSPRITEORIGIN, GETSPRITEX, GETSPRITEY
SETSPRITETRANSPurposeSet a transparency colour for a given sprite and its sub-sprites.
SyntaxSETSPRITETRANS(spriteId, Red, Green, Blue)
DescriptionIf you specify a transparency colour for a sprite then anypixels in the sprite that are this colour will be transparenti.e. They will show as the background colour. This allows asprite to pass over a background image without blocking itout. You need to load the sprite files first before settingthe transparency colour.
Example (overleaf)
Functions, Constants & Procedures
109main index
SETSPRITETRANS Example
CLSRGBCOLOUR(247, 247, 247)RECT(50, 50, 101, 101, TRUE)COLOUR = YELLOWCIRCLE(100, 100, 50, TRUE)SAVEREGION("s3.bmp", 50, 50, 101, 101)CLS2COLOUR = REDMidY = GHEIGHT / 2FOR X = 0 TO GWIDTH STEP 100 LOOP
RECT(X, MidY - 50, 50, 200, TRUE)REPEATCOLOUR = Blacks1 = NEWSPRITE(1)LOADSPRITE("s3.bmp", s1, 0)SETSPRITETRANS(s1, 247, 247, 247)FOR X = 0 TO gWidth STEP 10 LOOP
PLOTSPRITE(s1, X, GHEIGHT / 2, 0)UPDATEWAIT (0.0005)
REPEATEND
AssociatedGETSPRITEH, GETSPRITEW, LOADSPRITE, NEWSPRITE,PLOTSPRITE, RGBCOLOUR
SGETPurposeRead a byte from a serial port.
Syntaxbyte=SGET(handle)
DescriptionFetch a single byte of data from an open serial port andreturn the data as a number. This function will pauseprogram execution for up to 5 seconds if no data isavailable. If there is still not data after 5 seconds, thefunction will return -1.
ExampleREM Read a byte from a serial portarduino=SOPEN("/dev/ttyUSB0", 115200)byte=SGET(arduino)PRINT byteSCLOSE(arduino)END
AssociatedSCLOSE, SGET$, SOPEN, SPUT, SPUT$, SREADY
Functions, Constants & Procedures
110main index
SGET$PurposeRead a character from a serial port.
Syntaxcharacter=SGET$(handle)
DescriptionFetch a single byte of data from an open serial port andreturn the data as a single character string. This functionwill pause program execution for up to 5 seconds if nodata is available. If there is still not data after 5 seconds,the function will return an empty string.
ExampleREM Read a character from a serial portarduino=SOPEN("/dev/ttyUSB0", 115200)char$=SGET$(arduino)PRINT char$SCLOSE(arduino)END
AssociatedSCLOSE, SGET, SOPEN, SPUT, SPUT$, SREADY
SGNPurposeReturns the sign of the specified number.
Syntaxsign=SGN(number)
DescriptionReturns -1 if the number is negative, 1 otherwise. (Zero isconsidered positive)
ExampleREM Prints 1PRINT SGN(100)PRINT SGN(0)REM Print -1PRINT SGN(-5)END
AssociatedABS
Functions, Constants & Procedures
111main index
SHOWKEYSPurposeList the function key definitions
SyntaxSHOWKEYS
DescriptionIt is possible to set the 12 function keys at the top of thekeyboard to user defined values. This command will showwhat the current definitions are. By default function keyF2 is defined to enter the EDIT command and F3 the RUNcommand but it is possible to overwrite these.
ExampleREM Set key F5 to clear screenkeyF5$ = "CLS\n"SHOWKEYS
SINPurposeReturns the sine of the given angle.
Syntaxsine=SIN(angle)
DescriptionReturns the sine of the argument angle in radians. This isthe ratio of the side of a right angled triangle, that isopposite to the angle, to the hypotenuse (the longestside).
ExampleREM Draw an ellipse in the screen centreCLSDEGFOR Angle=0 TO 360 LOOP
Xpos=100*COS(Angle)+GWIDTH/2Ypos=50*SIN(Angle)+GHEIGHT/2PLOT(Xpos,Ypos)
REPEATEND
AssociatedASIN, ATAN, COS
Functions, Constants & Procedures
112main index
SOFTPWMWRITEPurposeSynthesize Pulse Wave Modulation to the specified GPIOpin.
SyntaxSOFTPWMWRITE(pinNo,value)
DescriptionThis enables you to simulate an analog output. For exampleinstead of an LED being just on or off you can make it appearbrighter or dimmer. The pinNo parameter is the number of theGPIO output pin. This must first be set to pinSoftPwm. Thevalue parameter is a percentage (0-100).
ExampleREM Connect an LED to GPIO pin 0PINMODE (0, PINSOFTPWM)FOR I=0 TO 100 LOOP
SOFTPWMWRITE (0,I)WAIT(0.1)
REPEATFOR I=100 to 0 STEP -1 LOOP
SOFTPWMWRITE (0,I)WAIT(0.1)
REPEATEND
AssociatedPINMODE
SOPENPurposeOpens a serial device and makes it available for use.
Syntaxhandle=SOPEN($device,speed)
DescriptionThis opens a serial device and makes it available for ouruse. It takes the name of the serial port and the speed asan argument and returns a number (the handle) of thedevice. We can use this handle to reference the deviceand allow us to open several devices at once.The following baud rates are recognised: 50, 75, 110, 134,150,200, 300, 600, 1200, 1800, 2400, 19200, 3840057600, 115200 and 230400, but do check your local PCand devices capabilities. The device is always opened withthe data format set to 8 data bits, 1 stop bit and no parity.All handshaking is turned off.
ExampleREM Read a byte from a serial portarduino=SOPEN("/dev/ttyUSB0", 115200)byte=SGET(arduino)SCLOSE(arduino)END
AssociatedSCLOSE, SGET, SGET$, SPUT, SPUT$, SREADY
Functions, Constants & Procedures
113main index
SOUNDPurposePlay a synthesised sound with the specified parameters(emulates BBC BASIC SOUND command).
Syntaxsound(channel,amplitude,pitch,duration)
DescriptionThe channel is 0 to 3 with 0 being for white noise (static). Theamplitude goes from 0 to -15 where 0 is silent and -15 is fullvolume (-7 being half volume and so on). The duration is in20ths of a second, so 20 represents one second, 10 half asecond and so on. The pitch values are taken from a tablewhich can be found at the end of the manual but, middle C hasa value of 53 and each note is 4 away from the next. Note thatwhen used with a sound envelope amplitude is replaced bythe envelope number.
ExampleChannel=1Volume=-10FOR Note=1 TO 5 LOOP
READ Frequency,DurationSOUND(Channel,Volume,Frequency,Duration)
REPEATENDDATA 89, 20, 97, 20, 81, 20, 33, 20, 61, 40
AssociatedENVELOPE, TONE
SPACE$PurposeReturns a blank string of the specified length.
Syntaxblankstring=SPACE$(number)
DescriptionReturns a string of blank spaces number characters long.
ExampleBlank$ = SPACE$(100)FOR I=1 TO 20 LOOP
PRINT Blank$REPEATEND
Functions, Constants & Procedures
114main index
SPRITECOLLIDEPurposeDetect a sprite collision (fast bounding box)
Syntaxcollision=SPRITECOLLIDE(target)
DescriptionReturns the sprite index of the first sprite that the spriteindex target has collided with, or -1 if there is no collision.It only checks the current sprite location and this is onlyupdated after a screen update LOOP so it is possible to callPLOTSPRITE() and have a sprite overlap but it not bedetected until after the update has happened on screen.
ExampleCLSRGBCOLOUR(254,254,254)RECT(50,50,101,101,TRUE)COLOUR=YELLOWCIRCLE(100,100,50,TRUE)SAVEREGION("s1.bmp",50,50,101,101)COLOUR=REDCIRCLE(100,100,50,TRUE)SAVEREGION("s2.bmp",50,50,101,101)CLS2s1=NEWSPRITE(1)s2=NEWSPRITE(1)LOADSPRITE("s1.bmp",s1,0)LOADSPRITE("s2.bmp",s2,0)FOR X=0 TO GWIDTH STEP 1 LOOP
PLOTSPRITE(s1,X,200,0)PLOTSPRITE(s2,GWIDTH-X-100,200,0)IF SPRITECOLLIDE (s2) <> -1 THEN BREAKUPDATEWAIT(0.0005)
REPEATEND
AssociatedGETSPRITEH, GETSPRITEW, HIDESPRITE, LOADSPRITE,NEWSPRITE, PLOTSPRITE, SPRITECOLLIDEPP
Functions, Constants & Procedures
115main index
SPRITECOLLIDEPPPurposeDetect a sprite collision (pixel perfect)
Syntaxcollision=SPRITECOLLIDEPP(target,accuracy)
DescriptionThis is a slower but more accurate version of SpriteCollide.It first does do a simple bounding box test then checksrow at a time. The accuracy parameter is how many pixelsto skip both horizontally and vertically. This is from 1 to16, where 1 is "perfect" and greater than 1 is lessaccurate, but faster. This will affect the amount of visibleoverlap you get before a collision is detected.
ExampleCLSRECT(50,50,101,101,TRUE)COLOUR=YELLOWCIRCLE(100,100,50,TRUE)SAVEREGION("s1.bmp",50,50,101,101)COLOUR=REDCIRCLE(100,100,50,TRUE)SAVEREGION("s2.bmp",50,50,101,101)CLS2s1=NEWSPRITE(1)s2=NEWSPRITE(1)LOADSPRITE("s1.bmp",s1,0)LOADSPRITE("s2.bmp",s2,0)FOR X=0 TO GWIDTH STEP 1 LOOP
PLOTSPRITE(s1,X,200,0)PLOTSPRITE(s2,GWIDTH-X-100,200,0)IF SPRITECOLLIDEPP(s2,1) <> -1 THEN BREAKUPDATE
REPEATEND
AssociatedGETSPRITEH, GETSPRITEW, HIDESPRITE, LOADSPRITE,NEWSPRITE, PLOTSPRITE, SPRITECOLLIDE
Functions, Constants & Procedures
116main index
SPRITEOUTPurposeFind out if a sprite is off screen
Syntaxresult = SPRITEOUT( sprite )
DescriptionIf the sprite is off screen then result is true otherwise it isfalse.
Examplepic = NEWSPRITE( 1 )LOADSPRITE("/usr/share/fuze/logo.bmp",pic, 0)PLOTSPRITE( pic, GWIDTH / 2, GHEIGHT / 2, 0)WHILE NOT SPRITEOUT( pic ) LOOPADVANCESPRITE( pic, 2 )UPDATEREPEATPRINT "GONE!"END
AssociatedHIDESPRITE, PLOTSPRITE
SPUTPurposeSend a byte to an open serial port.
SyntaxSPUT(arduino,byte)
DescriptionSend a single byte of data to an open serial port.
ExampleREM Write a byte to a serial portarduino=SOPEN("/dev/ttyUSB0", 115200)SPUT(arduino,52)SPUT(arduino,50)SCLOSE(arduino)END
AssociatedSCLOSE, SGET, SGET$, SOPEN, SPUT$, SREADY
Functions, Constants & Procedures
117main index
SPUT$PurposeSend a character string to an open serial port.
SyntaxSPUT$(arduino,string)
DescriptionSend a string of characters of data to an open serial port.
ExampleREM Write a byte to a serial portarduino=SOPEN("/dev/ttyUSB0", 115200)SPUT$(arduino,"Hello")SCLOSE(arduino)END
AssociatedSCLOSE, SGET, SGET$, SOPEN, SPUT, SREADY
SQRTPurposeReturn the square root of the specified number.
Syntaxsquareroot=SQRT(number)
DescriptionReturns the square root of the argument number. This isthe opposite of multiplying a number by itself i.e. X =SQRT(X * X)
Examplefoursquared=4*4PRINT SQRT(foursquared)END
Functions, Constants & Procedures
118main index
SREADYPurposeGet the number of characters available to be read on anopen serial port.
Syntaxcount=SREADY(handle)
DescriptionReturns the number of characters available to be readfrom an open serial port. This can be used to poll thedevice to avoid stalling your program when there is nodata available to be read.
ExampleREM Read a character from a serial portarduino=SOPEN("/dev/ttyUSB0", 115200)IF SREADY(arduino) THEN
char$=SGET$(arduino)PRINT char$
ENDIFSCLOSE(arduino)END
AssociatedSCLOSE, SGET, SGET$, SOPEN, SPUT, SPUT$
STOPPurposeStop a running program.
SyntaxSTOP
DescriptionProgram execution is stopped with a message indicatingthe current line number.
ExampleINPUT "Enter the Password: ", pass$IF pass$<>"wibble" THEN
PRINT "Password Incorrect"STOP
ENDIFPRINT "Password Correct"END
AssociatedCONT
Functions, Constants & Procedures
119main index
STOPCHANPurposeStop the playing of a sound sample.
SyntaxSTOPCHAN(handle)
DescriptionThis function stops the playing of the sound sampleassociated with the handle returned by LOADSAMPLE thathas been started using PLAYSAMPLE. It cannot be resumedonce stopped.
Examplechannel=0volume=70SETCHANVOL(channel,volume)intro=LOADSAMPLE("pacman_intro.wav")PLAYSAMPLE(intro,channel,0)WAIT(3)STOPCHAN(intro)END
AssociatedLOADSAMPLE, PAUSECHAN, PLAYSAMPLE, RESUMECHAN,SETCHANVOL
STOPMUSICPurposeStop music playing completely.
SyntaxSTOPMUSIC
DescriptionStops a playing music track which cannot then beresumed.
Examplehandle=LOADMUSIC("takeoff.wav")SETMUSICVOL(70)PLAYMUSIC(handle,1)STOPMUSIC
AssociatedLOADMUSIC, PAUSEMUSIC, RESUMEMUSIC,SETMUSICVOL
Functions, Constants & Procedures
120main index
STR$PurposeReturns a string version of the supplied number.
Syntaxstring$=STR$(number)
DescriptionReturns a string in the decimal (base 10) representation ofnumber. This is useful if you want to append a number toa string. This is the opposite of the VAL function.
ExamplePRINT "The Answer is "+STR$(42)END
AssociatedVAL
SWAPPurposeSwap the value of two variables.
SyntaxSWAP(value1,value2)
DescriptionThis swaps the value of the 2 variables round. Botharguments must be the same type - i.e. Both numeric orboth string.
Examplelowest=99highest=0IF lowest>highest THEN
SWAP(highest,lowest)ENDIFPRINT "Lowest "; lowestPRINT "Highest ";highestEND
Functions, Constants & Procedures
121main index
SWITCHPurposeTest a value against many different values and executedifferent code.
SyntaxSWITCH (variable)
{ CASE value {, value }commands
ENDCASE }[ DEFAULT
commandsENDCASE ]
ENDSWITCH
DescriptionSimplify the writing of multiple IF. . . THEN. . . ELSEstatements. Rules• Every SWITCH must have a matching ENDSWITCH.• Every CASE or DEFAULT statement must have amatching ENDCASE.• Statements after a CASE statement must not run-intoanother CASE.• The constants after the CASE statement (and theexpression in the SWITCH statement) can be eithernumbers or strings, but you can’t mix both.
ExampleINPUT aSWITCH(a)
CASE 1,2PRINT "You entered 1 or 2"
ENDCASECASE 7
PRINT "You entered 7"ENDCASEDEFAULT
PRINT "You entered something else"ENDCASE
ENDSWITCHEND
AssociatedELSE, IF THEN
Functions, Constants & Procedures
122main index
TANPurposeReturn the tangent of the given angle.
Syntaxtangent=TAN(angle)
DescriptionReturns the tangent of the angle in the current angleunits. In a right-angled triangle the tangent of an angle isthe ratio of the length of the opposite side to the lengthof the adjacent side. This is a measure of the steepness ofan angle.
ExampleDEGPRINT "Tangent of 45 degrees: "; TAN(45)PRINT "ArcTangent of 1: "; ATAN(1)END
AssociatedACOS, ASIN, ATAN, COS
TANGLEPurposeRead or set the current angle of the turtle.
Syntaxangle=TANGLETANGLE=angle
DescriptionThis can be read or assigned to and represents the currentangle of the turtle when using turtle graphics mode (in thecurrent angle units)
ExampleCLSORIGIN(GWIDTH/2,GHEIGHT/2)CLOCKFOR I = 1 TO 60 LOOP
TANGLE = IMOVETO(0,0)PENDOWNMOVE(100)
REPEATEND
AssociatedLEFT, MOVE, MOVETO, PENDOWN, PENUP, RIGHT
Functions, Constants & Procedures
123main index
THEIGHTPurposeThe height in characters of the display.
Syntaxheight=THEIGHT
DescriptionThe height in characters of the display.
ExampleCLStext$="This text is centred in the screen"HVTAB((TWIDTH-LEN(text$))/2,THEIGHT/2)PRINT text$END
AssociatedTWIDTH
TIMEPurposeFind out how long the program has been running.
Syntaxtime=TIME
DescriptionThis returns a number which represents the time thatyour program has been running in milliseconds.
ExampleREM Simple reaction timerWAIT(2)REM Make sure no key pressedWHILE INKEY<>-1 LOOPREPEATstime=TIMEPRINT "Go!"WHILE INKEY=-1 LOOPREPEATetime = TIMEPRINT "Your reaction time is ";PRINT etime-stime; " milliseconds"END
Functions, Constants & Procedures
124main index
TONEPurposePlay a tone with the specified parameters.
SyntaxTONE(channel,volume,frequency,duration)
DescriptionThis plays a simple tone of the given frequency (1 to5000Hz), volume (%) and duration (0.01 to 20 seconds) onthe given channel.You can play multiple tones by playing them one after theother and up to three tones can be played simultaneouslyon different channels.Channel 0 is white noise and the frequency has no bearingon the sound produced.
ExampleChannel=1Volume=70FOR Note=1 TO 5 LOOP
READ Frequency,DurationTONE(Channel,Volume,Frequency,Duration)
REPEATENDDATA 440, 1, 493, 1, 392, 1, 196, 1, 294 ,2
AssociatedSOUND
TIME$PurposeReturns a string with the current time.
Syntaxnow$=TIME$
DescriptionThis returns a string with the current time in the followingformat: HH:MM:SS. For example: 18:05:45.
ExamplePRINT "The time now is ";PRINT TIME$END
AssociatedDATE$
Functions, Constants & Procedures
125main index
TRIANGLEPurposeDraw a triangle on the screen.
SyntaxTRIANGLE (xpos1, ypos1, xpos2, ypos2,xpos3, ypos3, fill)
DescriptionDraws a triangle with its corners at the three given points.The final parameter, fill is either TRUE or FALSE, andspecifies filled (TRUE) or outline (FALSE).
ExampleLOOP
COLOUR=RND(16)x1=RND(GWIDTH)x2=RND(GWIDTH)x3=RND(GWIDTH)y1=RND(GHEIGHT)y2=RND(GHEIGHT)y3=RND(GHEIGHT)f=RND(2)TRIANGLE (x1,y1,x2,y2,x3,y3,f)UPDATEIF INKEY<>-1 THEN BREAK
REPEATEND
AssociatedCIRCLE, ELLIPSE, RECT
TRUEPurposeRepresents the logical "true" value.
SyntaxTRUE
DescriptionRepresents a Boolean value that succeeds a conditionaltest. It is equivalent to a numeric value of 1 (in factanything other than 0 evaluates to TRUE)
Examplecondition=TRUEIF condition=TRUE THEN
PRINT "Condition is TRUE"ENDIFPRINT conditionEND
AssociatedFALSE
Functions, Constants & Procedures
126main index
TWIDTHPurposeThe width in characters of the display.
Syntaxwidth=TWIDTH
DescriptionThe width in characters of the display.
Exampletext$="This text is centred horizontally"HTAB=(TWIDTH-LEN(text$))/2PRINT text$END
AssociatedTHEIGHT
UPDATEMODEPurposeSet the video update mode.
SyntaxUPDATEMODE=mode
Description (overleaf)
Functions, Constants & ProceduresUPDATEMODE DescriptionThe updateMode determines when the screen is redrawn.Redrawing the screen takes a little time and will slowdown a program if you do it too often. The value of themode parameter can be 0, 1, or 2 as follows:0- automatic updates do not happen. Nothing will bedrawn on the screen until the UPDATE command is issued.1-This is the default mode whereby an UPDATE happensautomatically when you output a new line, or the screenscrolls.2-The screen is updated after every PRINT instructionwhether it takes a new line or not.
ExampleCLSINPUT "Update Mode? ",modeIF mode>=0 AND mode<=2 THEN
PRINT "Press space to exit"WAIT(1)UPDATEMODE=modeLOOP
PRINT "Hello World ";REPEAT UNTIL INKEY=32UPDATE
ELSEPRINT "Invalid Update Mode"
ENDIFWAIT(1)END
AssociatedUPDATE
127main index
UNTIL REPEATPurposeLoop until the specified condition is met.
SyntaxUNTIL condition LOOP
{statements}REPEAT
DescriptionExecute the statements zero or more times until thecondition is TRUE (Not 0).Because the test is done at the start of the loop thestatements may not be executed at all
ExampleREM Print 1 to 10count=1UNTIL count>10 LOOP
PRINT countcount=count + 1
REPEATEND
AssociatedBREAK, CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT,REPEAT UNTIL, WHILE REPEAT
UPDATEPurposeUpdate screen graphics.
SyntaxUPDATE
DescriptionGraphics are drawn to a temporary screen buffer ratherthan the visible screen. The UPDATE command copies theworking area to the main display. An update is alsoperformed if your program stops for input, or when youPRINT a new line.ExampleREM Moire patternsLOOP
CLSCOLOUR=RND(15)+1x=RND(GWIDTH)y=RND(GHEIGHT)FOR w=0 TO GWIDTH-1 STEP 3 LOOP
LINE(x,y,w,0)LINE(x,y,w,GHEIGHT-1)
REPEATFOR h=0 TO GHEIGHT-1 STEP 3 LOOP
LINE(x,y,0,h)LINE(x,y,GWIDTH-1,h)
REPEATUPDATE
REPEATEND
AssociatedUPDATEMODE
Functions, Constants & Procedures
128main index
VALPurposeReturns the number represented by a character string.
Syntaxnumber=VAL(string$)
DescriptionReturns the number represented by string$. This is theopposite of the STR$ function.
Examplenow$ =TIME$hh=VAL(LEFT$(now$, 2))mm=VAL(MID$(now$, 3, 2))ss=VAL(RIGHT$(now$, 2))elapsed=hh*3600+mm*60+ssPRINT "Seconds since midnight: "; elapsedEND
AssociatedSTR$
VLINEPurposeDraws a vertical line.
SyntaxVLINE (ypos1,ypos2,xpos)
DescriptionDraws a vertical line on column xpos, from row ypos1 torow ypos2.
ExampleCLSCOLOUR=redFOR xpos=0 TO GWIDTH STEP 100 LOOP
VLINE(0, GHEIGHT, xpos)REPEATUPDATEEND
AssociatedHLINE, LINE, LINETO
Functions, Constants & Procedures
129main index
VTABPurposeSet/Read the current text cursor vertical position.
SyntaxVTAB=valuevalue=VTAB
DescriptionSet/Read the current text cursor vertical position.
ExampleCLSFOR ypos = 0 TO THEIGHT LOOP
VTAB=yposPRINT VTAB
REPEATVTAB=0END
AssociatedHTAB, HVTAB
WAITPurposeWaits for the specified time to elapse.
SyntaxWAIT(time)
DescriptionThis waits (does nothing) for time seconds. This may be afractional number, but the accuracy will depend on thecomputer you are running it on, however delays down to1/100th of a second should be achievable.
ExampleREM COUNT 10 SecondsCLSSeconds = 0FOR I=1 TO 10 LOOP
WAIT(1)Seconds=Seconds + 1HVTAB(10,10)PRINT Seconds
REPEATPRINT "Elapsed "; TIME/1000END
Functions, Constants & Procedures
130main index
WHILE REPEATPurposeLoop while the specified condition is met.
SyntaxWHILE condition LOOP
{statements}REPEAT
DescriptionExecute the statements zero or more times while the conditionis TRUE (Not 0). Because the test is done at the start of the loopthe statements may not be executed at all.
Examplehandle=OPEN("whiletest.txt")FOR r=0 TO 10 LOOP
PRINT# handle,"Record ";rREPEATCLOSE(handle)handle = OPEN("whiletest.txt")WHILE NOT EOF(handle) LOOP
INPUT# handle, record$PRINT record$
REPEATCLOSE (handle)END
AssociatedBREAK, CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT,REPEAT UNTIL, UNTIL REPEAT
Functions, Constants & Procedures
listGamepadsImmediate mode only. Displays a list of connecteddevices.
numButtons( gamepad )Returns the number of buttons on a specified device
numAxes( gamepad )Returns the number of analog axis on a specified device
numHats( gamepad )Returns the number of HATS on a specified device
numGamepadsReturns the number of devices connected
getAxis( gamepad, axis )Returns the value of a given axis on a specified device
getButton( gamepad, button )Returns the value of a given button on a specified device
getHat( gamepad, hat )Returns the value of a given HAT on a specified device
SetupGamepad( gamepad )Configure a specified device
Joystick and Gamepad commands
131
132main index
scanBackspacescanTabscanClearscanReturnscanPausescanEscapescanSpacescanExclaimscanQuoteDblscanHashscanDollarscanAmpersandscanQuotescanLeftParenscanRightParenscanAsteriskscanPlusscanCommascanMinusscanPeriodscanSlashscan0
scanAscanBscanCscanDscanEscanFscanGscanHscanIscanJscanKscanLscanMscanNscanOscanPscanQscanRscanSscanTscanUscanV
scanDownscanRightscanLeftscanInsertscanHomescanEndscanPageupscanPagedownscanF1scanF2scanF3scanF4scanF5scanF6scanF7ScanF8scanF9scanF10scanF11scanF12scanF13scanF14ScanF15scanNumLock
scanCapsLockscanScrolLockscanRShiftscanLShiftscanRCtrlscanLCtrlscanRAltscanLAltscanRMetascanLMetascanLSuperscanRSuperscanModescanComposescanHelpscanPrintscanSysReqscanBreakscanMenuscanPowerscanEuroscanUndo
ScanKeyboard values
scan1scan2scan3scan4scan5scan6scan7scan8scan9scanColonscanSemiColonScanLessScanEqualsscanGreaterscanQuestionscanAtscanLeftBracketscanBackSlashscanRightBracketscanCaretScanUnderscorescanBackQuote
scanVscanWscanXscanYScanZscanDeletescanKP0scanKP1scanKP2scanKP3scanKP4scanKP5scanKP6scanKP7scanKP8scanKP9scanKpPeriodscanKpDividescanKpMultiplyscanKpMinusscanKpPlusScanKpEnterScanKpEqualsscanUp
133main index
Notes & Octaves for Sound function
Octave NumberNote 1 2 3 4 5 6 7
B 0 49 97 145 193 241A# 0 45 93 141 189 237
A 41 89 137 185 233G# 37 85 133 181 229
G 33 81 129 177 225F# 29 77 125 173 221
F 25 73 121 169 217E 21 69 117 165 213
D# 17 65 113 161 209D 13 61 109 157 205 253
C# 9 57 105 153 201 249C 5 53 101 149 197 245
fuze.co.uk
FUZE BASICProgrammer’s reference guide£14.99 / $24.99 / €21.99
FUZE BASICProgrammer’s Reference Guide