TIME$
Moderators:Administrator, Global Moderator
Hello all,
How do I split apart TIME$ so I can save it as 3 variables?
thank you.
How do I split apart TIME$ so I can save it as 3 variables?
thank you.
Splitting time$ into three parts...
or.... Why not simply use Mid$???
You can get all three parts just using that one alone
and better yet you can do it in a loop... and place the output into an array of strings, in one easy step...
the advantage?? the whole set of related time sets of characters are neatly sored away into a single object...
rather than three... dim an array of type string * how ever long each "piece" is:
the piece size for each time variable is n% here
rem $DYNAMIC
n%= ....
dim array(n%) as string *2
and dim it to 2 (normal defualt for arrays is to start from 0)
then use a mid$ with a variable , but be sure to add one to the variable used with the mid$ after making any other necessary adjustments, then loop some variable
for x% = 0 to 2
b% = x% + 1
array(x%)=mid$(time$,b%,n%)
next x%
program has to be started with the /ah /cmd $dynamic metacomand in order to work , otherwise It will not like the above dim command
This will also work for stripping ANY string into predefined segments.. I hope you enjoy!
You can get all three parts just using that one alone
and better yet you can do it in a loop... and place the output into an array of strings, in one easy step...
the advantage?? the whole set of related time sets of characters are neatly sored away into a single object...
rather than three... dim an array of type string * how ever long each "piece" is:
the piece size for each time variable is n% here
rem $DYNAMIC
n%= ....
dim array(n%) as string *2
and dim it to 2 (normal defualt for arrays is to start from 0)
then use a mid$ with a variable , but be sure to add one to the variable used with the mid$ after making any other necessary adjustments, then loop some variable
for x% = 0 to 2
b% = x% + 1
array(x%)=mid$(time$,b%,n%)
next x%
program has to be started with the /ah /cmd $dynamic metacomand in order to work , otherwise It will not like the above dim command
This will also work for stripping ANY string into predefined segments.. I hope you enjoy!
Here is the program I just wrote that splits time very nicely into three parts and puts them into an array...
DECLARE SUB gorp ()
DIM SHARED array(2) AS STRING * 2
CALL gorp
PRINT array(0)
PRINT array(1)
PRINT array(2)
------ this part here gets created as a SUBROUTINE call:
SUB gorp
SHARED array() AS STRING * 2
r$ = TIME$
n% = 2
FOR x% = 0 TO 2
b% = 3 * x% + 1
array(x%) = MID$(r$, b%, n%)
NEXT x%
END SUB
hope this helps....
DECLARE SUB gorp ()
DIM SHARED array(2) AS STRING * 2
CALL gorp
PRINT array(0)
PRINT array(1)
PRINT array(2)
------ this part here gets created as a SUBROUTINE call:
SUB gorp
SHARED array() AS STRING * 2
r$ = TIME$
n% = 2
FOR x% = 0 TO 2
b% = 3 * x% + 1
array(x%) = MID$(r$, b%, n%)
NEXT x%
END SUB
hope this helps....
Mmmm...............
That's a lot of coding...........
-
- Jr. Member
- Posts:10
- Joined:Sat Feb 14, 2009 3:26 pm
- Location:New York, U.S.
TIME$
It is a good idea to set another variable to TIME$ so that it doesn't change while parsing. Just a hint.