Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

s = hex(const)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
uga237

Bascom Member



Joined: 15 May 2012
Posts: 32

blank.gif
PostPosted: Tue May 29, 2012 7:46 am    Post subject: s = hex(const) Reply with quote

$regfile = "xm256A3def.dat"
$crystal = 32000000
$hwstack = 1024
$swstack = 1024
$framesize = 1024

Const Value = &HAA
Dim Str_a As String * 30

Str_a = Hex(value)


Error : 42 Line : 10 Numeric parameter expected [170] , in File : C:\Atmel\PDA\BASCOM\PDA\noname3.bas

want to work it )
Back to top
View user's profile
uga237

Bascom Member



Joined: 15 May 2012
Posts: 32

blank.gif
PostPosted: Tue May 29, 2012 7:48 am    Post subject: Re: s = hex(const) Reply with quote

not to offer a:

$regfile = "xm256A3def.dat"
$crystal = 32000000
$hwstack = 1024
$swstack = 1024
$framesize = 1024


Const Value = &HAA
Dim Str_a As String * 30
Dim B As Byte

B = Value
Str_a = Hex(b)
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Tue May 29, 2012 1:35 pm    Post subject: Reply with quote

Hi,

Try that:
Code:
Const MyStringHexValue = "AA"
Dim Str_a As String * 30
Str_a = MyStringHexValue

The HEX() function expects a variable and will use code space and resources at run-time.

Best regards,

Luciano
Back to top
View user's profile
uga237

Bascom Member



Joined: 15 May 2012
Posts: 32

blank.gif
PostPosted: Tue May 29, 2012 1:58 pm    Post subject: Reply with quote

uncomfortable, and the use of constants in this form is convenient
Back to top
View user's profile
uga237

Bascom Member



Joined: 15 May 2012
Posts: 32

blank.gif
PostPosted: Tue May 29, 2012 2:00 pm    Post subject: Reply with quote

and logical
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6197
Location: Holland

blank.gif
PostPosted: Tue May 29, 2012 3:29 pm    Post subject: Reply with quote

str() behaves the same. it expects a variable since a constant has a value already known, and when i added the hex/str functions i could not see benefit from converting already known values:
const x=170
s = str(x) , which would be "170". For the hex, yes, that is not so obvious. i will add it to the next release. the compiler will replace the constant and assigns a string constant : s = "AA".

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive 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