Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Math from list
#1
Hi there,

I have this list on my clipboard like this:

8:00 10m
10:00 15m

what i like to do is to extraxt the 10m/15m and use the "10/15" of it for a calculation.

Can this be done?

Greetings

Sonic
#2
Macro Macro5
Code:
Copy      Help
;8:00 10m
;10:00 15m
out
str s.getclip       ;; get time from clipboard
s.findreplace("m")  ;; remove letter 'm'
ARRAY(str) a        ;; array to hold tokenized items
int ntok=tok(s a)   ;; tokenize string
;for int'i 0 a.len  ;; double check
,;out a[i]
int min1=val(a[2])  ;; get 1st min value
int min2=val(a[5])  ;; get 2nd min value
out _s.format("1st minute = %d[]2nd minute = %d", min1 min2)

;If you want to use the "10/15" result for your calculation, then do this

double dMin1 = min1*1.0
double dMin2 = min2*1.0
double result = dMin1/dMin2
str output.format("result = %.2f" result)
out output


Forum Jump:


Users browsing this thread: 1 Guest(s)