Sort of bug supplying ip address to functions

Report bugs. Post bug workarounds or fixes

Moderator: MSandro

Post Reply
SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Sort of bug supplying ip address to functions

Post by SimpleSi » Aug 4th, '17, 22:18

Not mainstream but in trying to write networking stuff using primitive GP elements such as

openClientSocket

I'm finding that GP is very "moody" over what it thinks is an acceptable Ip address

it won't accept 1.2.3.4, (thinks its 1.2) - it usually accepts join (1.2.3.4) () or join (1) (.) (2) (.) (3) (.) (4) but not always - once it doesn't project needs to be saved then re-loaded

It won't accept to string (1.2.3.4) - thinks its 1.2

basically GP treats anything with a . in it as a number (most of the time)

I think if GP should treat any field in a join as being a string - even if it has a . in it

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Sort of bug supplying ip address to functions

Post by JohnM » Aug 4th, '17, 23:48

If you used "blockify", you may have created the block with a number input slot vs. a string slot.

Note the difference between blockifying this with quotes around 1.2.3.4:

Code: Select all

 openClientSocket '1.2.3.4' 80
scriptImage1.png
scriptImage1.png (5.57 KiB) Viewed 11334 times
versus no quotes:

Code: Select all

 openClientSocket 1.2.3.4 80
scriptImage.png
scriptImage.png (5.15 KiB) Viewed 11334 times
You'll notice that in the first case you get a square ended input slot (string) and in the second case you get a rounded input slot (number). In the second case, GP also tried to interpret 1.2.3.4 as a number, but it only took the first three characters because you can't have two decimal points in a number.

Moral: when using blockify, put single quotes around anything that you want to be sure is a string.

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: Sort of bug supplying ip address to functions

Post by SimpleSi » Aug 5th, '17, 10:21

Got it

So this was one of those things where the question wasn't, why didn't it work all the time, but in fact how come it worked some of the time :)

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Sort of bug supplying ip address to functions

Post by JohnM » Sep 20th, '17, 20:14

The "number or string" input slots in v75 do a much better job at detecting things that start with a digit but are not numbers, such as IP addresses.

So '1.2.3.4' or '3 + 5' will not be treated as strings rather than trying to force them to be numbers and getting values like 1.2 or 3.

In addition, you can now use a context menu force an input slot to expect only numbers, only strings, or either (with the slot guessing the user's intent based on whether the format is a legal number:
Screen Shot 2017-09-20 at 4.09.15 PM.png
Screen Shot 2017-09-20 at 4.09.15 PM.png (15.23 KiB) Viewed 5124 times
Note that an input slot set to 'string or number' will change shape to indicate when a number is recognized. Square ends indicate that the contents is being read as a string, rounded ends indicate a number. In 'number only' mode, the slot will only accept input that is a valid integer or floating point number.

String:
Screen Shot 2017-09-20 at 4.10.11 PM.png
Screen Shot 2017-09-20 at 4.10.11 PM.png (7.84 KiB) Viewed 5124 times

Number:
Screen Shot 2017-09-20 at 4.10.20 PM.png
Screen Shot 2017-09-20 at 4.10.20 PM.png (7.59 KiB) Viewed 5124 times

Number treated as a string in 'string only' mode:
Screen Shot 2017-09-20 at 4.09.29 PM.png
Screen Shot 2017-09-20 at 4.09.29 PM.png (6.72 KiB) Viewed 5121 times

With these changes, users will have control over the difference between strings and numbers in input slots.

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: Sort of bug supplying ip address to functions

Post by SimpleSi » Sep 20th, '17, 20:24

Excellent - I'd been running into issues and using join to overcome them - will let you know if anything crops up now

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: Sort of bug supplying ip address to functions

Post by SimpleSi » Sep 20th, '17, 20:32

The only thing I'd mention at moment is that if you try use a returned numerical value in a place that expects a string - it fails unless you explicitly convert

It'd be nice if it didn't but arguable that it fact it should fail :)
scriptsImage.png
scriptsImage.png (10.22 KiB) Viewed 5113 times

Post Reply