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


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 addition issues
PostPosted: Sun Jan 14, 2018 10:46 pm 
Offline
Veteran
User avatar
having issues with the following
Code:
def a=0,b=0,c=0,d=0,e=1,f=1,g=1,h=1
code=receiveString("script.x")        ( x is held as "1^1^1^1")
(a,b,c,d) = code.tokenize("^")
a=a+e
b=b+f
c=c+g
d=d+h
code=a+"^"+b+"^"+c+"^"+d
send("script.x",code)

I'm expecting code to end as 2^2^2^2
but I get 11^11^11^11
where have I gone wrong?

I'm assuming the tokenise command is resetting a - d as strings but using 'as int' doesn't help

_________________
"If you don't gosub a program loop, you'll never get a subroutine."


Top
 Profile Send private message 
 
 Re: addition issues
PostPosted: Mon Jan 15, 2018 12:15 pm 
Offline
Site Admin
User avatar
code.tokenize("^") is a function that returns an array of strings, not an array of integers (even if those strings contains some digits)
This would work :
Code:
def a=0,b=0,c=0,d=0,e=1,f=1,g=1,h=1
code=receiveString("script.x")        ( x is held as "1^1^1^1")
(a,b,c,d) = code.tokenize("^")
a=a.toInteger()+e
b=b.toInteger()+f
c=c.toInteger()+g
d=d.toInteger()+h
code=a+"^"+b+"^"+c+"^"+d
send("script.x", code)


Top
 Profile Send private message 
 
 Re: addition issues
PostPosted: Mon Jan 15, 2018 9:53 pm 
Offline
Veteran
User avatar
That’s great thanks, I’m using tokenize to try to do everything in one call rather than repeating for each item.

_________________
"If you don't gosub a program loop, you'll never get a subroutine."


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 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:  


cron
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.