Putting strings in Vars
Archiver
Posts: 46,084
Hi All,
Simple question I am sure, but I can't seem to find the answer. How do I store a
string in a VAR?
myVar VAR Word
myVar = "My String"
This results in "Error, expected ":" or end of line". I can work around this
with SEROUT commands, as the strings are displayed on an LCD, but it is clumsy
and uses more lines. I know there has to be a way to do it!
Thanks,
Jonathan Peakall
www.madlabs.info
[noparse][[/noparse]Non-text portions of this message have been removed]
Simple question I am sure, but I can't seem to find the answer. How do I store a
string in a VAR?
myVar VAR Word
myVar = "My String"
This results in "Error, expected ":" or end of line". I can work around this
with SEROUT commands, as the strings are displayed on an LCD, but it is clumsy
and uses more lines. I know there has to be a way to do it!
Thanks,
Jonathan Peakall
www.madlabs.info
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
serstring var byte(4)
This gives you a variable with four bytes. Only bytes, not word, bit or nib.
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
statements, like this:
Msg1 DATA "I love BASIC Stamps!", 0
Msg2 DATA "BASIC Stamps rule!", 0
Important: Notice that each string is terminated with a 0 (zero).
Then you can dump them to your display with a simple subroutine. Before you
call this subroutine, you must set the first character address in the
variable called eeAddr. This is as easy as
eeAddr = Msg1
...when using DATA statements as above. Here's the code that prints it:
Print_String:
READ eeAddr, char ' get a character
IF (char = 0) THEN Print_Done ' if zero, we're done
DEBUG char ' print the character
eeAddr = eeAddr + 1 ' point to next
GOTO Print_String
Print_Done:
RETURN
I hope this helps you.
-- Jon Williams
-- Applications Engieer, Parallax
In a message dated 6/29/02 10:04:35 AM Central Daylight Time,
jpeakall@m... writes:
> Hi All,
>
> Simple question I am sure, but I can't seem to find the answer. How do I
> store a string in a VAR?
>
> myVar VAR Word
> myVar = "My String"
>
> This results in "Error, expected ":" or end of line". I can work around
> this with SEROUT commands, as the strings are displayed on an LCD, but it
> is clumsy and uses more lines. I know there has to be a way to do it!
>
> Thanks,
>
> Jonathan Peakall
>
[noparse][[/noparse]Non-text portions of this message have been removed]
displayed a lot of text on an LCD as the user scrolled through the menus.
This was taking up a lot of my programming space. I know all of this can be
offloaded to an external eeprom but the pointer and memory locations always
get me confused and then the hassle of recalling the data through some sort
of counter. I just bought an lcd from scott edwards(TRM-425L), that can
store 90 pages of text for you. All you do is program in the text and give
it a number between 0 and 90. Then when you want the whole page of text a
simple command with the number of where it resides brings up the whole page.
This along with a keypad decoder makes a nifty little device. A bit pricey
but worth it.
Original Message
From: <jonwms@a...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, June 29, 2002 12:11 PM
Subject: Re: [noparse][[/noparse]basicstamps] Putting strings in Vars
> There is no String type in PBASIC. What you can do is store strings in
DATA
> statements, like this:
>
> Msg1 DATA "I love BASIC Stamps!", 0
> Msg2 DATA "BASIC Stamps rule!", 0
>
> Important: Notice that each string is terminated with a 0 (zero).
>
> Then you can dump them to your display with a simple subroutine. Before
you
> call this subroutine, you must set the first character address in the
> variable called eeAddr. This is as easy as
>
> eeAddr = Msg1
>
> ...when using DATA statements as above. Here's the code that prints it:
>
> Print_String:
> READ eeAddr, char ' get a character
> IF (char = 0) THEN Print_Done ' if zero, we're done
> DEBUG char ' print the character
> eeAddr = eeAddr + 1 ' point to next
> GOTO Print_String
>
> Print_Done:
> RETURN
>
> I hope this helps you.
>
> -- Jon Williams
> -- Applications Engieer, Parallax
>
>
>
> In a message dated 6/29/02 10:04:35 AM Central Daylight Time,
> jpeakall@m... writes:
>
>
> > Hi All,
> >
> > Simple question I am sure, but I can't seem to find the answer. How do I
> > store a string in a VAR?
> >
> > myVar VAR Word
> > myVar = "My String"
> >
> > This results in "Error, expected ":" or end of line". I can work around
> > this with SEROUT commands, as the strings are displayed on an LCD, but
it
> > is clumsy and uses more lines. I know there has to be a way to do it!
> >
> > Thanks,
> >
> > Jonathan Peakall
> >
>
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> 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/
>
>
>
>
What stamp does your 'string' code supposed to work on, it doesn't work
on my BASIC STAMP 2 ???? Gives errors ?? What's up ???
leroy
jonwms@a... wrote:
>
> There is no String type in PBASIC. What you can do is store strings in DATA
> statements, like this:
>
> Msg1 DATA "I love BASIC Stamps!", 0
> Msg2 DATA "BASIC Stamps rule!", 0
>
> Important: Notice that each string is terminated with a 0 (zero).
>
> Then you can dump them to your display with a simple subroutine. Before you
> call this subroutine, you must set the first character address in the
> variable called eeAddr. This is as easy as
>
> eeAddr = Msg1
>
> ...when using DATA statements as above. Here's the code that prints it:
>
> Print_String:
> READ eeAddr, char ' get a character
> IF (char = 0) THEN Print_Done ' if zero, we're done
> DEBUG char ' print the character
> eeAddr = eeAddr + 1 ' point to next
> GOTO Print_String
>
> Print_Done:
> RETURN
>
> I hope this helps you.
>
> -- Jon Williams
> -- Applications Engieer, Parallax
>
> In a message dated 6/29/02 10:04:35 AM Central Daylight Time,
> jpeakall@m... writes:
>
> > Hi All,
> >
> > Simple question I am sure, but I can't seem to find the answer. How do I
> > store a string in a VAR?
> >
> > myVar VAR Word
> > myVar = "My String"
> >
> > This results in "Error, expected ":" or end of line". I can work around
> > this with SEROUT commands, as the strings are displayed on an LCD, but it
> > is clumsy and uses more lines. I know there has to be a way to do it!
> >
> > Thanks,
> >
> > Jonathan Peakall
> >
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
> 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/
Stamp editor and it works fine on a stock BS2. Remember, I didn't supply a
whole program, just the working parts. You have to define the variables used
by the subroutine and then actually call it with GOSUB.
-- Jon Williams
In a message dated 6/29/02 1:03:28 PM Central Daylight Time, leroy@f...
writes:
> Dear Jon;
>
> What stamp does your 'string' code supposed to work on, it doesn't work
> on my BASIC STAMP 2 ???? Gives errors ?? What's up ???
>
>
> leroy
>
> jonwms@a... wrote:
> >
> > There is no String type in PBASIC. What you can do is store strings in
> DATA
> > statements, like this:
> >
> > Msg1 DATA "I love BASIC Stamps!", 0
> > Msg2 DATA "BASIC Stamps rule!", 0
> >
> > Important: Notice that each string is terminated with a 0 (zero).
> >
> > Then you can dump them to your display with a simple subroutine. Before
> you
> > call this subroutine, you must set the first character address in the
> > variable called eeAddr. This is as easy as
> >
> > eeAddr = Msg1
> >
> > ...when using DATA statements as above. Here's the code that prints it:
> >
> > Print_String:
> > READ eeAddr, char ' get a character
> > IF (char = 0) THEN Print_Done ' if zero, we're done
> > DEBUG char ' print the character
> > eeAddr = eeAddr + 1 ' point to next
> > GOTO Print_String
> >
> > Print_Done:
> > RETURN
> >
> > I hope this helps you.
> >
> > -- Jon Williams
> > -- Applications Engieer, Parallax
> >
> > In a message dated 6/29/02 10:04:35 AM Central Daylight Time,
> > jpeakall@m... writes:
> >
> > > Hi All,
> > >
> > > Simple question I am sure, but I can't seem to find the answer. How do I
> > > store a string in a VAR?
> > >
> > > myVar VAR Word
> > > myVar = "My String"
> > >
> > > This results in "Error, expected ":" or end of line". I can work around
> > > this with SEROUT commands, as the strings are displayed on an LCD, but
> it
> > > is clumsy and uses more lines. I know there has to be a way to do it!
> > >
> > > Thanks,
> > >
> > > Jonathan Peakall
> > >
>
[noparse][[/noparse]Non-text portions of this message have been removed]
the whole program, but then I did not have the whole program to paste.
Sorry about the error..
Leroy
jonwms@a... wrote:
>
> You must be doing something wrong ... I just pasted that routine into my
> Stamp editor and it works fine on a stock BS2. Remember, I didn't supply a
> whole program, just the working parts. You have to define the variables used
> by the subroutine and then actually call it with GOSUB.
>
> -- Jon Williams
>
> In a message dated 6/29/02 1:03:28 PM Central Daylight Time, leroy@f...
> writes:
>
> > Dear Jon;
> >
> > What stamp does your 'string' code supposed to work on, it doesn't work
> > on my BASIC STAMP 2 ???? Gives errors ?? What's up ???
> >
> >
> > leroy
> >
> > jonwms@a... wrote:
> > >
> > > There is no String type in PBASIC. What you can do is store strings in
> > DATA
> > > statements, like this:
> > >
> > > Msg1 DATA "I love BASIC Stamps!", 0
> > > Msg2 DATA "BASIC Stamps rule!", 0
> > >
> > > Important: Notice that each string is terminated with a 0 (zero).
> > >
> > > Then you can dump them to your display with a simple subroutine. Before
> > you
> > > call this subroutine, you must set the first character address in the
> > > variable called eeAddr. This is as easy as
> > >
> > > eeAddr = Msg1
> > >
> > > ...when using DATA statements as above. Here's the code that prints it:
> > >
> > > Print_String:
> > > READ eeAddr, char ' get a character
> > > IF (char = 0) THEN Print_Done ' if zero, we're done
> > > DEBUG char ' print the character
> > > eeAddr = eeAddr + 1 ' point to next
> > > GOTO Print_String
> > >
> > > Print_Done:
> > > RETURN
> > >
> > > I hope this helps you.
> > >
> > > -- Jon Williams
> > > -- Applications Engieer, Parallax
> > >
> > > In a message dated 6/29/02 10:04:35 AM Central Daylight Time,
> > > jpeakall@m... writes:
> > >
> > > > Hi All,
> > > >
> > > > Simple question I am sure, but I can't seem to find the answer. How do I
> > > > store a string in a VAR?
> > > >
> > > > myVar VAR Word
> > > > myVar = "My String"
> > > >
> > > > This results in "Error, expected ":" or end of line". I can work around
> > > > this with SEROUT commands, as the strings are displayed on an LCD, but
> > it
> > > > is clumsy and uses more lines. I know there has to be a way to do it!
> > > >
> > > > Thanks,
> > > >
> > > > Jonathan Peakall
> > > >
> >
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
> 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/