View previous topic :: View next topic |
Author |
Message |
uga237
Joined: 15 May 2012 Posts: 32
|
Posted: Tue May 29, 2012 7:46 am Post subject: s = hex(const) |
|
|
$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 |
|
|
uga237
Joined: 15 May 2012 Posts: 32
|
Posted: Tue May 29, 2012 7:48 am Post subject: Re: s = hex(const) |
|
|
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 |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
Posted: Tue May 29, 2012 1:35 pm Post subject: |
|
|
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 |
|
|
uga237
Joined: 15 May 2012 Posts: 32
|
Posted: Tue May 29, 2012 1:58 pm Post subject: |
|
|
uncomfortable, and the use of constants in this form is convenient |
|
Back to top |
|
|
uga237
Joined: 15 May 2012 Posts: 32
|
Posted: Tue May 29, 2012 2:00 pm Post subject: |
|
|
and logical |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue May 29, 2012 3:29 pm Post subject: |
|
|
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 |
|
|
|