Special mention: (5:282) and negative numbers

This line is getting a special mention because it doesn't let you extract a negative number (like -10) from a string.

For example, if we have a string called ~CookieDebt with the text ‘Our cookie debt is: -48’ in it, and we tried to extract the negative balance of cookies that we have in our Dream with the (5:282) line into a variable called %CookieBalance:

(5:282) set variable %CookieBalance to the first number in ~CookieDebt.

The %CookieBalance variable would receive the value 48. Now, you may wonder why this occurs.. after all, variables are perfectly capable of holding negative integers! However, this doesn't work here due to how strings parse text.

In a string, the symbol - is seen as a text character, a hyphen, rather than as the minus component of a negative number. Therefore, the (5:282) line is incapable of distinguishing between the two.

Now, this may become problematic if your DS handles negative numbers within strings. A workaround involves using PS to convert a negative number in a string to a numerical number that can be used in a variable. Please refer to the PhoenixSpeak Manipulation section for more information on the workaround.

Account E-Mail

Password