combining variables
Dan-
The following is pretty simple and takes advantage of the Stamp's
expression evaluation scheme:
xyz = x * 10 + y * 10 + z
Regards,
Steve
On 18 Feb 02 at 13:30, daniel.d.dangremond@j... wrote:
> Stampers,
> I know this question was answered once before but I thought I'd ask
> again....
>
> I have three variables that I want to combine to make a three digit
> number: x var 2 y var 3 z var 4 I need the result to be: <234>...
The following is pretty simple and takes advantage of the Stamp's
expression evaluation scheme:
xyz = x * 10 + y * 10 + z
Regards,
Steve
On 18 Feb 02 at 13:30, daniel.d.dangremond@j... wrote:
> Stampers,
> I know this question was answered once before but I thought I'd ask
> again....
>
> I have three variables that I want to combine to make a three digit
> number: x var 2 y var 3 z var 4 I need the result to be: <234>...
Comments
I know this question was answered once before but I thought I'd ask
again....
I have three variables that I want to combine to make a three digit number:
x var 2
y var 3
z var 4
I need the result to be: <234>
I know that:
(x*100)+(y*10)+z=<xyz>
or:
a=x*100
b=y*10
c=z
result = a+b+c
But is there a simpler method?
Thanks in advance,
Dan
>Dan-
>
>The following is pretty simple and takes advantage of the Stamp's
>expression evaluation scheme:
>
>xyz = x * 10 + y * 10 + z
I may be off the mark here, but should the above not be: xyz = x * 100 + y
* 10 + z ('hundreds' should be * 100 instead of *10)
dwayne
Dwayne Reid <dwayner@p...>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax
Celebrating 18 years of Engineering Innovation (1984 - 2002)
.-. .-. .-. .-. .-. .-. .-. .-. .-. .-
`-' `-' `-' `-' `-' `-' `-' `-' `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.
I think I have too little sleep and too much solder fumes!
Dan
parkiss@earth
link.net To: basicstamps@yahoogroups.com
cc:
02/18/2002 Subject: Re: [noparse][[/noparse]basicstamps]
combining variables
12:16 AM
Please
respond to
basicstamps
Dan-
The following is pretty simple and takes advantage of the Stamp's
expression evaluation scheme:
xyz = x * 10 + y * 10 + z
Regards,
Steve
On 18 Feb 02 at 13:30, daniel.d.dangremond@j... wrote:
> Stampers,
> I know this question was answered once before but I thought I'd ask
> again....
>
> I have three variables that I want to combine to make a three digit
> number: x var 2 y var 3 z var 4 I need the result to be: <234>...
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
operations.
Dwayne Reid wrote:
> At 01:16 PM 2/18/02 +0800, S Parkis wrote:
> >Dan-
> >
> >The following is pretty simple and takes advantage of the Stamp's
> >expression evaluation scheme:
> >
> >xyz = x * 10 + y * 10 + z
>
> I may be off the mark here, but should the above not be: xyz = x * 100 + y
> * 10 + z ('hundreds' should be * 100 instead of *10)
>
> dwayne
>
> Dwayne Reid <dwayner@p...>
> Trinity Electronics Systems Ltd Edmonton, AB, CANADA
> (780) 489-3199 voice (780) 487-6397 fax
>
> Celebrating 18 years of Engineering Innovation (1984 - 2002)
> .-. .-. .-. .-. .-. .-. .-. .-. .-. .-
> `-' `-' `-' `-' `-' `-' `-' `-' `-'
> Do NOT send unsolicited commercial email to this email address.
> This message neither grants consent to receive unsolicited
> commercial email nor is intended to solicit commercial email.
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Xyz=x*10+y*10+z is the same as:
Xyz = (((x*10)+y)*10)+z
Which is algebraically the same as x*100+y*10+z (using "normal" math
notation).
This is sort of the way you do it in a loop with user input or an array:
Result=0
For i=3 to 0 step -1
Result=result*10
Result=result+x[noparse][[/noparse]i] ' x is the "next number"
Next
Al Williams
AWC
* Easy RS-232 Prototyping
http://www.al-williams.com/awce/rs1.htm
>
Original Message
> From: Dwayne Reid [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=qZ11k7Xbi3B0I5I6WCfa_BgIEp_30nWYPkjsamEQwraO1zpg5-F4l4CsIHjnj_srp1EROS0rR_i_5eVoReQg_og]dwayner@p...[/url
> Sent: Monday, February 18, 2002 3:43 PM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] combining variables
>
>
> At 01:16 PM 2/18/02 +0800, S Parkis wrote:
> >Dan-
> >
> >The following is pretty simple and takes advantage of the Stamp's
> >expression evaluation scheme:
> >
> >xyz = x * 10 + y * 10 + z
>
>
> I may be off the mark here, but should the above not be: xyz
> = x * 100 + y
> * 10 + z ('hundreds' should be * 100 instead of *10)
>
> dwayne
>
>
> Dwayne Reid <dwayner@p...>
> Trinity Electronics Systems Ltd Edmonton, AB, CANADA
> (780) 489-3199 voice (780) 487-6397 fax
>
> Celebrating 18 years of Engineering Innovation (1984 - 2002)
> .-. .-. .-. .-. .-. .-. .-. .-. .-. .-
> `-' `-' `-' `-' `-' `-' `-' `-' `-'
> Do NOT send unsolicited commercial email to this email
> address. This message neither grants consent to receive
> unsolicited commercial email nor is intended to solicit
> commercial email.
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
> Subject and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
When my reply got posted, I thought it looked rude. Sorry about that.
I'll try again, more politely:
The order of operations in the BS2 is purely left to right -- it doesn't
follow the precedence rules we were taught in school (exponents,
mult/div,
add/subtract. Remember that, and you can see why xyz = x * 10 + y * 10
+ z
works.
Clark Hughes
Dwayne Reid wrote:
>
> At 01:16 PM 2/18/02 +0800, S Parkis wrote:
> >Dan-
> >
> >The following is pretty simple and takes advantage of the Stamp's
> >expression evaluation scheme:
> >
> >xyz = x * 10 + y * 10 + z
>
> I may be off the mark here, but should the above not be: xyz = x * 100 + y
> * 10 + z ('hundreds' should be * 100 instead of *10)
>
> dwayne
>
> Dwayne Reid <dwayner@p...>
> Trinity Electronics Systems Ltd Edmonton, AB, CANADA
> (780) 489-3199 voice (780) 487-6397 fax
>
> Celebrating 18 years of Engineering Innovation (1984 - 2002)
> .-. .-. .-. .-. .-. .-. .-. .-. .-. .-
> `-' `-' `-' `-' `-' `-' `-' `-' `-'
> Do NOT send unsolicited commercial email to this email address.
> This message neither grants consent to receive unsolicited
> commercial email nor is intended to solicit commercial email.
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
--
J. Clark Hughes
Applied Research Laboratories
The University of Texas
Austin, Texas
you want to call it an operator...?
On Mon, 18 Feb 2002, J. Clark Hughes wrote:
> Dwayne:
>
> When my reply got posted, I thought it looked rude. Sorry about that.
> I'll try again, more politely:
>
> The order of operations in the BS2 is purely left to right -- it doesn't
> follow the precedence rules we were taught in school (exponents,
> mult/div,
> add/subtract. Remember that, and you can see why xyz = x * 10 + y * 10
> + z
> works.
>
> Clark Hughes
>
> Dwayne Reid wrote:
> >
> > At 01:16 PM 2/18/02 +0800, S Parkis wrote:
> > >Dan-
> > >
> > >The following is pretty simple and takes advantage of the Stamp's
> > >expression evaluation scheme:
> > >
> > >xyz = x * 10 + y * 10 + z
> >
> > I may be off the mark here, but should the above not be: xyz = x * 100 + y
> > * 10 + z ('hundreds' should be * 100 instead of *10)
> >
> > dwayne
> >
> > Dwayne Reid <dwayner@p...>
> > Trinity Electronics Systems Ltd Edmonton, AB, CANADA
> > (780) 489-3199 voice (780) 487-6397 fax
> >
> > Celebrating 18 years of Engineering Innovation (1984 - 2002)
> > .-. .-. .-. .-. .-. .-. .-. .-. .-. .-
> > `-' `-' `-' `-' `-' `-' `-' `-' `-'
> > Do NOT send unsolicited commercial email to this email address.
> > This message neither grants consent to receive unsolicited
> > commercial email nor is intended to solicit commercial email.
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> > from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
> --
>
>
> J. Clark Hughes
> Applied Research Laboratories
> The University of Texas
> Austin, Texas
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
Sean T. Lamont, CTO / Chief NetNerd, Abstract Software, Inc. (ServNet)
Seattle - Bellingham - Vancouver - Portland - Everett - Tacoma - Bremerton
email: lamont@a... WWW: http://www.serv.net
"...There's no moral, it's just a lot of stuff that happens". - H. Simpson
>Dwayne:
>
>When my reply got posted, I thought it looked rude. Sorry about that.
No offense taken! Thanks to all for the more detailed explanations.
dwayne
Dwayne Reid <dwayner@p...>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax
Celebrating 18 years of Engineering Innovation (1984 - 2002)
.-. .-. .-. .-. .-. .-. .-. .-. .-. .-
`-' `-' `-' `-' `-' `-' `-' `-' `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.
wanted to assemble the string, "234"
using, say, Qbasic, you could just concatenate. Can you do this with pbasic
commands?
Best, Michael
"J. Clark Hughes" wrote:
> Dwayne:
>
> When my reply got posted, I thought it looked rude. Sorry about that.
> I'll try again, more politely:
>
> The order of operations in the BS2 is purely left to right -- it doesn't
> follow the precedence rules we were taught in school (exponents,
> mult/div,
> add/subtract. Remember that, and you can see why xyz = x * 10 + y * 10
> + z
> works.
>
> Clark Hughes
>
> Dwayne Reid wrote:
> >
> > At 01:16 PM 2/18/02 +0800, S Parkis wrote:
> > >Dan-
> > >
> > >The following is pretty simple and takes advantage of the Stamp's
> > >expression evaluation scheme:
> > >
> > >xyz = x * 10 + y * 10 + z
> >
> > I may be off the mark here, but should the above not be: xyz = x * 100 + y
> > * 10 + z ('hundreds' should be * 100 instead of *10)
> >
> > dwayne
> >
> > Dwayne Reid <dwayner@p...>
> > Trinity Electronics Systems Ltd Edmonton, AB, CANADA
> > (780) 489-3199 voice (780) 487-6397 fax
> >
> > Celebrating 18 years of Engineering Innovation (1984 - 2002)
> > .-. .-. .-. .-. .-. .-. .-. .-. .-. .-
> > `-' `-' `-' `-' `-' `-' `-' `-' `-'
> > Do NOT send unsolicited commercial email to this email address.
> > This message neither grants consent to receive unsolicited
> > commercial email nor is intended to solicit commercial email.
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> > from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
> --
>
>
> J. Clark Hughes
> Applied Research Laboratories
> The University of Texas
> Austin, Texas
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
michcg@m... writes:
> Since this has come up, I am wondering about strings: From the example, if
> you wanted to assemble the string, "234"
> using, say, Qbasic, you could just concatenate. Can you do this with pbasic
>
There are no character or string types in PBASIC. The best you can do is use
an array of bytes and put the characters into as you desire. You'll have to
specify the character position in the array; concatenating won't work.
myStr VAR Byte(3)
myStr(0) = "2"
myStr(1) = "3"
myStr(2) = "4"
DEBUG STR myStr\3
-- Jon Williams
-- Parallax
[noparse][[/noparse]Non-text portions of this message have been removed]