hBasic Manual Console
command changes
|
||||||||||||||||||||||||||||||||||
BACKSPACE
BACKSPACE
{
<count_nexp>
}
Deletes the last character(s) of the last console row
and puts PRINT
into append mode. Rules; 1. count must be greater than 0. If count is not given, 1 character is deleted. 2. If count is greater than the length of the last line, all characters will be deleted leaving an empty line. 3. Any PRINT following BACKSPACE is appended to the end of the line.
Examples
BACKSPACE
%
deletes 1 character backward BACKSPACE 5 % deletes 5 characters backward |
||||||||||||||||||||||||||||||||||
PRINT.AT
PRINT.AT
<line_nexp> ,
<column_nexp>; {<exp> {, | ;}}
Print at screen location Line,Column;
Rules 1. <exp> is the same as the regular PRINT command. 2. line and column coordinates start from 1 (not 0). Line 1 is at the top and Column 1 is at the left. 3. line = 0 will append after the last line 4. column =0 will append after the end of line 5. line < 0 will count upwards from bottom (-1=last line) 6. column < 0 will count backwards from end of line (-1 = last char) 7. If line > last_line then extra lines are added for padding. 8. If column > last_char_of_line then extra spaces are added for padding. 9. Any other lines or columns out-of-range (i.e above or left of screen) are ignored and the command has not effect. 10. Although PRINT.AT does not obey PRINT's append mode, it will still
preserve any previous append mode (since v4.67). i.e If a previous PRINT was in append mode ( ";" as last character), then the next PRINT will append after the last line of the console, ( even if PRINT.AT created that line ).
Examples
PRINT.AT
2, 11; "print this at line
2, column 11"
PRINT.AT 0, 11; "append after the last line at column 11" PRINT.AT 2, 0; "append after the end of line 2" PRINT.AT -1, 11; "print on last line at column 11" PRINT.AT -2, 11; "print above last line at column 11" PRINT.AT 2, -1; "print over the last char of line 2" PRINT.AT 3, -2; "print from last two chars of line 3"
Notes:
PRINT.AT only works well with monospaced fonts.
PRINT.AT usually works well with "CONSOLE.SET WRAP OFF". PRINT.AT will use the current (CONSOLE.SET) styles for it's content.
Some of these styles will affect the whole
console,
others will affect only the content being printed. |
||||||||||||||||||||||||||||||||||
PRINT.IMG
PRINT.IMG
<line_nexp>,
<column_nexp>
,
<tag_sexp>,
<file_name_sexp> {,
<align_nexp>}{,scale_nexp>
<}
e.g PRINT.IMG 5 , 5
, "mytag", "picture.png"
Print an image at the screen location
line
, column with a
tag.
The purpose of this command is to be able to print small images on the console.
Example
PRINT
"Cartman" PRINT.IMG -1,0,"Tagged","cartman.png" % append to last line do : pause 200 : until 0 end OnConsoleTouch: Console.Tapped ,,w$ print w$ ConsoleTouch.Resume
A tap on the image returns the word under the image
which is "CartmanTagged"
Use a space if you wish to separate "Cartman" from "Tagged"; PRINT "Cartman "
About
Tags
Be wary when re-printing over a tag , as the tag
length and it's columns are still valid.
If you PRINT.AT or PRINT.IMG over an existing tag column,
The existing image is always removed. The existing tag becomes normal text and is shown on the console. Any new string or tag is overlaid on top of the old tag. Any new image occupies only it's own tag length. It is not advisable to put spaces inside tags, otherwise the word returned by console.tapped is unpredicatable.
Notes:
Internally, a new bitmap is created for each
call.
It is not advisable to loop large animations on the console as it is not designed for speed and memory. All console bitmaps will be cleared with CLS. PRINT.IMG preserves any previous print append mode. |
||||||||||||||||||||||||||||||||||
CONSOLE.BACKIMG
CONSOLE.BACKIMG
file_name_sexp
{,fit_type_nexp}{,smooth_lexp}
Sets a background image for the console
The image
file_name_sexp
is relative to <base_dir>/data/.
Accepted formats are jpg, png, bmp, gif. If file_name is empty (""), then any previous image is removed. Images The loaded image always replaces the console VOIDCOLOR. So you will not not see the void color while the image is on. Also images with transparency do not work. Fitting The image is fitted to the screen depending on an optional fit_type_nexp which is by default 0.
If the fit scales the image larger than the screen on
any side, then the image is cropped.
If you wish to use a flag other than 0, make sure your image is appropriately proportioned to fit your target screen, otherwise there is a possible hole leftover. Smoothing Any scaling will smooth the image by default. To scale without smoothing, set the optional smooth flag to zero. Orientation Changes The ratio is always maintained. But if the orientation is later changed, the image will be streched. To maintain the same image ratio, be sure to call CONSOLE.BACKIMG again if the orientation has changed. You can detect for orientation changed with the OnORIENT interrupt block. e.g
CONSOLE.BACKIMG "image.jpg" do: pause 100: until 0 END OnORIENT:
CONSOLE.BACKIMG
"image.jpg" % reload the
background ORIENT.ResumePRINT "Now is " + DEVICE$("Orient_Simple") Replacing the Text background color with image |
||||||||||||||||||||||||||||||||||
CONSOLE.GOTO
CONSOLE.GOTO
<line_nexp>
Position a row of the console given by <line_nexp>
into visible view.
This is only useful if the line is not
visible on the console (e. scrolled out of view). After execution, the line is usually displayed at the top of the console window, the exception is if the line is part of the last page of the console, in which case it could appear anywhere within the last page but still in view. Rules 1. The first line of the console starts at 1 2. if line is out of range, it will be forced to the last line; if line <= 0 OR line > last_line then it will goto to the last_line.
Example
FOR
i =
1 TO
500
PRINT i NEXT
CONSOLE.GOTO
200
% positions line 200 into
view
|
||||||||||||||||||||||||||||||||||
CONSOLE.SET
CONSOLE.SET
<pair_sexp>
{,..}
e.g
CONSOLE.SET
"TEXTCOLOR
#FF112233"
note : the pair is a
string
expression.
(the '='
is optional but there must be a space if it is
not used)
Sets console attributes for
styling.
These attributes may apply to either the whole
console or only for future printing. The Keyword Value Pairs accepted are;"BACKCOLOR <color>" e.g "BACKCOLOR=#112233" % Text Background "LINECOLOR <color>" e.g "LINECOLOR =Aqua" % Divider Line "VOIDCOLOR <color>" e.g "VOIDCOLOR #000000" % Empty Console Area
Sets the color of
various attributes.
The VOIDCOLOR is the area where there is no text. VOIDCOLOR and LINECOLOR apply to the whole console. TEXTCOLOR and BACKCOLOR apply for future printing.
Colors
<color> may either be
hex #AARRGGBB as alpha, red,
green, blue or hex #RRGGBB as red, green, blue (alpha assumed to be solid) or any one of the 564 HTML colors listed here or original website here. Any color string starting with an underscore ( ' _' ) will have that underscore ignored. (this is to accomodate underscored names from other environments). Alpha channels for color Names
A color name can be post-fixed with an alpha-channel
value e.g
CONSOLE.SET
"TEXTCOLOR
darkcoffee.169" is the same as CONSOLE.SET "TEXTCOLOR darkcoffee#A9" is the same as CONSOLE.SET "TEXTCOLOR #A93B2F2F " #hh A 'H'ash ( # ) begins the alpha value as Hex. .ddd A 'dot' ( '.' ) begins the alpha value as Decimal. "SPACING = <number>" e.g CONSOLE.SET "SPACING = 8"
Line
Spacing
(padding above & below text measured as dp)
-ve size
will use Basic's default size (5dp) Applies for future printing. "WRAP <on | off>" e.g CONSOLE.SET "WRAP off"
Set whether text
on one line should wrap if there's not enough room to
display.
Note that wrapped text still sits on 'one' line, even
though it looks likes there are two or more. Set the
dividers 'on' to see which line the text sits on. Applies for future printing. "TEXTSIZE <number>" e.g CONSOLE.SET "TEXTSIZE = 16" %(16 point dp)
Set the font
size of the text +ve size means dp (device independent pixels) -ve size means sp (scaled pixels, adhering to android user prefs) 0 size will default to Basic's preferences. Applies for future printing. "FONT <number|family>" e.g CONSOLE.SET "FONT = 2" % use loaded font 2
e.g
CONSOLE.SET "FONT
= sans-serif" %
use family font
Use a loaded
font or font-family-style where <number> uses a loaded font from the FONT.LOAD command or <family> uses an android family font This command is similar to Gr.text.setfont. A font number or family name can be post-fixed with a style after a dot '.' Normal | Bold | Italic | Bold_Italic e.g CONSOLE.SET "FONT sans-serif.BOLD" e.g CONSOLE.SET "FONT 3.BOLD" (any unrecognised style will default to NORMAL). An example of loading a font is found here. Applies for future printing. "ANTIALIAS <on | off>" e.g CONSOLE.SET "AntiAlias off"
Set Anti-Alias
for text rendering. The default setting is ON. It is recommended to leave this on unless you are using unicode block graphic characters and need to have adjacent lines to look flush. Applies for future printing. "UNDERLINE <on | off>" e.g CONSOLE.SET "UnderLine on"
Underline
text The default setting is OFF. Applies for future printing. "STRIKE <on | off>" e.g CONSOLE.SET "Strike ON"
Apply
strike-through effect on text. The default setting is OFF. Applies for future printing. "DIVIDERS <on | off>" e.g CONSOLE.SET "DIVIDERS off"
turns ON or OFF
line dividers Applies to the whole console. "SCROLL <FASTON | FASTOFF>" e.g CONSOLE.SET "SCROLL Faston"
Set scroll
attributes. FastOn - fast scroll scrollbar drag if list is 4x screenheight or more. FastOff - turns off fast scroll. Applies to the whole console. "STACK <FROMBASE | FROMTOP>" e.g CONSOLE.SET "Stack FromTop"
Set stack
attributes.
FromTop - stack new lines from the top of screen (default). FromBase - stack new lines from the bottom of screen. Applies to the whole console. "NAVBARTXT <LIGHT | DARK>" e.g CONSOLE.SET "NavBarTxt dark"
Set the status
bar text or navigation bar icons
shading. (default is
light)
STATUSTXT does not work for devices < Api 23 (Android 6). NAVBARTXT only works for devices Api 26-34 (Android 8-14). The colors are dependent on the device version or if they are hidden or not (see this table). e.g You may want dark text if you know the statusbar background will be light (see @@window_bg). Applies to the whole console. CONSOLE.SET Rules 1. A keyword value pair is a string expression. e.g "keyword = value" or MyString$. 2. "keyword value" pairs can be separated with commas within the string.
e.g
CONSOLE.SET
"TEXTCOLOR
#FF112233
,
BACKCOLOR=WHITE" 3. "keyword value" pairs can also be separated with commas outside each string.
e.g
CONSOLE.SET
"TEXTCOLOR
#FF112233"
,
"BACKCOLOR=WHITE" and The command can also be continued on the next line using "~" e.g
CONSOLE.SET
"TEXTCOLOR
#FF112233"
, ~ notes:"BACKCOLOR=WHITE" A comma is still required to separate them. Each string itself cannot be split with the "~" continuation character. 4. Within each string, a keyword can be separated from it's value with either whitespace and/or "=".
e.g
"TEXTCOLOR
#FF112233" or e.g "TEXTCOLOR = #FF112233" 5. All strings are case-insensitive.
Examples
CONSOLE.SET "BACKCOLOR=BLUE"
CONSOLE.SET "TEXTCOLOR LIGHTGREY, LINECOLOR = YELLOW",~ "SPACING 0", "DIVIDERS=OFF" + ",TEXTSIZE -30" MyStyle$ = "SPACING 10, DIVIDERS=ON" + ",TEXTSIZE 16" CONSOLE.SET MyStyle$ |
||||||||||||||||||||||||||||||||||
dot CS
Shortcut
.CS
<pair_sexp>
{,..}
is the same as CONSOLE.SET <pair_sexp> {,..} i.e .CS is a shortcut for CONSOLE.SET. |
||||||||||||||||||||||||||||||||||
SCREEN.SIZE
SCREEN.SIZE
size[]_array[], realsize[]_array[], density_DP_nvar, density_SP_nvar
In legacy Basic, this gets information for both the
console and graphics screen. In hBasic, this gets information for the console screen only. The size[] and realsize[] arrays will have width and height values returned in elements [1] and [2]. In hBasic, size[] refers to the console view size only (without decorations). In hBasic, realsize[] refers to the whole device screen (with decorations). density_DP Gets the screen density as (independent) pixels per inch. eg. 160 on a 160 dip display. density_SP Gets the screen density as pixels per scaled inch. e.g returns 320 on a 160 dpi display with a user preference scale of 2X in settings. It is important to have the console being displayed (in front) when executing this command. You may need to use a PAUSE before executing this command, especially if you have just come back to the console or if the console is just begining to be displayed. Recommended is 50ms or more. If you need information for the graphics screen, please use GR.SCREEN. |
||||||||||||||||||||||||||||||||||
CONSOLE.SCREEN
CONSOLE.SCREEN
{<width_nvar>}
{, <height_nvar>
}
Guess the dimensions of the console as number of
characters. This command only works well with the MONOSPACE font. Other fonts will give unpredicatble results. width or height is optional, but the comma is needed for height. Note that the returned values may have a fractional part, .eg 32.2 |
||||||||||||||||||||||||||||||||||
CONSOLE.TAPPEDCONSOLE.TAPPED {row_nvar} {,column_nvar} {,word$_svar} {,longPressed_lvar} |
||||||||||||||||||||||||||||||||||
CONSOLE.ORIENTCONSOLE.ORIENT orientation_nexp Sets the Screen Orientation of the console. The new orientation is effective immediately. |
||||||||||||||||||||||||||||||||||
CONSOLE.EXIT
CONSOLE.EXIT Exits the console without exiting the Editor. (This is different to EXIT which exits the app). This is an immediate exit. The console screen will not be held. For Standard mode, it will exit to the Editor. For APK mode the Standalone app will exit to the caller. |
||||||||||||||||||||||||||||||||||
TGET
TGET
result$_svar, {,prompt$_sexp} {,title$_sexp} {,backKey_nvar}
Get text Input from the last line of the console.
where
result$
is the return string ( not
optional) TGET now closely resembles the output
console.prompt sets the prompt (optional) title sets the window title (optional) backKey is a variable to hold the backKey flag (optional)
0 => backKey was not pressed to exit TGET Commas are needed to seperate parameters, even
if they are omitted.1 => backKey was pressed to exit TGET Any style changes to the console will do the same to TGET. After input from the user, TGET prints both the prompt and user input. The exception is if the user presses 'Stop' from the console menu, in which case 'Stopped by user' is printed instead, and the program execution is stopped or exited.
Examples
TGET
r$,
"cmd >",
"Enter
Command" TGET r$, "Input your password >", "Security Check", bkey IF bkey THEN PRINT "Do you want to Quit ?" (see sample program h05_shell.bas for a demo of a terminal emulator) TGET Sub commands These sub-commnds are designed to quickly get input without obscuring the console. Like TGET, they get input into result with optional prompt and title. |
||||||||||||||||||||||||||||||||||
CLRCLR row_nexp {,column_nexp} |
||||||||||||||||||||||||||||||||||