BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:35 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Question about modifiers
PostPosted: Thu Aug 25, 2011 7:09 pm 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
This is from the manual:
DEC
DEC{#max} expression{\#min}
#max: optional maximum number of digits to send
#min: optional minimum number of digits to send
The DEC modifi er when used in an output command will convert a stored values to ASCII characters.
The example will format the value of temp so it prints out the number in a terminal window. The output
would display 1234.
temp var word
temp = 1234
serout s_out, i9600, [DEC temp] ;prints “1234”


My problem:
I am trying to relearn PBASIC again for my project (yep...that is left over from last winter) and of course have forgot just about how to do everything with PBASIC :(

I am trying to limit the number of digits displayed; I assumed that the #max expression would in theory limit the digits being displayed beginning with the left.

So I thought something like serout s_out, i9600, [DEC\2 temp] would print 34 but no deal. No matter what combination of "syntax" I use nothing seems to work. Can someone provide a simple code example or am I off target of how the #max expression "works"

Thanks-Brian


Top
 Profile  
 
 Post subject: Re: Question about modifiers
PostPosted: Fri Aug 26, 2011 11:54 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
dec temp\2 would set the minimum characters displayed but not limit the maximum. Use both min and max to limit to a specific number:

dec2 temp\2 will only display the 2 low digits and will always display 2 digits even if the value is less then 10(eg 09,08,01,00)

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Question about modifiers
PostPosted: Mon Aug 29, 2011 6:00 pm 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
Thanks for the quick response to my question Nathan!

OK...I didn't try that combination/syntax...feel kind of foolish on that question!

Perhaps maybe adding a few code example(s) using the MAX option on a modifier example may help in the future (I kept trying to use the # symbol in my code)

Thanks-Brian


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO