../
kernel
functions
add
all
apply_delta
assert
atan2
btn
btnp
camera
cd
char
chooser
circ
circfill
clip
cls
color
cos
count
cp
create_delta
create_gui
create_process
cursor
date
del
deli
env
error
exit
fetch
fetch_metadata
fget
fillp
foreach
fset
fstat
fullpath
get_clipboard
get_display
get_draw_target
get_spr
include
input
key
keyp
line
ls
map
max
memcpy
memmap
memset
menuitem
mget
mkdir
mouse
mouselock
mset
music
mv
note
on_event
open
oval
ovalfill
peek
peek2
peek4
peek8
peektext
pget
pid
pod
poke
poke2
poke4
poke8
printh
pset
pwd
readtext
rect
rectfill
rm
rrect
rrectfill
scoresub
send_message
set_clipboard
set_draw_target
set_spr
sfx
sin
socket
split
spr
sspr
stat
stop
store
store_metadata
sub
time
tokenoid
type
unmap
unpod
userdata
vec
vid
window
sub(str,pos0,pos1): string
Overview
sub returns a substring of the string sub, similar to Lua's default string.sub (which is also available in Picotron).
This can also be used in the form of string:sub(), where string becomes the first argument, str.
Arguments
str: string
The string to acquire the substring of.
pos0: integer
The first position of the substring (character index).
Positions are 1-indexed, similar to tables, so the first character is at index 1.
pos1: integer|nil
The second position of the substring (character index), if this is nil, it defaults to the value in pos0.
Positions are 1-indexed, similar to tables, so the first character is at index 1.
Returns
substring: string
The substring of the string.
Example
local string="Hello world"
?sub(string,1,5) -- "Hello"
?sub(string,7) -- "World"
?string:sub(1,5) -- "H"