cannot pass 16-digit number to function as string argument
Moderator: MSandro
cannot pass 16-digit number to function as string argument
i was trying to pass a string of 16 digits as a string to a function but the argument is treated as a number , not as a string, so it becomes garbled.
converting the number string to a list argument works but i have to change the function logic accordingly,
it also works if i create an artificial string by surrounding it with quotes or apostrophes, or prefixing with some special character but i have to deal with removing them in the function.Re: cannot pass 16-digit number to function as string argument
Many GP input slots (such as the one in the 'return' block) accept either a number or a string. They guess the type based on what you type. If the string has the correct syntax for an integer or floating point numbers, it guesses that you intend for it to be a number. When GP guesses that the input is a number, it changes the shape of the input slot from rectangular (string) to rounded (number).
In this case, however, you want to pass a string of 16 digits, and you want GP to treat it as a string, even though it has the syntax of a (large!!) integer. There are two ways to tell GP what you mean.
First, you can use a menu to set the input slot to "string only":
Note that the slot remains rectangular, indicating that it will be treated as a string.
Second, you can use the "quotes" block from the "Words" category:
The former requires one less block but isn't as obvious or easily discovered.
In this case, however, you want to pass a string of 16 digits, and you want GP to treat it as a string, even though it has the syntax of a (large!!) integer. There are two ways to tell GP what you mean.
First, you can use a menu to set the input slot to "string only":
Note that the slot remains rectangular, indicating that it will be treated as a string.
Second, you can use the "quotes" block from the "Words" category:
The former requires one less block but isn't as obvious or easily discovered.
Re: cannot pass 16-digit number to function as string argument
thank you! i wish i had known this sooner!