Go Down

Topic: working with strings, cut in parts (Read 2570 times) previous topic - next topic

mcanet

Hi,

I have to cut a long String in a parts.
Are there in wiring language commands look like substring to cut long string?

best regards,

Mar Canet

beltran

that's a good question,
I've been gibbling around with this for a week
and I'm going to post a tutorial soon (hopefully tonight)
it's all about handeling multiple bytes in Arduino.

but ofcourse if any other advanced user has some tips for us newbies that would be just great! :)

in general the C language (and Arduino as far as I know) can't handle strings natively.
in C you can import a string library but you need to do some workarounds in Arduino to set it up.
the basic concept is that a string is an array of single bytes or chars. In the samples I'm preparing there should be reusable functions for this kind of problems. and an Actionscript Class to easily set up a communication between Flash and Arduino.

I'll get back here to give you the url and to let the Arduino masters tell me If I got the right or wrong method. ;)

l8r
b.


mellis

Beltran, I can't wait to see what you come up with.

Mar: what do you want to use the substrings for?  As Beltran said, C's (and therefore Arduino's) handling of strings isn't the best, but we should be able to find a method of doing what you need.

mcanet

I send thought serial port a string like that "0101010101". This string have a information to open or close a the power in a diferents pins in the Arduino.

B.

Mar

beltran

ok try here,

http://www.progetto25zero1.com/b/tools/Arduino/

these are the examples I've set up to work with long strings.

what you probably should do after reading it,
and hence storing it into a String-Array,
is loop trhough that array and at every index associate your action to your relative pin.
for that you could use another array in which you store the pin numbers at the same index as your StringArray

check it out.


hey david, please tell me what you think of the code :)
I've never written anything in C and so this got my head quite a lot before understanding the right syntax. I'm a designer not a computer scientist :)

ciao
b.

David Cuartielles

Hej Beltran,

your code looks great, in fact I will post D. Mellis about it and we may consider to include it as it is in one of our libraries.

Please keep the good work ;-)

/David

beltran

cool  :) !

hopefully today I'll also post the Arduino Actionscript 2.0 class for flash.

ciao
b.

Go Up