basic - How to parse a time in years in QBasic -


how parse time (month/date/year) in microsoft qbasic, needed testing.

s = 'pt1h28m26s' 

i get:

num_mins = 88 

you can parse such time string code below, real question is:
still uses qbasic in 2015!?

cls s$ = "pt1h28m26s"  ' find key characters in string posp = instr(s$, "pt") posh = instr(s$, "h") posm = instr(s$, "m") poss = instr(s$, "s")  ' if 1 of values zero, multiplying 0 if ((posp * posh * posm * poss) = 0)   ' 1 or more key characters missing   nummins = -1   numsecs = -1 else   ' values string   shour$ = mid$(s$, posp + 2, (posh - posp - 2))   smin$ = mid$(s$, posh + 1, (posm - posh - 1))   ssec$ = mid$(s$, posm + 1, (poss - posm - 1))    ' string integer, can calculate   ihour = val(shour$)   imin = val(smin$)   isec = val(ssec$)    ' calculate totals   nummins = (ihour * 60) + imin   numsecs = (ihour * 60 * 60) + (imin * 60) + isec end if  ' display results print "number of minutes: "; nummins print "number of seconds: "; numsecs print "qbasic in 2015! w00t?!" 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -