How can a String variable be sent using the RS232 Component?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

How can a String variable be sent using the RS232 Component?

Post by Mark »

I want to send a String variable via the RS232 Component,

Sending "Hello" as a predefined string works OK, but

trying to send the variable String where string = "Hello" is not accepted by the component.

I can hive off individiual characters from the string using
characterstring = mid$(string,X,1) and incrementing X.

However, I can find no way of changing characterstring into a byte variable so as to provide something that the RS232 component will accept.

Please advise.

Thanks in advance,

Mark

ps a string appears to recieve fine, as in string = string + RS232byteinput to build up a string.
Go with the Flow.

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Hello Mark,

The RS232 component "send" macro accepts a single character. To get the single character out of the string, you can access it as an array of characters. Here's a simple prog with variables len (byte), i (byte) and s (string):

Code: Select all

String manipulation:
s = "Hello Mark!"
len = Length$(s)

Calculation:
i = 0

Loop:
While i < len

Call Component Macro:
RS232:SendRS232Char( s[i] )

Calculation:
i = i + 1

End Loop:
Not ideal, but should work ok.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello Mark

Also you can use a string manipulation icon to do the following

Code: Select all

Calculation
i = 0

String Manipulation
STR = "Hello"
CHR = Char$(STR, i)

Component Macro
RS232:SendRS232Char(CHR) 

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Post by Mark »

Once again thanks Guys. :)

Both methods work fine. I was looking for the Char$ command but failed to spot it as it is only in a list in the help file rather than as an illustrated example along with the other functions.

best regards,

Mark
Go with the Flow.

Post Reply