mirror of
https://github.com/irmen/prog8.git
synced 2026-04-21 17:16:33 +00:00
don't give error when returning uword value in subroutine that returns STR
This commit is contained in:
@@ -391,6 +391,13 @@ Using the ``in`` operator you can easily check if a character is present in a st
|
||||
example: ``if '@' in email_address {....}`` (however this gives no clue about the location
|
||||
in the string where the character is present, if you need that, use the ``string.find()``
|
||||
library function instead)
|
||||
**Caution:**
|
||||
This checks *all* elements in the string with the length as it was initially declared.
|
||||
Even when a string was changed and is terminated early with a 0-byte early,
|
||||
the containment check with ``in`` will still look at all character positions in the initial string.
|
||||
Consider using ``string.find`` followed by ``if_cs`` (for instance) to do a "safer" search
|
||||
for a character in such strings (one that stops at the first 0 byte)
|
||||
|
||||
|
||||
.. hint::
|
||||
Strings/arrays and uwords (=memory address) can often be interchanged.
|
||||
|
||||
@@ -611,16 +611,11 @@ containment check: ``in``
|
||||
txt.print("cc is one of the values")
|
||||
}
|
||||
|
||||
str email_address = "?????????"
|
||||
str email_address = "name@test.com"
|
||||
if '@' in email_address {
|
||||
txt.print("email address seems ok")
|
||||
}
|
||||
|
||||
.. caution::
|
||||
This check compares the needle against *all* elements in the haystack.
|
||||
For byte arrays and strings(!), this means it considers *all* elements in the array or string with the length as it was declared.
|
||||
Even when a string was changed and is terminated early with a 0-byte early.
|
||||
Consider using ``string.find`` followed by ``if_cs`` (for instance) to do a "safer" containment check in such strings.
|
||||
|
||||
address of: ``&``
|
||||
This is a prefix operator that can be applied to a string or array variable or literal value.
|
||||
|
||||
Reference in New Issue
Block a user