string as number problem

Ask for help

Moderators: Murderator+, Murderator

Post Reply
xinxilas
Posts: 78
Joined: 2009-03-10 09:43:01

string as number problem

Post by xinxilas »

sub plate()
var f,n,x=1
dim a[6]
a[1] = '0x1415 0'; Chest
a[2] = '0x1411 1'; Legs
a[3] = '0x1414 0'; Gloves
a[4] = '0x1413 1'; Gorget
a[5] = '0x1410 1'; Arms
a[6] = '0x1412 0'; Helmet
repeat
for n=1 to 6
f=MID(a[n], 7, 1)
uo.msg(f)
if f==1 then
...

Look..
It is all okay...
f for n=1 is 0
f for n=2 is 1
etc...
the msgs shows it allright...

But.. when i verify it here: if f==1 then
none of them return true

and...

if i put if f>1 then
all of them return true...

what should i do?
Last edited by xinxilas on 2010-01-17 05:24:53, edited 1 time in total.
xinxilas
Posts: 78
Joined: 2009-03-10 09:43:01

Post by xinxilas »

well i fixed..

if f=='1'

i need to transform the valour of f
to NUMBER, and not text...


because i need to do things like that:

f=f+1

What can i do?
Scripts Writer
Posts: 2259
Joined: 2005-04-19 18:00:29
Location: Московская область
Contact:

Post by Scripts Writer »

Code: Select all

sub test()
  var f = "1"
  uo.Print(STR(VAL(f)+1))
end sub


Result: 2
xinxilas
Posts: 78
Joined: 2009-03-10 09:43:01

Post by xinxilas »

Very good...
f=(VAL(MID(a[n], 7, 1)))

it worked... :D
Scripts Writer
Posts: 2259
Joined: 2005-04-19 18:00:29
Location: Московская область
Contact:

Post by Scripts Writer »

I know :)
Post Reply