Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Trouble with data type in Lookup Table

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
got_bascom

Bascom Member



Joined: 23 Feb 2015
Posts: 12

PostPosted: Sun Mar 01, 2015 4:19 pm    Post subject: Trouble with data type in Lookup Table Reply with quote

Hi gang,
I'm having trouble with figuring out what data type to use for an ultra simple lookup table.
I'm watching the system load values into the variables in the simulator.
Some of them I understand the datatype is understandably over-flowing.
But some of them I don't understand.
For example, when I try to use a Dword or a Double as a data type the compiler indicates "Wrong Data Type" error.
I really feel the Double, or the Dword are the best choice here but the compiler will not allow.
So far, I'm unable to find a data type that can accurately store all of the values in the table.
Must be something simple I'm missing!!

Here is the code:
Dim A As Byte ' used in for loop

'Variables experimental to see how they will store lookup values
Dim Varint As Integer
Dim Varword As Word
Dim Vardword As Dword
Dim Varlong As Long
Dim Varsingle As Single
Dim Vardouble As Double

For A = 0 To 11 Step 1
Varint = Lookup(a , Baudlookup)
Varword = Lookup(a , Baudlookup)
Vardword = Lookup(a , Baudlookup)
Varlong = Lookup(a , Baudlookup)
Varsingle = Lookup(a , Baudlookup)
Vardouble = Lookup(a , Baudlookup)
Next A

END

Baudlookup:
Data 300% , 600% , 1200% , 2400% , 4800% , 9600% , 19200% , 38400% , 57600% , 128000% , 256000% , 115200%

(BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.8 )
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 674

poland.gif
PostPosted: Sun Mar 01, 2015 4:49 pm    Post subject: Reply with quote

One table can be filled with variables of the same type only. If Word or Integer cannot accommodate value then biger type must be used and then in Help You can read:
Quote:
Integer and Word constants must end with the %-sign.
Long constants must end with the &-sign.
Single constants must end with the !-sign.
Double constants must end with the #-sign.
Back to top
View user's profile Visit poster's website
got_bascom

Bascom Member



Joined: 23 Feb 2015
Posts: 12

PostPosted: Sun Mar 01, 2015 5:45 pm    Post subject: Reply with quote

AH!
Thank you!
Where did you find that in the Help files?
I didn't see that in the "lookup" help text.
But from your post I did find it in the "Data" help text.

Many thanks!!
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 674

poland.gif
PostPosted: Sun Mar 01, 2015 5:54 pm    Post subject: Reply with quote

Bascom Wiki site , for which I have a shortcut in my browser.

http://wiki.mcselec.com/bavr/BASCOM-AVR_Help

On every sub site read "See also" where related keywords are showed.
So You find http://wiki.mcselec.com/bavr/DATA
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4975
Location: Holland

blank.gif
PostPosted: Sun Mar 01, 2015 8:41 pm    Post subject: Reply with quote

or use : avrhelp.mcselec.com
Part of the wiki is available in German too. And wiki users with rights can edit the articles. The help is static and an exact copy of the chm/hlp file.

_________________
Mark
Back to top
View user's profile Visit poster's website
PeterM

Bascom Member



Joined: 09 Jun 2008
Posts: 118

australia.gif
PostPosted: Sun Mar 01, 2015 9:42 pm    Post subject: Reply with quote

Quote:
But from your post I did find it in the "Data" help text.

Its towards the end just before the example under Difference with QB

_________________
Peter
Back to top
View user's profile
got_bascom

Bascom Member



Joined: 23 Feb 2015
Posts: 12

PostPosted: Sun Mar 01, 2015 10:56 pm    Post subject: Reply with quote

Thanks All!!
My learning curve :-]
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum