Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,63 @@
|
|||
#include <hopper.h>
|
||||
|
||||
#proto splitdate(_DATETIME_)
|
||||
#proto splitnumber(_N_)
|
||||
#proto split(_S_,_T_)
|
||||
|
||||
main:
|
||||
|
||||
s="this string will be separated into parts with space token separator"
|
||||
|
||||
aS=0,let( aS :=_split(s," "))
|
||||
|
||||
{","}toksep // set a new token separator
|
||||
{"String: ",s}
|
||||
{"\nArray:\n",aS},
|
||||
{"\nSize="}size(aS),println // "size" return an array: {dims,#rows,#cols,#pages}
|
||||
|
||||
{"\nOriginal number: ",-125.489922},println
|
||||
w=0,let(w:=_split number(-125.489922) )
|
||||
{"Integer part: "}[1]get(w) // get first element from array "w"
|
||||
{"\nDecimal part: "}[2]get(w),println // get second element from array "w"
|
||||
|
||||
{"\nDate by DATENOW(TODAY) macro: "},print
|
||||
dt=0, let( dt :=_splitdate(datenow(TODAY);!puts)) // "!" keep first element from stack
|
||||
{"\nDate: "}[1]get(dt)
|
||||
{"\nTime: "}[2]get(dt),println
|
||||
|
||||
exit(0)
|
||||
|
||||
.locals
|
||||
splitdate(_DATETIME_)
|
||||
_SEP_=0,gettoksep,mov(_SEP_) // "gettoksep" return actual token separator
|
||||
{","}toksep, // set a new token separator
|
||||
_NEWARRAY_={}
|
||||
{1},$( _DATETIME_ ),
|
||||
{2},$( _DATETIME_ ),pushall(_NEWARRAY_)
|
||||
{_SEP_}toksep // restore ols token separator
|
||||
{_NEWARRAY_}
|
||||
back
|
||||
|
||||
splitnumber(_X_)
|
||||
part_int=0,part_dec=0,
|
||||
{_X_},!trunc,mov(part_int),
|
||||
minus(part_int), !sign,mul
|
||||
xtostr,mov(part_dec), part_dec+=2, // "part_dec+=2", delete "0." from "part_dec"
|
||||
{part_dec}xtonum,mov(part_dec)
|
||||
_NEWARRAY_={},{part_int,part_dec},pushall(_NEWARRAY_)
|
||||
{_NEWARRAY_}
|
||||
back
|
||||
|
||||
split(_S_,_T_)
|
||||
_NEWARRAY_={},_VAR1_=0,_SEP_=0,gettoksep,mov(_SEP_)
|
||||
{_T_}toksep,totaltoken(_S_),
|
||||
mov(_VAR1_), // for total tokens
|
||||
_VAR2_=1, // for real position of tokens into the string
|
||||
___SPLIT_ITER:
|
||||
{_VAR2_}$( _S_ ),push(_NEWARRAY_)
|
||||
++_VAR2_,--_VAR1_
|
||||
{ _VAR1_ },jnz(___SPLIT_ITER) // jump to "___SPLIT_ITER" if "_VAR1_" is not zero.
|
||||
clear(_VAR2_),clear(_VAR1_)
|
||||
{_SEP_}toksep
|
||||
{_NEWARRAY_}
|
||||
back
|
||||
Loading…
Add table
Add a link
Reference in a new issue