This file is for use as quick reference for the NaaLaa programming language. 

This is a partial list. For more see: Program Files(x86)/NaaLaa Creator/NaaLaa 5/doc (Windows)


Get NaaLaa at:    http://www.naalaa.com/




set window 0, 0, 1200, 700, true, 1    rem this piece of code starts a program. I usually declare variables before this.

set redraw off

set color 25, 25, 60

cls

 redraw

set color 100, 0, 200


.........

   

         wait keydown               

         end                                    

 rem   add functions here.


                                THREE TYPES OF VARIABLES


rem int_variable = <integer expression>                         a

rem float_variable# = <floating point expression>          b#

rem string_variable$ = <string expression>                    c$

visible:     this statement makes varibles visible to subprograms


                             VARIABLE CONVERSIONS


a =  int(float_expr#)       a = int(string_expr$)         

b# = float#(int_expr)      b = float#(string_expr$)

c$ = str$(int_expr)         c$ = str$(float_expr#)




                               INPUT / OUTPUT


set caret x, y   This sets the position of the caret used for the next win statement.


wln             This is the print comand (basic) --  In this case it works on the graphics

               screen instead of the console; Much more useful.

write           Same as wln, except no line break


a = rin ( max )        input from keyboard to integer   max = maximum number of characters

b# = rin (max)        input from keyboard to float

c$ = rin (max)        input from keyboard to String 


a = inkey()       integer value of pressed key

c$ = chr$(a)    String value of integer a

a = asc(c$)      integer value of first letter of c$


                                      LOOPS AND PROCEDURES


procedure  dothis( a,b)               rem All variable are local

          wln a

                  wln b 

endproc


function stuff# ( a#,b#)

   statement

   ...

   return b#

 endfunc

d# = stuff# ( 3.1, 4.2)


while a< 10                         rem  variables b and c not changed

       dothis(b,c)                   rem   print b and c

       a=a+1

wend


a = 0

do

wln "   a is ", a, " and not 3"

a = a + 1

until a = 3


for a = 0 to 3

wln "   a is ", a

next


wln "for/downto/next:"

for a = 3 downto 0

wln "   a is ", a

next


do

wln "   I loop until someone gives me a break"

a = a + 1

if a = 4 then break

loop


if a = b then  .... do this (one statement)


if a > b  

     ....

     ....

endif


if a < b 

    ......

else

    ......

endif







                                       GRAPHICS


set redraw off                 take redraw off of auto mode

redraw                             causes screen to be drawn from back buffer

wait 10                             wait 10 ms     We need this after every redraw to conserve power

draw line x0, y0, x1, y1

draw pixel x, y

rect x, y, w, h[, fill]                                 rectangle will be filled if fill=true

set color r, g, b[, a]                               rgb  or  rgba

create image image_id, w, h

save image image_id, filename$

load image image_id, filename$

set image image_id

draw image image_id, x, y

hscroll dx

vscroll dy 

scroll dx, dy






                                       STRINGS


                            Basic like string functions:


len(txt$)

lower$(txt$)            make lower case

upper$(txt$)

left$(txt$, n)            return n chars of txt$

right$(txt$, n)

mid$(txt$, pos)       return character at pos

mid$(txt$, pos, n)   return n chars from start pos

instr(txt$, sub$)      return position of sub$

instr(txt$, sub$, pos)



                                        MATH


min(a, b)

min#(a#, b#)

max(a, b)

max#(a#, b#)

abs(a)

abs#(a#)

sqr#(a#)

sin#(a#)

cos#(a#)

tan#(a#)

asin#(a#)

acos#(a#)

atan#(a#)

procedure degrees        Switch between degrees  and radians for all trigonometric functions

procedure radians          default is degrees


DecToBin$(dec)

BinToDec(bin$)

DecToHex$(dec)

HexToDec(hex$)

Distance#(x1, y1, x2, y2)                                  Return the distance between two points

DistanceF#(x1#, y1#, x2#, y2#)

InvDistance#(x1, y1, x2, y2)

InvDistanceF#(x1#, y1#, x2#, y2#)

AngleTo#(src_x, src_y, dst_x, dst_y)                Return angle between two points.

AngleToF#(src_x#, src_y#, dst_x#, dst_y#)



ARRAYS


 Arrays are created by naming or using them:

      AA[ ] = [ 1,2,3,4,5]

      ab[ 5]

      ab[0] = 10

      


  

 
Make a Free Website with Yola.