hBasic Manual Commands -
Changes by category
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TEXT.WRITELN Fixes
In legacy basic, this command was line-based using a
buffer to collect continuation text. In hBasic (since v.4.93) it is now stream based and the buffer is removed. This means all text is output directly. This fixes the problem of a last line having continuation (";") and not being written. And also fixes the conflict of multiple output files sharing the only one buffer. ( For legacy programs, there should be no need to make any adjustments to the Basic code. ) Note: The final output still uses an internal buffer (which is not related to continuation). It is therefore still strongly advised that TEXT.CLOSE be called to ensure that any remaining text is wriiten and the file closed. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FTP.<XXX>
Return Flags
An optional return flag was inserted into these FTP
client commands.
FTP.OPEN
{ok_nvar,}
<url_sexp>, <port_nexp>,
<user_sexp>, <pw_sexp>
FTP.PUT {ok_nvar,} <source_sexp>, <destination_sexp> FTP.GET {ok_nvar,} <source_sexp>, <destination_sexp> FTP.DIR {ok_nvar,} <list_nvar> {,<dirmark_sexp>} FTP.CD {ok_nvar,} <new_directory_sexp> FTP.RENAME {ok_nvar,} <old_filename_sexp>, <new_filename_sexp> FTP.DELETE {ok_nvar,} <filename_sexp>> FTP.RMDIR {ok_nvar,} <directory_sexp> FTP.MKDIR {ok_nvar,} <directory_sexp> FTP.CLOSE {ok_nvar} If ok_nvar is not present, an error will stop with an error message (like legacy Basic). If ok_nvar is present, the app will not stop with a run-time error. if ok_nvar is 1 (true), the command was successful. There was no error. if ok_nvar is 0, (false) there was an error. Further information may be contained in getERROR$(). Note that if you don't use this flag (omitted), then it's following comma (if any) is ignored. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FTPS Commands
These commands control the built-in ftp server.
FTPS.SET rc_nvar { options} Configures the server. (must restart server after) FTPS.START rc_nvar { options} Starts the server. FTPS.STOP rc_nvar Stops the server.
Return codes
All commands return an exit code (not optional) which
will be one of the following;
FTPS.SET
return_code_nvar {,port_nexp} {,username_sexp}
{,password_sexp}
{,welcome_string_sexp}
Configures the server. (must restart server
after)
e.g
FTPS.SET rc, "john",
"mypass"
FTPS.SET rc, "john", p$, "Welcome to myApp's Server" FTPS.SET ,,newpassword$
Use lowercase for all parameters.
The config does not take place until a new server starts. So do this before starting the server. Do not put any newlines ("\n") inside the welcome string. Note that some ftp-clients do not allow to have empty usernames and/or passwords.
FTPS.START
return_code_nvar {,IP_svar}
Starts the server.
Returns IP_svar as the server's ip address plus the port number used as "d.d.d.d:port" e.g 192.0.0.105:2345
e.g
FTPS.START rc,
IP$
IF rc > 0 THEN PRINT "Error" ELSE PRINT "Server started on ";IP$
FTPS.STOP
return_code_nvar
Stops the server.
e.g
FTPS.STOP
rc
IF rc <> 0 THEN PRINT "Error" ELSE PRINT "Server stopped" |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FILE.<XXX> Return
Flag
An optional ok return flag was inserted into these FILE
commands.
FILE.MKDIR {ok_nvar,} <path_sexp> FILE.DIR {ok_nvar,} <path_sexp>, Array$[] {,<dirmark_sexp>} FILE.RENAME {ok_nvar,} <old_path_sexp>, <new_path_sexp> FILE.DELETE {ok_nvar,} <path_sexp> If ok_nvar is not present, an error will stop with an error message (like legacy Basic). If ok_nvar is present, the app will not stop with a run-time error. if ok_nvar is 1 (true), the command was succesful. There was no error. if ok_nvar is 0, (false) there was an error. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FILE.DELETE
The return flag ok_nvar is now
optional An option to delete recursively was added to this command.
FILE.DELETE
{ok_nvar,}
path_sexp {,recurse_nexp}
Becareful with the recurse option. A blank path will delete the default directory. if ok_nvar is 1 (true), the command was succesful. The file/dir existed and was deleted. if ok_nvar is 0, (false) there was an error. Either the file/dir did not exist or could not be deleted. If <path_sexp> is a non-empty directory and recurse_nexp is false; then the directory will not be deleted and ok_nvar is false.If <path_sexp> is a non-empty directory and recurse_nexp is true then the directory and all subdirectories and files will be deleted. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FN_IMPORT
This command imports 'global' (main) variables into the
function's local variable list as referenced variables
with the same name.
Effectively, you can import main variables into the function with read/write access.
FN.IMPORT
nvar | svar |
array[] | array$[] { , ... } e.g FN.IMPORT a, foo$, b[], c$[] % imports main variables a,foo$,b[] and c$[] And here are the rules; 1. You can only use FN.IMPORT inside a function. 2. You can use the FN.IMPORT command anywhere inside a function, and even more than once. 3. The import will only take effect after the fn.import command (not before). 4. Variable(s) given will ONLY be searched in the main program namespace (no where else). 5. Any changes to an imported variable will also change the main variable. 6. You must import at least one variable. 7. You cannot repeat variables during import or have the same name local variable in the function. 8. You can only import variables, not functions nor any other literals. Example
fn.def
test()
% fn.import a,a % error: var Duplicate: a fn.import b % fn.import b % error: var Duplicate: b b=3 fn.end a=1 : b=2 test() print b end Output: 3 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FN_RTN
In legacy Basic, FN.RTN must return a value. FN.RTN
alone will produce a syntax error.
This has been changed in hBasic (since v2.50). FN.RTN <something_result> is the similar to Legacy, except that it can also return an array pointer, (even if it's multi-dimensional)
e.g FN.RTN a[] or FN.RTN a$[]
Also, FN.RTN alone does not syntax error (since v2.50). It will behave the same as FN.END (below)
FN.END will return a default value. For a numeric function, it returns 0. For a string function, it returns an empty string "". For a numeric array pointer, it returns a one-dimensional array with 0 as the only element. For a string array pointer, it returns a one-dimensional array with "" as the only element. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bundle
EnhancementsMultiple Input
These are enhancements made to accept multiple input
parameters instead of just one with the same
command.
BUNDLE.PUT
<pointer_nexp>,
<key_sexp>,
<val_nexp>|<val_sexp> {, <key, val>...}
puts one or more objects in a bundle. e.g
bundle.put
mybundle, "Key1",99,
"Key2","RED",
"Key3","Balloons" BUNDLE.GET <pointer_nexp>, <key_sexp>, <val_nvar>|<val_svar> {, <key, val>...} gets one or more objects from a bundle. e.g
bundle.get
mybundle, "Key1",k1,
"Key2",k2$
This enhancement made to get or put variables with the
same named
tag as a convenience. For 'auto' mode, you only have to specify the variable (the tag is matched with the variable). 'auto' mode starts with a ' { ', followed by a list of comma separated variable names. and ends with a ' } '. Variables must be numeric or strings. They cannot be arrays, array cells, literal numbers nor literal strings or you will get a syntax error. The matching tags will be lower case with no spaces. (Basic will always lower case all variable names) The matching tags which are strings will also have the ending ' $ '. e.g'
BUNDLE.PUT
mybundle, {
v1, v2$, v3
} puts into the bundle using tags "v1", "v2$", "v3" with content from variables v1, v2$, v3
BUNDLE.GET
mybundle, {
v1, v2$, v3
} gets content from bundle using tags "v1","v2$","v3" into variables v1, v2$, v3
'auto' mode
can also be mixed in with 'normal mode; BUNDLE.PUT mybundle, "mytag0", v0, { v1, v2$, v3 }, "mytag4", 44 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Accept a Color
String
For these existing commands, a color string
(similar to
console.set) may be used in place of the 4
decimal colors at the front of the command. GR.OPEN <{ {alpha}, {red}, { green},{ blue} } | { color_sexp } > {, decors_flag_nexp} {, orientation_nexp}} GR.COLOR <{ {alpha}, {red}, { green},{ blue} } | { color_sexp } > {, style} {, paint}} e.g
GR.OPEN
"blue", 1,1
is the same as GR.OPEN 255,0,0,255,1,1
Color strings may also be used with various hBasic
commands eg;
CONSOLE.TITLE
..
HTML.TITLE ..
Color Strings color_sexp may be
either
A hexadecimal pre-fixed with a hash '# e.g6 digit hex
e.g "#112233" 8 digit hex
e.g "#FF112233" A color name
e.g "Orange" (case insensitive with no
spaces) A color name postfixed with a decimal alpha channel using a dot '.'
eg. "Orange.255" A color name postfixed with a hexadecimal alpha channel using a hash '#'
eg. "Orange#FF" Color names are listed here or here. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Window Titles and
Colors
GR.TITLE
{title_sexp} {, textcolor_sexp}
{, backcolor_sexp} CONSOLE.TITLE {title_sexp} {, textcolor_sexp} {, backcolor_sexp} HTML.TITLE {title_sexp} {, textcolor_sexp} {, backcolor_sexp}
Sets the actionbar title, text color and
background color for the window. Specify at least one argument. The commas are needed to seperate the args. These commands can be used even if screens are not opened yet. The color strings format is the same as for console.set. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Window
Subitles and Colors
GR.SUBTITLE
{title_sexp} {,textcolor_sexp} CONSOLE.SUBTITLE {title_sexp} {,textcolor_sexp} HTML.SUBTITLE {title_sexp} {,textcolor_sexp}
Sets the actionbar subtitle (under the title)
and/or text color for the window. Specify at least one argument. The commas are needed to seperate the args. These commands can be used even if screens are not opened yet. The color strings format is the same as for console.set. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
REDIM
Re-Dimensions an existing array with optional 'preserve
contents' flag. REDIM {preserve_nexp, } Array[<nexp>{, <nexp> } ... ] ... e.g REDIM a[2,3] REDIM b[4] , c$[5] REDIM 1,d[6] % ( with preserve ) Any references to a REDIMed array will be intact, e.g an array passed into a function that executes a REDIM will not be un-dimmed, i.e it will still be the same array but re-dimensioned. Arrays must exist before REDIMing. The preserve flag is optional.
If the preserve flag is zero,
the array will be full of 0's or "".
If the preserve flag is non-zero,
the old contents will be
preserved to the size of the old or new
array, whichever was
smallest. Any cells left-over will be 0's or
"".
If there are no preserve flags, the default is to not preserve (0). Preserve flags may be inserted anywhere in the arguments list. Arrays following a preserve flag will honor that preserve flag until the next preserve flag. e.g REDIM 1,a[2,3], 0,b[4], 1,c[5], d$[6] % b[] will not be preserved. Preserve flags may be numeric literals or numeric variables but they cannot be numeric array values e.g p[3] would be mis-interpreted as an array to be re-dimmed. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SQL.PING
SQL.PING <result_nvar>,
<DB_pointer_nvar>
{,<table_name_sexp>
{,<column_name_sexp>}}
Ping a database, table or column for some info.
This is mainly used to test for existence of tables. e.g
Returns the size (number of rows) of a database or table to result. In case (A), this is the total number of user tables in the db. The result code is as follows; -1 = table name does not exist -2 = table name exists but column does not exist in the table >=0 = The total number of tables in the database or rows in the table. In case (C), this also means both table and column exists. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PROGRAM.INFOIn addition to the standard info from Program.Info, these items were added :
Some of these added info keys will return absolute paths. PROGRAM.INFO bNote that legacy's FILE.Root <svar> command returns the combination of BasePath, App_Path and "/data". |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DEBUG.DUMP.FNDEBUG.DUMP.FN {level_nexp} Prints the function name from the function stack. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
INPUTINPUT {prompt_sexp}, result_nvar {,{default_exp}{,canceled_nvar}}{,extraFlags_nexp} An optional extraFlags at the end of INPUT was added. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TEXT.INPUT
A cancelled_nvar flag was
added to inform whether the user cancelled the input
via the backkey.
TEXT.INPUT
result$_svar{,text_sexp} {,title_sexp} {,cancelled_nvar}
If the user cancelled the input, the contents of
<result$_svar> remain
unchanged.
Example
TEXT.INPUT
store$,
default$, Title$,
cancelled
IF cancelled THEN PRINT "Do you wish to try again ?" (Since v4.90+ The orientation of TEXT.INPUT will lock to the same orientation of the top most screen at the time the command is called.) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CLIPBOARDDue to privacy issues, the clipboard has not been working since Android 10 so the code was upgraded (v4.60+). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
NOTIFY
sub-commandsNOTIFY.STATUS <last_status_nvar> If the NOTIFY command is used with a 'wait' flag e.g NOTIFY t$, s$, a$,1 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnORIENT ..
ORIENT.RESUME
Interrupt to catch orientation changes.
Triggered if the device changes orientation. The device must be in auto-rotate mode (by sensors) which can be set with CONSOLE.ORIENT -1, GR.ORIENTATION -1 or HTML.ORIENTATION as well as GR.OPEN and HTML.OPEN. You can get a simple report of the orientation with DEVICE$("Orient_Simple").
e.g
CONSOLE.ORIENT
-1 do : pause 100 : until 0 END OnORIENT
print
DEVICE$("orient_simple") ORIENT.Resume |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AUDIO.PLAY
AUDIO.PLAY
aft_nexp {, async_prep_lexp}
An optional Asynchronous Preparation flag was
added. If set to true (non-zero), will attempt to prepare the audio for play in the background before playing. This reduces stress on the foreground thread which may otherwise cause a delay in graphics. If you omit this flag, the default setting is off (legacy behaviour) and the interpreter will wait until the preparation is complete. Note: This option (if true) does not check if play was successful and does not error message if unsuccesful. You may test this flag with the sample program h13_animations.bas. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LIST.CREATE
LIST.CREATE
N|S
{ M | L } pointer_nvar { , pointer_nvar | data_nexp|sexp
...
}
Added optional creation modes M or L or omitted.
Omitted mode behaves exactly like legacy Basic.
LIST.CREATE
N, nlist LIST.CREATE S, slist There is no multiple creation nor any data loading. Multiple mode M creates one or more empty lists.
LIST.CREATE
NM,
nlist1,nlist2.. LIST.CREATE SM, slist1,slist2.. Loading mode L creates one list with data loading.
LIST.CREATE
NL,
nlist,
1,2,3 LIST.CREATE SL, slist, "apple","orange","pear" Creation modes {<omitted> | M | L } are mutually exclusive, i.e you can only use one of them per command. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-End |