|
Post by eyfenna on Jul 8, 2017 12:32:14 GMT -6
although i am writing this in bas code
a native variant of val that can get if a string is a hexadecimal number or that reads a string as hexadecimal number would be nice. especially with tile maps.
|
|
|
Post by eyfenna on Jul 9, 2017 10:29:33 GMT -6
Does the job although I'm sure there is a faster variant:
function getHx(string$) dim value[length(string$)] for i = 0 to length(string$)-1 if(val(mid$(string$,i,1))=0) then if not mid$(string$,i,1) = "0" then for j = 10 to 15 step 1 if Hex$(j) = mid$(string$,i,1) then value[i] = j end if next else value[i] = val(mid$(string$,i,1)) end if else value[i] =val( mid$(string$,i,1)) end if next integer = 0 outcome = 0 for i = 0 to arraysize(value,1)-1 j = 0 integer = value[i] if (i <> arraysize(Value,1)-1) then while(arraysize(Value,1)-1 -i -j > 0) integer = integer*16 j = j +1 wend outcome = outcome + integer else outcome = outcome + integer end if j=0 next return outcome end function
|
|
|
Post by n00b on Jul 9, 2017 22:49:12 GMT -6
I think this is probably the best way to accomplish what you needed. I may implement a native function for this eventually but it I just want to get the core features I have been working on done before I tackle anything else.
|
|