• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] S2i

Status
Not open for further replies.
heres the code sry couldve sworn i pasted the code lol it pastes it every 5 seconds
it was just to see how it worked
JASS:
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
    local integer i = 0 
    set tempinteger = tempinteger + 1
    if tempinteger == 1 then
        set i = S2I("A1")
        call BJDebugMsg(I2S(i))
        set i = S2I("A3")
        call BJDebugMsg(I2S(i))
        set i = S2I("A5")
        call BJDebugMsg(I2S(i))
        set i = S2I("A7")
        call BJDebugMsg(I2S(i))
    endif
endfunction
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
The function S2I(string) has to contain a string that is only a number, nothing else: S2I("50") would return 50.
The moment there's any other character in the string, it will be set to 0.

In case you were wondering how things like 'A001' work, then this post can help a little.
Basically, 'A001' isn't a string (it never was). It's an integer, just like 48 (decimal) is an integer, or 0010010 (binary) is an integer and 8F (hexadecimal) is an integer.
It uses a base-256 system.

is there any way to convert it to integer ?
This works: call BJDebugMsg( I2S('a') ).
It will return 97 (because a = 97 in the ASCII-table).
'A' will return 65.

The problem is that (I believe) it can only contain either 1 character (like 'a'), or 4 characters (like 'abcd').
2 or 3 won't work (haven't tried any higher either).

But then again, those aren't strings :/.
 
ik about ASCII values but thx apocalypse although i did not know the actual values i knew about it thx for the link anyways

next question is there any way to change strings to ascii ?
also y does '"A1"' and '"A3"' give same values ?
i was hoping this way would work but no it does is there any way to get something like this to work ? thx
JASS:
        set i = S2I("'00A1'")
        call BJDebugMsg(I2S(i))
        set i = S2I("'00A3'")
        call BJDebugMsg(I2S(i))
        set i = S2I("'00A5'")
        call BJDebugMsg(I2S(i))
        set i = S2I("'00A7'")
        call BJDebugMsg(I2S(i))
 
Last edited:
'"A1"' has the ascii (') on the ends and (") in between them im guessing tht the (") r the ones tht mess w the ascii values and ik they arent in object editor what im trying to do has nothing to do w object editor im just trying to find a way to convert a string like "A1" or "A3" into an integer like if im in a game and type A1 in the chat i was trying to convert tht to an integer i could use for other things
 
ik about ASCII values but thx apocalypse although i did not know the actual values i knew about it thx for the link anyways

next question is there any way to change strings to ascii ?
also y does '"A1"' and '"A3"' give same values ?
i was hoping this way would work but no it does is there any way to get something like this to work ? thx
JASS:
        set i = S2I("'00A1'")
        call BJDebugMsg(I2S(i))
        set i = S2I("'00A3'")
        call BJDebugMsg(I2S(i))
        set i = S2I("'00A5'")
        call BJDebugMsg(I2S(i))
        set i = S2I("'00A7'")
        call BJDebugMsg(I2S(i))

You need
JASS:
set i = '00A1'
call BJDebugMsg(I2S(i))

This is because '00A1'is not a string, nor a character (just as ap0calypse said)
 
Status
Not open for further replies.
Top