Description
The 'util' package includes a set of procedures and functions that support legacy Scratch 3 functionality.
8 functions
1 procedure
'wait' procedure
Imports an integer or real number value.
The 'wait' procedure imports an integer or real number value and pauses the program for the specified number of seconds.
wait [integer]
wait [real]
'isnumeric' function
Imports a single parameter.
Exports a boolean.
The 'isnumeric' function imports a value and returns 'true' if and only if the value is an integer or real number. Else, false is returned.
isnumeric [value]
[variable] & [isnumeric] [value]
if isnumeric [value]
[...]
endif
'ask' function
Imports a string.
Exports a string.
The 'ask' function uses the legacy Scratch 3 ask block to prompt the user for input. The user's input is returned as a string.
ask [string]
[variable] & ask [string]
'date' function
Imports a string.
Exports a string.
The 'date' function returns a date value based on the string import. The string import must be one of the following:
For example, given the date Monday 1st of January 2020:
"m" returns the month number "1".
"mm" returns the month number padded with 0's "01".
"d" returns the day number "1".
"dd" returns the day number padded with 0's "01".
"y" retuns the year "2020".
"wd" returns the weekday number "2".
"month" returns the month name "January".
"mon" returns the abbreviated month name "Jan".
"weekday" returns the weekday name "Monday"
Any other input will crash the program.
date [string]
[variable] & date [string]
'time' function
Imports a string.
Exports a string.
The 'time' function returns a time value based on the string import. The string import must be one of the following:
For example, given the time 8:05:09 PM:
"h" returns the hour (24hr time) "20".
"hh" returns the hour padded with 0's "20".
"m" returns the minute "5".
"mm" returns the minute padded with 0's "05".
"s" returns the second "9".
"ss" returns the second padded with 0's "09".
"p" returns AM/PM "PM".
Any other input will crash the program.
time [string]
[variable] & time [string]
'dst' function
Imports nothing.
Exports a real number.
The 'dst' function returns the exact number of days since 2000.
dst
[variable] & dst
'getusername' function
Imports nothing.
Exports a string.
The 'getusername' function returns a string of the current user's username on TechSpaces.
getusername
[variable] & getusername
'random' function
Imports two values.
Exports an integer or a real number.
The 'random' function accepts two numeric values and returns a random value between those values. An integer value is returned if and only if both imports are integers. Else, a real number is returned.
random [integer] [integer] : integer
random [integer] [real] : real
random [real] [real] : real
random [real] [integer] : real
'round' function
Imports one value.
Exports a value.
The 'round' function accepts a real number value and exports the nearest integer.
round [real]
[variable] & round [real]