Other

CONST #ConstantName=ConstantExpression[,#ConstantName=ConstantExpression]

Define constants

・You can define another constant by writing a comma after one definition.

ConstantName

・Constant names have the same format as variable names and begins with #.

ConstantExpression

・Numeric values, strings, other constants, CHR$, RGB, RGBF, HSV, HSVF, DEG, RAD functions, and their operations can be used as constant expressions.

Example

CONST #C1=1,#C2="ABC",#C3=RAD(180)
?#C1,#C2,#C3

ENUM #ConstantName[=ConstantExpression][,#ConstantName[=ConstantExpression]]

Define constants with sequential numbers

・Unlike CONST, only Int constants can be defined.
・Constant expressions can be omitted.
・If not specified, the set value +1 in the previous constant definition is used.

ConstantName

・Constant names have the same format as variable names and begins with '#'.

ConstantExpression

・Int, other Int constants, RGB, RGBF, HSV, HSVF, DEG, RAD, and their operations can be used for constant expressions.
・If the constant expression is a Real, the decimal part is rounded toward zero.
・If not specified, the set value +1 in the previous constant definition is used.

Example

ENUM #TYPE1=2,#TYPE2,#TYPE3
?#TYPE1,#TYPE2,#TYPE3

DATA ConstantExpression[,ConstantExpression...]

Define data to be read by the READ command

Argument

ConstantExpression

・Numeric values, strings, other constants, CHR$, RGB, RGBF, HSV, HSVF, DEG, RAD functions, and their operations can be used as constant expressions.
・If it is a constant expression, both numerical values and strings can be mixed.

Example

DATA 123,#C_RED,56,"SAMPLE"+CHR$(20)

READ Variable1[,Variable2...]

Read the value defined by the DATA command

・If there is no data that can be read, Out of data error occurs.

Argument

Variable

Variable to store information to be read (multiple variables can be specified)

・Get sequentially from the first DATA statement.
・Use the RESTORE command to change the DATA statement to be read.

Example

READ X,Y,Z,G$
DATA 200,120,0,"JAN" 
DATA 210,120,0,"FEB" 

RESTORE @Label
RESTORE String

Change the DATA statement read with the READ command

Argument

@Label

@LabelName added to the beginning of the DATA statement to be read

・When you put RESTORE "1:@LabelName" or/and the "Number:" before the label names, then it can refer to other program slots.
・When specifying a program slot, it is necessary to enable the program in the target program slot beforehand with the EXEC command.

String

・If a string is specified instead of a label, the value of the expression is considered as a label at runtime and the label is referenced.
・In addition to labels, each of the following strings has a special function.

"PUSH" Stops the READ reading position on the stack. The current READ reading position remains unchanged.
"POP" Set the READ reading position to the location where the reading occurred from the stack.
"BEGIN" Set the READ reading position to the beginning of a DATA statement in the program.
"Number:BEGIN" Set the READ reading position to the beginning of a DATA statement in the specified program slot.

Example

RESTORE @DATATOP
READ X,Y,Z,T$
@DATATOP
DATA 123,345,56,"SAMPLE" 

OPTION FunctionName

Set the program operation mode

Argument

FunctionName

STRICT Variable definition is mandatory and assignment to an undefined variable results in an error.
DEFINT The default value of the variable is set to the Int 0 instead of a Real. The default type for numeric arrays is an Int array.

Example

OPTION STRICT

WAIT [FrameCount]

Stop program execution until the specified frame count elapses

Argument

FrameCount

Specify elapsed frame count from the present time

・If 0 is specified, it does not stop.
・If not specified, it's 1.

Example

WAIT 60

VSYNC [FrameCount]

Stop program execution until the specified frame count elapses

・Unlike WAIT, specify the frame count from the previous VSYNC execution.

Argument

FrameCount

Specify elapsed frame count since the last VSYNC

・If 0 is specified, it does not stop.
・If not specified, it's 1.

Example

VSYNC 1

REM
'

Symbol for comment description

・REM or ' and after the end of the line are regarded as comments and they will be ignored.
・Comments do not affect program execution.

Example

' MAIN ROUTINE

TMREAD OUT H,M,S
TMREAD TimeString OUT H, M, S

Convert time string to number

Argument

TimeString

Time string in "HH:MM:SS" format

・HH is a numerical character from 00 to 23, MM and SS are numerical characters from 00 to 59.
・Current time is the default.

Return Value

H,M,S

H Variable that receives the hour
M Variable that receives the minute
S Variable that receives the second

Example

TMREAD "12:59:31" OUT H,M,S

DTREAD OUT Y,M,D[,W]
DTREAD DateString OUT Y,M,D[,W]

Convert date string to number

Argument

DateString

Date string in "YYYY/MM/DD" format

・YYYY is a numeric character from 0000 to 9999, MM is from 01 to 12, and DD is from 01 to 31.
・The default is the current date.

Return Value

Y,M,D,W

Y Variable that receives the year
M Variable that receives the month
D Variable that receives the day
W Variable that receives the day of the week (a number with Sunday as 0) (optional)

Example

DTREAD "2014/10/12" OUT Y,M,D

CHKLABEL(String[,Flag])

Check if a label with the same name as the specified string exists

Argument

String

The string to search for as a label

・CHKLABEL "1:@LabelName" can also check labels in other program slots.
・When specifying a program slot, the target program slot must be enabled with the EXEC command in advance.

Flag

Specify whether to search labels outside DEF when CHKLABEL is used in DEF

0 Search only in DEF
1 Search global labels if not in DEF

・0, if not specified.

Return Value

1 if it exists, 0 if not exist

Example

A=CHKLABEL("@MAIN")

CHKCALL(String)

Check if there is an command/function with the same name as the specified string

Argument

String

String to search for as an command/function

Return Value

1 if it exists, 0 if not exist

Example

A=CHKCALL("KEYCHECK")

CHKVAR(String)

Check if a variable with the same name as the specified string exists

Argument

String

String to search for as a variable

Return Value

1 if it exists, 0 if not exist

Example

A=CHKVAR("COUNTX")

DIALOG DisplayString[,SelectionType[,CaptionString[,TimeoutPeriod]]]

Display the dialog and wait until the button is pressed

・Pressed button information can be obtained with the RESULT function.
・1: OK, -1: Cancel, 0: Timeout

Argument

DisplayString

String to be displeday in the dialog

・Up to 256 characters can be displayed.
・If there is CHR$(10) or CHR$(13) in the display string, a line break will occur.

SelectionType

0 OK (Default)
1 No / Yes
2 Back / Next
3 Cancel / OK
4 Cancel / Execute
5 Next

・If not specified, it's 0.

CaptionString

String to be displayed in the caption field at the top of the dialog

・If the caption string is longer than 46 characters, only 46 characters are displayed.
・If not specified, "DIALOG" is displayed in the caption column.

TimeoutPeriod

Number of seconds before closing the dialog automatically

・If a negative value is specified, it is specified in frame count units.
・If 0 is specified, it waits until the user operates.
・If not specified, it's 0.

Example

DIALOG "Let's get started",5,"Scenario",-120

DIALOG(DisplayString,ButtonType[,CaptionString[,TimeoutPeriod]])

Display dialog and wait until touch or hardware button is pressed

Argument

DisplayString

String to be displayed in the dialog

・Up to 256 characters can be displayed.
・If there is CHR$(10) or CHR$(13) in the display string, a line break will occur.

ButtonType

bit0 X Button
bit1 B Button
bit2 Y Button
bit3 A Button
bit4 Up Button
bit5 Down Button
bit6 Left Button
bit7 Right Button
bit8 L Button
bit9 R Button
bit10 ZL Button
bit11 ZR Button
bit12 Press the L Stick
bit13 Press the R Stick
bit14 Any from A/B/X/Y Button
bit15 Any from Up/Down/Left/Right Button
bit16 Any button other than press the Stick
bit17 Touch Screen

・Specify the OR of the above bit values.
・Specifying zero causes an error.

CaptionString

String to be displayed in the caption field at the top of the dialog

・If the caption string is longer than 46 characters, only 46 characters are displayed.
・If not specified, "DIALOG" is displayed in the caption column.

TimeoutPeriod

Number of seconds before closing the dialog automatically

・If a negative value is specified, it is specified in frame count units.
・If 0 is specified, it waits until the user operates.
・If not specified, it's 0.

Return Value

Depending on the button pressed, it returns the value which becomes 1 corresponding to a bit value of the button type argument.

・Except for touch, the same value as BUTTON() is returned.
・0 is returned in case of timeout.

Example

R=DIALOG("ABXYLR/DirectionalKey/Touch",(1 << #B_ANY) OR (1 << 17),"Special",0)

DIALOG(InitialString,CaptionString[,MaximumNumberOfCharacters])

Display a dialog dedicated to file name input

Argument

InitialString

File name string set in advance as an input value

・An error occurs if characters that cannot be used in the file name are used.

CaptionString

The string to display in the caption

・If the caption string is longer than 39 characters, only 39 characters are displayed.

MaximumNumberOfCharacters

Up to 32 characters

Return Value

Obtained string

・If the return value of the RESULT function is -1, it'll be canceled (string invalid).

Example

T$=DIALOG("NEWNAME0","SAVE",14)

RESULT()

Get the execution result of some commands

・Returns the execution results of commands that require execution results such as DIALOG, file operation commands, and XCTRLSTYLE.
・Use after execution of an command that updates RESULT.

Return Value

Command execution result

・The result value varies depending on each command, but as a common element, 1 indicates success and 0 indicates failure in all commands.

CALLIDX()

Return the number associated with the callback

Return Value

The number associated with the callback

・For CALL SPRITE, the sprite ID that called the callback.
・For CALL TEXT, the text screen ID that called the callback.
・If you call outside the callback, a meaningless value is returned.

CLIPBOARD String

Set clipboard contents

Argument

String

String to be stored on the clipboard

Example

CLIPBOARD "Good morning" 

CLIPBOARD()

Get clipboard contents

Return Value

String in the clipboard

Example

PRINT CLIPBOARD()

KEY KeyNumber,String

Set the function key contents

・The contents set with Ctrl+F1 to F5 can be entered.

Arguments

KeyNumber

Function key number to register: 1 to 5

String

String to be registered in the function key

・The maximum length of the string is 256 characters.

Example

KEY 1,"PRINT" 

KEY(FunctionKeyNumber)

Get the contents of a function key

Argument

KeyNumber

Function key number for acquiring the contents: 1 to 5

Return Value

String registered in the function key

Example

A$=KEY(1)

FONTINFO CharacterCode,FontType OUT X,Y
FONTINFO String,FontType OUT X,Y

Get font storage coordinates

・Get the storage coordinates of the specified font in GRPF.

Arguments

CharacterCode

Character code of the character you want to check

・User-defined characters cannot be specified.

String

String that contains the first character you want to check

・Ignore characters other than the first character.
・User-defined characters cannot be specified.

FontType

The type of font you want to check

・8 or 16 can be specified.

Return Value

X,Y

Returns the coordinates where characters are stored in GRPF

FREEMEM()
FREEMEM OUT TotalFreeSpace,ContinuousFreeSpace

Get free memory space for strings and arrays

・The unit of capacity is bytes. SmileBASIC consumes 2 bytes per character, 4 bytes per Int array element, and 8 bytes per Real array element.
・When it's used in function format, the total free space is returned.

Return Value

TotalFreeSpace

Total size of unused memory

ContinuousFreeSpace

Size of unused memory that can be used at one time

MILLISEC()

Returns the elapsed time since launching SmileBASIC4

・Unit is milliseconds (1/1000th of a second)

Return Value

Elapsed time since startup

MAINCNT()

Return the elapsed time since launching SmileBASIC

・The time per frame count is about 1/60th of a second when no processing loss occurs.
・Used to measure how many times the display has been updated. Not suitable for accurate timekeeping.

Return Value

Frame count since startup

SYSPARAM(InformationNameString)
SYSPARAM InformationNameString OUT SettingValue1,SettingValue2
SYSPARAM InformationNameString,SettingValue

Get and set various information

Argument

SettingItemNameString

Specify the name of the item you want to get/set as a string

The item names that can be specified are as follows:

LANG Language name set in Nintendo Switch™ (Get)
SYSBEEP System UI sound effect playback flag (Set/Get)
TABSTEP Number of spaces inserted when using the TAB key in the editor (Get)
KEYREPEAT Setting menu on the key repeat value (Get)
MOUSECURSOR Mouse cursor display (Set/Get)
TVMODE Whether TV Mode (Get)
TOOL1 Tool 1 file name (Get)
TOOL2 Tool 2 file name (Get))
TOOL3 Tool 3 file name (Get)

・KEYREPEAT returns two values: repeat start and repeat interval

Return Value

Returns a value according to the item name

Example

PRINT SYSPARAM("LANG")
SYSPARAM "KEYREPEAT" OUT ST,IT

PERFBEGIN MeasurementNumber [,ColorCode]

Start execution time measurement

・Used in combination with the PERFEND command.

Arguments

MeasurementNumber

Number of measurement information to use: 0 to 7

ColorCode

Color when indicatng information on the performance gauge

・Optional

PERFEND MeasurementNumber

Finish the execution time measurement and register the result in the performance gauge

・If the same measurement number is specified and PERFBEGIN has not been called, correct measurement results cannot be obtained.

Argument

MeasurementNumber

Number of measurement information to use: 0 to 7

PERFEND(MeasurementNumber)

Finish the execution time measurement and register the result in the performance gauge

・If the same measurement number is specified and PERFBEGIN has not been called, correct measurement results cannot be obtained.
・When it's used as a function, the execution time between PERFBEGIN and PERFEND can be obtained.
・If the measurement time exceeds 2147 seconds, correct results will not be returned.

Argument

MeasurementNumber

Number of measurement information to use: 0 to 7

Return Value

Returns the elapsed time from PERFBEGIN to PERFEND in microseconds (1 millionth of a second)

METALOAD ["ProjectName"]

Load the metadata of the specified project

・Read the icons and descriptions of the specified project to the memory and makes them editable.

Argument

ProjectName

Project name string to be read
・If it is not specified, the current project will be read.

METAEDIT MetadataItems,SettingData

Set metadata items

Arguments

MetadataItems

Specify the metadata item to be set as a numeric value

0 Title
1 Description
2 Icon

SettingData

Specify the value to set

・The type and contents of the value differ for each metadata item number.
・For a title, set a string of up to 24 characters.
・For a description, set a string of up to 240 characters. Line feed with CHR$(10).
・For an icon, an icon image is designated by a numerical array with the number of elements 1600(Height40,Width40).

METAEDIT MetadataItem OUT SettingData

Get the currently set metadata item

Argument

MetadataItem

Specify the metadata item to be acquired as a numeric value

0 Title
1 Description
2 Icon

Return Value

SettingData

The returned value is different for each metadata item number.

・For a title, a string of up to 24 characters is returned.
・For a description, a string of maximum 24 characters x 10 lines is returned. Line feed with CHR$(10).
・For an icon, a 2D Int array with the number of elements 1600(Height40,Width40) is returned as an icon image.

METASAVE

Save metadata

・The metadata of the current project is rewritten.