NewString = toString$(msg[0]) + toString$(msg[1])

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am

NewString = toString$(msg[0]) + toString$(msg[1])

Post by Rudi »

Hi

info:

msg is a variable type of String[100] that i read in from RS232..

i try simple this

Code: Select all

NewString = toString$(msg[0]) + toString$(msg[1]) + toString$(msg[2]) + toString$(msg[3]) + toString$(msg[4])
but the NewString ( in #char ) is false..

i try this

LC1..LC2 are String Variables [20]

Code: Select all


LC1 = toString$ (msg[0])
LC2 = toString$ (msg[1])
LC3 = toString$ (msg[2])
LC4 = toString$ (msg[3])
LC5 = toString$ (msg[4])

NewString = LC1 + LC2 + LC3 + LC4 + LC5

this will go on...
msg = Hello
NewString = 104101108108111
this is ok...

why? ;-)

what make i wrong with this

Code: Select all


NewString = toString$(msg[0]) + toString$(msg[1]) + toString$(msg[2]) + toString$(msg[3]) + toString$(msg[4])


and how can i make the newString as "hello" again
i would change the "104101108108111" to "hello"

example the other function from char$()

104 = char$("h")

"h" = ????(104)

like this

Code: Select all


NewString = CharToString(msg[0]) + CharToString(msg[1]) +CharToString(msg[2]) +CharToString(msg[3]) +CharToString(msg[4]) 



Thank you for your teach this!

best wishes

Rudi
;-)

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8878
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: NewString = toString$(msg[0]) + toString$(msg[1])

Post by medelec35 »

Hi Rudi ,
Not sure if this is what you're after?
Attached flowchart should read one valid ASCII at a time including spaces, then store in msg string variable until a carriage return is encountered. then will no longer receive characters.
Flowchart is just a demo.
I have done the flowchart in this way as i'm unsure reason for converting string to Char value, then storing in another string?
This is just a starting point.

When creating your own flowchart,I would recommend using UART RX interrupt if supported.

Martin
Attachments
Rs232Rx2.fcfx
(6.45 KiB) Downloaded 101 times
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
SteveM
Posts: 55
Joined: Tue Mar 25, 2014 2:09 pm
Contact:

Re: NewString = toString$(msg[0]) + toString$(msg[1])

Post by SteveM »

Rudi wrote:what make i wrong with this

Code: Select all

NewString = toString$(msg[0]) + toString$(msg[1]) + toString$(msg[2]) + toString$(msg[3]) + toString$(msg[4])

Hi Rudi,
As found by another user, it seems that there is a bug in Flowcode which is sometimes not allowing Strings to be added correctly - so I think you are doing nothing wrong, this line of code should work as you expect. In fact, if you tried to compile that line of code, it may even cause a compiler error. Our apologies for any time you may have spent trying to make the code work properly.
This has now been passed to the programming team to get fixed as soon as possible.

Best regards,
Steve.

User avatar
LeighM
Matrix Staff
Posts: 2043
Joined: Tue Jan 17, 2012 10:07 am
Contact:

Re: NewString = toString$(msg[0]) + toString$(msg[1])

Post by LeighM »

Hi Rudi,

As Steve says, there are some problems at the moment with concatenating strings.
But I also think you have some confusion about constructing strings and how characters are coded.
The toString macro converts a number into a string representation of it.
The character that is printed as an “h” is ASCII code number 104, as computers only understand numbers.
So if you are trying to re-construct a printable string NewString from msg string,
then one way to do it is to copy the numbers between the two arrays, e.g. NewString[0] = msg[0] etc..
Or you can copy the strings with NewString = msg
or part of it with NewString = Left$(msg,4)

Hope that helps, rather than confuse :)
Leigh

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am

Re: NewString = toString$(msg[0]) + toString$(msg[1])

Post by Rudi »

SteveM wrote:
Rudi wrote:what make i wrong with this

Code: Select all

NewString = toString$(msg[0]) + toString$(msg[1]) + toString$(msg[2]) + toString$(msg[3]) + toString$(msg[4])

Hi Rudi,
As found by another user, it seems that there is a bug in Flowcode which is sometimes not allowing Strings to be added correctly - so I think you are doing nothing wrong, this line of code should work as you expect. In fact, if you tried to compile that line of code, it may even cause a compiler error. Our apologies for any time you may have spent trying to make the code work properly.
This has now been passed to the programming team to get fixed as soon as possible.

Best regards,
Steve.

Hi Steve, ty!

i hink the same like this?
http://www.matrixmultimedia.com/mmforum ... =7&t=14488

ok... no problem i work then in char...
i have test all before i start with a nice project... i hope USB and Baudrate will go on at PIC24.. ;-) this ghost make fun to me.. ;-) ;-) ;-)
ah... and kill my phun ;-) ;-) ;-)..

i am "new" in all and my fist steps allways a Stone at way ;-)...
no problem,,, that let "beginner" look deep in code and i learn many in this...
ok.. no problem Steve..

i am happy that the Matrix Staff is allway helpfull in all..
i really happy --- your product is the best ever i have seen .. so i bought the FC6 with the chippacks for comerz - i will bougt next version too..
your Staff make a great Service!!!

each project is really fast in begin.. and the conzept is great.

nobody is perfect - and what "you not make game over that make you hard"...
so i am sure in future FC will be >Simple the Best< ... i think not only in future... at Time -- FC is >Simple the Best< now

Matrix Staff is hard working ( Benj is great!!! i wish we have Benj in our concern .. this guy is "with "Body and soul" in FC ( i hope i have translate correct this is a "Praise Award" what i mean.. )
I will read next time more in Wiki how FC is handle .. i will learn this ... i have many happy hour with the prog .
FC have so much "hidden features".. and is great Diversity.. i hope i will find this and can work next time so skillfully as Benj -- and other from Matrix Staff.

Best wishes from Germany!
Rudi
;-)



LeighM wrote:
...But I also think you have some confusion about constructing strings and how characters are coded.

....Hope that helps, rather than confuse :)
Leigh
Hi Leigh,

..confuse..confuse ..confus ;-) ;-)

;-) ;-) ;-)

...

i test all :-)
^^^^^^^^

;-)

,...but you are right... the coding is not so right from me..
i will test all before i start up... because if i coding.. i will write like i think..
and then is going on..i am new in mikrocontroller.. :-) ;-) ;-)

...ty!!!

Best wishes!
Rudi
;-)

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am

Re: NewString = toString$(msg[0]) + toString$(msg[1])

Post by Rudi »

?

Post Reply