| 12-21-2009, 10:20 AM | #1 |
Sup! JASS:local string test = "'hpea'" local integer id = S2I(test) call BJDebugMsg(I2S(id)) Why doesn't this work? I need to convert the integer from the string to an object ID. |
| 12-21-2009, 10:26 AM | #2 |
lol... maybe should S2I also conver 0xff ? (hexademical) you need to write own algorithm (function) to convert raw to decimal. i have done this with a preprocessor. |
| 12-21-2009, 10:51 AM | #3 |
Because 'hpea' isn't a string, it's an integer. just display I2S('hpea') |
| 12-21-2009, 11:01 AM | #4 |
Toadcoap, could you help me? I need to generate IDs out of a string. For example: "'hpea', 'Hpal'" should return 2 integers, 'hpea' and 'Hpal'. |
| 12-21-2009, 05:09 PM | #5 |
Requires ASCII. JASS:
function String2Rawcode takes string s returns integer
local integer i = StringLength(s)
local integer j = 1
local integer k = 0
loop
exitwhen i == 0
set i = i-1
set k = k+Char2Ascii(SubString(s, i, i+1))*j
set j = j*256
endloop
return k
endfunction
function blah takes nothing returns nothing
local string test = "'hpea'"
local integer id = String2Rawcode(test)
call BJDebugMsg(I2S(id))
endfunction
|
| 12-21-2009, 05:33 PM | #6 | |
Quote:
|
| 12-21-2009, 05:38 PM | #7 | |
Quote:
unfortunately for you string to integer only seems to parse number in decimnal notation. i dont recall if i testd it, but its likely "010" would retrun 10 rather than 8 |
| 01-04-2010, 09:15 AM | #8 |
But is 'Hpal' exactly the same as the integer of the 'Hpal' id? Is is threated the same way? Because I would need this CreateItem(ID, 0., 0.) with a parsed string. |
| 01-04-2010, 10:10 AM | #9 |
you can enter integer as decimal hex or raw BUT game process decimal only. |
