If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
and arrays again
16 posts
• Page 2 of 2 • 1, 2
Re: and arrays again
tester wrote:This one works reasonably fine
Yeh..the way he's written the index in at all stages is what i was stuck with...
Adjusted my code with it and it's great...got the starting point i was after...
Thanks nubeat7
- Code: Select all
def event i,v,t
if i == 0 then
x = 0
data=[]
5.times do
data[x]= @a[x].to_s + "-" + @b[x].to_s
x +=1
output 1,t
end
output 0,data
watch data
end
end
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: and arrays again
billv wrote:
- Code: Select all
def event i,v,t
if i == 0 then
x = 0
data=[]
5.times do
data[x]= @a[x].to_s + "-" + @b[x].to_s
x +=1
output 1,t
end
output 0,data
watch data
end
end
but like this it is fixed to a length of 5! why not using @a.length or @b.length or get the longest/shortest before
also, when "using 0.upto length|x| do" or "for x in 0..length do" the x would be the iteration so you dont need an extra variable and adding +1 to it each iteration
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: and arrays again
Nubeat7 wrote: fixed to a length
Yeh...that code was just the starting point.
I added the length fix next, moved the code around a bit so it's easier to work.
brought the de-limiters out as well, so you can use a different one at each stage...
It's looking ok, it's working with float,int or string but I've notice commas won't go through....
Tried to get a gsub thing in there so when there is space in the array you can fill it
with something....but struggled there...so probably have to do it before array goes .to_s
- Code: Select all
def event i,v,t
if i == 0 then
x = 0
data=[]
d1=@d1
d2=@d2
d3=@d3
d4=@d4
findlength =[]
aa = @a.length
bb = @b.length
cc = @c.length
findlength =[aa,bb,cc]
c = findlength.each_with_index.max
d = c.max
d.times do
a = @a[x].to_s
b = @b[x].to_s
c = @c[x].to_s
data[x]= a + d1 + b + d2 + c
x +=1
end
output 0,data
watch d
end
end
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: and arrays again
Did the last bit...(providing a default string if array slot empty).worked out well.
The whole thing seems to work great.
I fixed up a basic module that's ready to use...
@tester
Note that it functions somewhat like a basic 'router'....
as you've noted before processing the data as it goes through the chain is another story.......
It's good that you've already got Trog's monster system up and running...seems ideal...
That's where I'm going now....
The whole thing seems to work great.
I fixed up a basic module that's ready to use...
@tester
Note that it functions somewhat like a basic 'router'....
as you've noted before processing the data as it goes through the chain is another story.......
It's good that you've already got Trog's monster system up and running...seems ideal...
That's where I'm going now....
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: and arrays again
Thanks for efforts.
As for Trogs monster, I digest it, but meanwhile I'm focused on wiring the main structures. The weather isn't helping yet :-]
As for Trogs monster, I digest it, but meanwhile I'm focused on wiring the main structures. The weather isn't helping yet :-]
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
16 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 73 guests