PDA

View Full Version : HEX -> DEC or sprintf



dev2000
08-07-2008, 02:03 PM
Hi. I'm writing an lscript that scans .lws files and keeps track of objectids for merging the objects of multiple scenes together. I need to convert hex numbers like "1000009b" to decimal and back again. Some numbers will need to be reassigned to avoid duplicates, gaps will be filled in, etc.

Standard sprintf should cover this simple conversion but I can't seem to find sprintf anywhere in lscript. I could write hex -> dec functions from scratch, but I'm certain that I'm overlooking something obvious here since this is likely a common task given objectids are represented in hex.

Thanks for any ideas!

jeremyhardin
08-08-2008, 05:25 AM
just use integer or number to convert from hex.

generic
{

info("0x20000000");
info(integer(0x20000000));
}
Docs cover math conversions here:
http://www.mikegreen.name/Lscript/Source/Math_Commands.htm#number