[LuaVIEW-users] Hexadecimal constants
Dave Ludlam
dave at safebydesign.co.uk
Thu Aug 14 05:59:18 GMT+2 2008
Thanks Albert-Jan, I was being dim!
Never stopped to think that hex constants wouldn't be in Lua and as the
links take you to Lua 5.1 manuals I completely forgot that LuaVIEW uses 5.0.
Dave
-----Original Message-----
From: luaview-users-bounces at lists.luaforge.net
[mailto:luaview-users-bounces at lists.luaforge.net] On Behalf Of Albert-Jan
Brouwer
Sent: 13 August 2008 22:45
To: A forum for LabVIEW programmers that use LuaVIEW
Subject: Re: [LuaVIEW-users] Hexadecimal constants
Dave,
LuaVIEW is based on Lua 5.0 as you can check by
printing the _VERSION global or the string returned by
lv.luaversion(). Unlike Lua 5.1, Lua 5.0 does not handle
hex numbers in the parser.
However, you can obtain a number from a hexadecimal
string using the tonumber() function, e.g.:
print(tonumber("1A",16)) -> 26
To make it a little less ugly, you can define a helper
function like so:
function X(str) return tonumber(str, 16) end
print(X"DEADBEEF") -> 3735928559
_______________________________________________
LuaVIEW-users mailing list
LuaVIEW-users at lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/luaview-users
More information about the LuaVIEW-users
mailing list