'if you can put the data in a string with a predictable format, then you can do math on it
dat$ = "0 All races, 1 Human, 2 elves, 4 Orcs, 8 Draenea, 16 Trolls, 32 blood elves"
Split dat$, ", ", races$()
'what is the total of all the races?
vals
(i
) = VAL(leftOf$
(races$
(i
), " ")) total = total + vals(i)
PRINT "Total Races should be "; total
a = vals(race)
ar$ = rightOf$(races$(race), " ")
getop:
INPUT "Enter + , -, * , / ", op$
b = vals(race)
br$ = rightOf$(races$(race), " ")
CASE "+":
PRINT ar$;
" + "; br$;
" = "; a
+ b
CASE "-":
PRINT ar$;
" - "; br$;
" = "; a
- b
CASE "*":
PRINT ar$;
" * "; br$;
" = "; a
* b
CASE "/":
PRINT ar$;
" / "; br$;
" = "; a
/ b
selectRace:
PRINT "Enter Number of Race to add, subtract, mult, divide:" PRINT i;
" "; rightOf$
(races$
(i
), " ")
'notes: REDIM the array(0) to be loaded before calling Split '<<<<<<<<<<<<<<<<<<<<<<< IMPORTANT!!!!
' bplus modifications of Galleon fix of Bulrush Split reply #13
' http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=1612.0
' this sub further developed and tested here: \test\Strings\Split test.bas
copy = mystr 'make copy since we are messing with mystr
'special case if delim is space, probably want to remove all excess space
copy
= MID$(copy
, 1, p
- 1) + MID$(copy
, p
+ 1) curpos = 1
arrpos = 0
dpos
= INSTR(curpos
, copy
, delim
) arr
(arrpos
) = MID$(copy
, curpos
, dpos
- curpos
) arrpos = arrpos + 1
curpos
= dpos
+ LEN(delim
) dpos
= INSTR(curpos
, copy
, delim
) arr
(arrpos
) = MID$(copy
, curpos
)
posOf
= INSTR(source$
, of$
) IF posOf
> 0 THEN leftOf$
= MID$(source$
, 1, posOf
- 1)
posOf
= INSTR(source$
, of$
)