Shop OBEX P1 Docs P2 Docs Learn Events
Concatenating Variables — Parallax Forums

Concatenating Variables

Chris SpaconeChris Spacone Posts: 7
edited 2009-07-20 05:34 in BASIC Stamp
I would like to accomplish the following:

Port_0_Val = $FF - this is the low portion of the ports_val
Port_1_Val = $FF - this is the high portion of the ports_val
Ports_Val =$FFFF - this would be the concatenated variable

I reviewed page 89 of the BS Syntax & Ref manual covering aliases and modifiers. I'm then lead to the conclusion that the following should work

Ports_Val VAR Word ' this is the final value I want to evaluate
Port_0_Val VAR Ports_Val.LOWBYTE 'This is the low portion of Ports_Val
Port_1_Val VAR Ports_Val.HIGHBYTE 'This is the high portion of Ports_Val

Question: am I on the right track? Does the LOWBYTE line and HIGHBYTE line order of appearance matter?

Thanks,
Chris

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
TWSRO schmismo! Low level scanning is the key to total field perception!

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-07-19 21:54
    What you have will assign Port_0_Val and Port_1_Val from the Word variable. But that’s not what you’re trying to do. You can assign the word variable from the byte variables by using the following code…

    Ports_Val.LOWBYTE = Port_0_Val
    Ports_Val.HIGHBYTE = Port_1_Val

    This could also be done in a single line by:

    Ports_Val = Port_1_Val << 8 + Port_0_Val

    I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering


    Post Edited (Chris Savage (Parallax)) : 7/19/2009 9:59:28 PM GMT
  • Chris SpaconeChris Spacone Posts: 7
    edited 2009-07-20 05:34
    I'll give it a try and let you know how it works out. Thanks for the help!

    -Chris

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    TWSRO schmismo! Low level scanning is the key to total field perception!
Sign In or Register to comment.