Hi! The title sums up my query. We're utilizing an ASCII/ANSI to text library (credits in lib) and want to expand it's use from single character calls to sending in a string of characters. In its original use case if '65' is passed in (ex: A2S(65), the character 'A' is returned as this is the equivalent text character for the integer 65 in ANSI. What we'd like to do is be able to send in multiple integers, ex: "97 98 99", and get the correct corresponding characters in return, in this case "abc".
Reference: ANSI and equivalent character set
Again our function, callA2S(string s), takes in a string, ex: "97 98 99", and for each integer (separated by spaces) a call is made to the function A2S(integer i) which returns a character. Finishing this example what would be returned is "abc".
We mocked up a simple second function, callA2S() that ideally iterates through a passed in string and calls A2S() for each integer. Any help is appreciated and our thanks in advance!
Best always,
j
Reference: ANSI and equivalent character set
Again our function, callA2S(string s), takes in a string, ex: "97 98 99", and for each integer (separated by spaces) a call is made to the function A2S(integer i) which returns a character. Finishing this example what would be returned is "abc".
We mocked up a simple second function, callA2S() that ideally iterates through a passed in string and calls A2S() for each integer. Any help is appreciated and our thanks in advance!
Best always,
j
JASS:
function callA2S takes string str returns string
local string s=""
local integer i=0
loop
s=s+A2S(i)
i=i+1
endloop
return s
endfunction
function Trig_Melee_Initialization_Actions takes nothing returns nothing
call DisplayTextToForce( GetPlayersAll(), callA2S("97 98 99") )
endfunction
JASS:
library Ascii
///////////////////////////////////////////////////////////////////
//
// credits: Bribe/TheDamian/Nestharus @ HiveWorkshop
//
// function A2S takes integer a returns string
// string rawcode = A2S('CODE')
// ex: A2S(97) returns a
//
///////////////////////////////////////////////////////////////////
globals
private string array c //char
endglobals
function A2S takes integer a returns string
local string s=""
loop
set s=c[a-a/256*256]+s
set a=a/256
exitwhen 0==a
endloop
return s
endfunction
private module Init
private static method onInit takes nothing returns nothing
set c[8]="\b"
set c[9]="\t"
set c[10]="\n"
set c[12]="\f"
set c[13]="\r"
set c[32]=" "
set c[33]="!"
set c[34]="\""
set c[35]="#"
set c[36]="$"
set c[37]="%"
set c[38]="&"
set c[39]="'"
set c[40]="("
set c[41]=")"
set c[42]="*"
set c[43]="+"
set c[44]=","
set c[45]="-"
set c[46]="."
set c[47]="/"
set c[48]="0"
set c[49]="1"
set c[50]="2"
set c[51]="3"
set c[52]="4"
set c[53]="5"
set c[54]="6"
set c[55]="7"
set c[56]="8"
set c[57]="9"
set c[58]=":"
set c[59]=";"
set c[60]="<"
set c[61]="="
set c[62]=">"
set c[63]="?"
set c[64]="@"
set c[65]="A"
set c[66]="B"
set c[67]="C"
set c[68]="D"
set c[69]="E"
set c[70]="F"
set c[71]="G"
set c[72]="H"
set c[73]="I"
set c[74]="J"
set c[75]="K"
set c[76]="L"
set c[77]="M"
set c[78]="N"
set c[79]="O"
set c[80]="P"
set c[81]="Q"
set c[82]="R"
set c[83]="S"
set c[84]="T"
set c[85]="U"
set c[86]="V"
set c[87]="W"
set c[88]="X"
set c[89]="Y"
set c[90]="Z"
set c[92]="\\"
set c[97]="a"
set c[98]="b"
set c[99]="c"
set c[100]="d"
set c[101]="e"
set c[102]="f"
set c[103]="g"
set c[104]="h"
set c[105]="i"
set c[106]="j"
set c[107]="k"
set c[108]="l"
set c[109]="m"
set c[110]="n"
set c[111]="o"
set c[112]="p"
set c[113]="q"
set c[114]="r"
set c[115]="s"
set c[116]="t"
set c[117]="u"
set c[118]="v"
set c[119]="w"
set c[120]="x"
set c[121]="y"
set c[122]="z"
set c[91]="["
set c[93]="]"
set c[94]="^"
set c[95]="_"
set c[96]="`"
set c[123]="{"
set c[124]="|"
set c[125]="}"
set c[126]="~"
endmethod
endmodule
private struct Inits extends array
implement Init
endstruct
endlibrary