Log In  


I would like to preface this is an issue in version 0.2.6b, both in my downloaded executable of Pico 8 and Pico 8 Education Edition

So I have been reading and re-reading the pico 8 manual for the past weeks now and I have noticed that there is a really big discrepancy in the way that sub() works vs how it is presented. The manual establishes that:

When POS1 is specified, but not a number, a single character at POS0 is returned.
PRINT(SUB(S,5,TRUE)) --> "Q"

This does not seem to be the case, however, as using non-numerical values such as a boolean, nil or a string all still will return a string from the index all the way to the end of the string. I tried looking information about this in the forums and it seems like at some point this behavior was indeed implemented, but in another update it seems to have been removed. I don't know if this was intentional or if this is the product of a bug/oversight but it would be nice if the change was reflected in the manual.

Another thing that I have been made aware of today while looking at the Pico 8 wiki is that apparently since v0.2.5 it is possible to get a character from a string using brackets if used on a variable, i.e.

a = "Hello!"
print(a[3]) --> "l"

I don't know if this is an experimental feature or not but it seems important to include in the manual if it replaces the slightly more token-heavy sub(string, n, n) to get a single character.

1


I'm not excusing the oversights in the manual, but I will point out that a lot of confusion about changing behaviour can be investigated in the changelog
https://www.lexaloffle.com/dl/docs/pico-8_changelog.txt

I believe your questions about sub() can be clarified therein.

Added: sub(str,pos,pos) can be written as str[pos]

Changed: sub(str, pos, nil) returns whole string (pre-0.2.4 behaviour). For single chars, can now use str[pos].

etc...


@ChristopherD ah thank you !! I kind of forgot that the changelog existed haha. Thanks for the reminder. I do think this is also a thing that is part of the problem of like, having to check the changelogs to know what is going on but I guess this'll make do for now !!



[Please log in to post a comment]