hBasic > hManual > Functions

hBasic Manual
Function changes

Convert


DEVICE$ (..) Gets specific device information as a string

INT    ( nexp | sexp ) accepts a string

INT$  ( nexp | sexp ) accepts a string
Extract


ROUND (..)
Fix for ROUND function for precise input values

VERSION$ (..)
return base version

WORD_ALL$ ( .. )
Does not trim leading and trailing empty words

INT (..) and INT$ (..)

These functions now accept a string as well as a number.

INT   (nexp | sexp)        % convert to real + dismiss fractional part
INT$ (nexp | sexp)        % convert to string + truncate fractional part

e.g
s$ = "99.12"
PRINT INT(s$)       % 99.0
PRINT INT$(s$)      % 99

DEVICE$ ()

DEVICE$ ( <key_sexp> )

Gets device information without needing permissions.
This function is an alternative to the legacy DEVICE sub-commands

Pass a key_sexp to get information about the key.
e.g
a$ = DEVICE$("locale")    % will return e.g "en_US"
The allowed keys are;
Key example
comment
"LANGUAGE" "English"     Language
"LOCALE" "en_US" Locale
"OS" "4.0.3" Android version
"BATT_PERCENT" "73" battery level as percentage left.
"BATT_STATUS" "Discharging" "Charging", "Not Charging", "Discharging", "Full","Unknown"
"ORIENT_SIMPLE"
"Portrait"
"Portrait", "Lansdscape"
All keys are case-insensitive.

Notes: Returned value is a string. You may have to use IS_NUMBER and VAL to parse it for a number.
(This function is similar /but not the same/ as the legacy DEVICE and  sub commands).
Some items are not part of the legacy DEVICE command and will not show up in it's bundles or strings.

ORIENT_SIMPLE
Returns the last view orientation as simply "Portrait" or "Landscape". This is the last config set for the top most view and might not be the same as the last requested orientation - depending on what is allowed by the hardware. It is mainly used with OnORIENT ..ORIENT.Resume.

VERSION$(0)

VERSION$()
returns the app version
VERSION$(0)         
returns a base version

This command returns a version string.
e.g
PRINT VERSION$()
PRINT VERSION$(0)

04.30
02.14


The current version of hBasic e.g 04.30 is equal to the master version with almost ALL patches applied.

The master version e.g 02.14 is the code base version used to build hBasic. This is the master shipped with hSuite. If you apply all patches within hSuite amd compile, you have the equivalent of the current version.

Both version numbers are user-definable within the hSuite compiler. If you don't use hSuite, your app maker will have to change the versions itself.

WORD_ALL$ ( .. )

WORD_ALL$ (source_sexp, nth_nexp {, separator_sexp})
Same as WORD$ except that it will not trim leading and trailing empty words.
This is useful for empty data in specific columns.

e.g
s$ = ",,1,2,3,,"              % get the 3rd word/column
PRINT WORD$ (s$,3,",")        % 3
PRINT WORD_ALL$ (s$,3,",")    % 1

ROUND (..)

Fix for ROUND function for precise input values

The math function ROUND (<value_nexp>{, <count_nexp>{, <mode_sexp>}})

Uses java BigDecimal for rounding BUT the input values were still binary64 leading to precision errors.

Fix was to use BigDecimal(String) instead of BigDecimal(double).




Leading Cloud Surveillance, Recording and Storage service; IP camera live viewing

Leading Enterprise Cloud IT Service; cloud file server, FTP Hosting, Online Storage, Backup and Sharing

Powered by FirstCloudIT.com, a division of DriveHQ, the leading Cloud IT and Cloud Surveillance Service provider since 2003.