de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Send/receive: inconsistent strings with numbers
PostPosted: Sat Mar 05, 2022 6:25 pm 
Offline
Regular
I found an unexpected behavior in the send/recieveString functions: It strips strings of leading zeros if they only contain digits, for example:
Code:
def key = "sendtest"
def a = "01"
send(key, a)
def b = receiveString(key)
show("$a vs $b")
send(key, null)

gives me: "01 vs 1". Adding a letter changes that to normal.

Can you confirm and fix please? I understand it is useful when transmitting integers, but would expect strings to stay the same no matter what they contain, e.g. when using them as IDs.


Top
 Profile Send private message 
 
 Re: Send/receive: inconsistent strings with numbers
PostPosted: Tue Mar 29, 2022 1:05 pm 
Offline
Site Admin
User avatar
Your test is good, and I agree that it should behave differently with such a test, but it is now a special condition : keys can be read in batch (when you use a dot notation), and so every value should be, in this case, casted to the good type (int, float, boolean, string or a full map). In such a case, where the user can't choose the type of each one, "01" will be converted to a number ; needing an heterogeous behaviour, we do this cast on any receiveXXX(), even if it's surprising.

So add a special character or a letter before the value if the value may be converted to a number and you don't want it.


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.