⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbref.txt

📁 smallbasic for linux
💻 TXT
字号:
Generic____________________________Limits:____________________________Max. length of    code text line: 511 charsMax. keyword length: 32 charMax. num. of parameters: 64Max. arrays dimentions: 4Numeric value range: 64b FPNMax. string size: 32KBMax. number of file handles:  PalmOS: 16  Other: 256INPUT (console only)  limit: 255B per call.  up to 16 variables.Max. number of colors: 16Max. bytecode size: 64KB  (by using CHAIN you can  run progs > 64KB)Background sound queue  size: 256 notesSystem events are checkedevery 50msPalmOS:  Be careful with memory  there is no too much.____________________________Variables:____________________________There is no data types. Alluser variables (includearrays) are 'VARIANT'.SB uses internaly 3 types1. Integer (32bit)2. Real    (64bit)3. String  (<32KB)Variable names can use anyalphanumeric characters,and the '$'. The first charof the name cannot bea digit.The symbol '$' is supportedfor compatibility. Its useis meanless.Example:a="123"a$=1? a<>a$REM displays 1 (true)____________________________System Variables:____________________________OSVER  - OS VersionOSNAME - OS NameSBVER  - SmallBASIC VersionPI     - 3.14..XMAX,YMAX       graphics display max.BPP    - Bits per pixel____________________________Operators (by priority):____________________________( )       = parenthesis-         = unary^         = power* / \     = mul, div, idiv% MOD     = modulus+ -       = add, sub=> =<  = >= <= <>  = compareAND & OR  |NOT ! XOR ~          = logical:         = EOL____________________________Base convertion:____________________________&H|0x hex. ex: 0x1F + &H1F&o|0o oct. ex: 0o33 = &o33&b|0b bin. ex: 0b11 = &b11____________________________Meta-commands:____________________________#!...  Used by Unix to make  SB source runs as script  executable#sec:section name  Used internaly to store  the section name  DON'T USE IT#inc:"file"#inc:file  Used to include a SB  source file into current  BASIC codeExample:...#inc:"mylib.bas"...MyLibProc "Hi"____________________________Subroutines/Functions:____________________________SUB name  [([BYREF] par1 [,  ...[BYREF] parN)]]  [LOCAL var[, var[, ...]]]  [EXIT SUB]ENDFUNC name  [([BYREF] par1 [,  ...[BYREF] parN)]]  [LOCAL var[, var[, ...]]]  [EXIT FUNC]  name=return-valueENDUse function's nameto return the value.Nested procedures/functionsare allowed (like Pascal).Example:FUNC f(x)  FUNC f11    FUNC f21	f21=21	END  END  FUNC f12  f12=12  END? f11? f21: REM ERRORf=x+f11+fEND____________________________The parameters are 'by value' by default.Passing parameters by valuemeans the executor makesa copy of the parameter tostack. The value in caller'scode will not be changed.Use BYREF keyword forpassing parameters 'by reference'. Passing parameters byreference means theexecutor push the pointerof variable into the stack.The value in caller's codewill be the changed.Example:' 'by value'SUB F(x)x=1ENDx=2F x? x:REM displays 2' 'by reference'SUB F(BYREF x)x=1ENDx=2F x? x:REM displays 1____________________________Use the LOCAL keyword forlocal variables.LOCAL creates variables(dynamic) at routine'scode.Example:SUB MYPROCLOCAL N:REM LOCAL VARN=2? N:REM displays 2ENDN=1:REM GLOBAL VARMYPROC? N:REM displays 1____________________________You can send arrays asparameters with ().When using arrays asparameters its better to usethem as BYREF; otherwise their data will beduplicated.Example:SUB FBR(BYREF tbl())? FRE(0)...ENDSUB FBV(tbl())? FRE(0)...END' MAINDIM dt(128)...? FRE(0)FBR dt()? FRE(0)FBV dt()? FRE(0)____________________________On a multi-section applications sub/funcs needsdeclaration on the mainsection.Example:#sec:Maindeclare func f(x)#sec:another sectionfunc f(x)...end____________________________Passing & returing arrays,using local arrays.Example:func fill(a())  local b(), i  dim b(16)  for i=0 to 16    b(i)=16-a(i)  next  fill=b()endDIM v(4)v()=fill(v())____________________________Statements:____________________________'|#|REM ...Remarks.The # can be used as remarksonly in the first pos. ofthe text line.____________________________[LET] var = exprAssign 'expr' to variable'var'.Example:z=1z="Change to string"DIM v(4)v2()=v()z=v():REM make z copy of v()____________________________CONST var = exprAssign 'expr' to variable'var' and make it READ-ONLY.____________________________DIM var( [lower TO]              upper [, ...])Creates an array.____________________________[LABEL] labelDefines a label. There aretwo kinds of labels. Numericand alphanumeric.Numeric labels does not needed the keyword LABEL,but alphanumeric does.Example:1000 ? "Hello"LABEL AlphaLabel? "Hello"...GOTO 1000GOTO AlphaLabel____________________________GOTO labelBranches to a specifiedlabel.____________________________GOSUB label - RETURNBranches to an old-stylesubroutine. The subroutinereturns to GOSUB's nextinstruction with RETURN.____________________________ON expr GOTO label-listON expr GOSUB label-listBranches to one of the several locations, dependingof the value of the 'expr'.____________________________FOR var = expr TO expr         [STEP expr] - NEXTRepeats a code block fora specified number of times.____________________________WHILE expr - WENDWHILE/WEND code block, loopswhile 'expr' is true.____________________________REPEAT - UNTIL exprREPEAT/UNTIL code block, loops while 'expr' is false.____________________________IF expr  [THEN] -         [ELSE|ELIF|ELSEIF]         - ENDIF|FIExecutes a code blockdepending on specifiedconditions.____________________________IF expr THEN          [num-label]|[...]   [ELSE [num-label]|[...]]Old-style inline-IFs.____________________________STOP|ENDStops the program execution.____________________________RESTORE labelREAD var[, var ...]DATA n[,n ...]DATA specifies values tobe read by READ.RESTORE specifies theposition of the nextdata to be read.READ reads values fromcurrent data position.Example:RESTORE MyDataBlockFOR I=1 TO 3	READ v	PRINT vNEXTENDLABEL MyDataBlockDATA 1,2,3____________________________ERASE var1[, var2[,  ... varN]]Frees the memory used by thespecified arrays or variables. After that these variablesturned to simple integerwith value 0Example:DIM x(100)...? fre(0)ERASE x? fre(0)? x(1):REM ERROR____________________________EXIT [FOR|LOOP|SUB|FUNC]By itself exits from lastcommand block (loop, for-loop or routine)FOR - Exit from the last  FOR-NEXT loopLOOP - Exit from the last  WHILE/REPEAT loopSUB - Return from the  current routineFUNC - Return from the  current function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -