examples show what happens when we request both a conversion and the optional places:
STR$(201.5, 16)
which gives us C9 (which equals 201, the integer part of 201.5 ) and
STR$(3.5, 2, 4)
which converts 3.5 into a binary number with 4 fractional places for .5 and returns 11.1000.
IN (source$, match$ [, startpos[, wild$]]) returns the leftmost character position number where match$ was found in source$. Optional parameter startpos determines the position within source$ to begin the search (default=1). If startpos is negative, the search starts from position ABS(startpos) and proceeds backwards (More about ABS further below).
The value returned will be between 1 and LEN source$ if a match was found or 0 if a match is not found, startpos is 0, match$ or source$ are the empty string ("").
If you're not entirely sure of the spelling of the word you're looking for within the original string you have the option to use a wildcard1 character which itself is user-definable. Any character you enter in wild$ or the copyright symbol © (ASCII 127), will become the wildcard character which you can then substitute in match$ for any character you're unsure about. Any characters in match$ which are the wildcard character will match any character in source$. If wild$ is the empty string (""), the wildcard character is ASCII 0. Here are some examples to better illustrate:
PRINT IN("Harry is awesome"," ")
Prints 6 on the screen as a space is a valid character while
PRINT IN("Harry is awesome","
",7)
Prints 9 as we told IN to start looking from position 7 onwards.
PRINT IN("Harry is awesome","
",-16)
will also return 9 as it's looking backwards and finally
PRINT IN("Here's
Garry!","a%%y",1,"%")
prints 9 as we substituted any letter for the symbol % and the first string is located there. If however we modified the above slightly and made it:
PRINT IN("Here's
Garry!","%r",1,"%")
we'd get 2 as the first match er for the %r is located there. If we then modified it a little further to:
PRINT IN("Here's
Garry!","%r",5,"%")
it would have returned 10 as starting from position 5 the first match is the rr in Garry.
1 A wildcard character is a character placeholder for any possible character
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.