vidnum\$ Convert Function Windows

A  function that returns the string representation of  of a rounded numeric expression.

Syntax: vidnum\$ (numeric-expression, dig%)

Num\$ = vidnum\$ (999999.2366666666, 4)
Return  999999.2367

Num\$ = vidnum\$ (-0.236, 4)
Return  -0.236

Num\$ =vidnum\$ (-12389.236, -2)
Return -12400

Details:
dig% - number of significant digits

function Hex2Dec (HexStr as string) as string

A function that returns the decimal (base 10) representation of the hexidecimal (base 16) string expression

function DecToHex (Dec as string) as string
A function that returns the hexidecimal (base 16) representation of the (base 10) string expression

String  is not pre-padded with 0's

function Add0Before (NumStr as string , ReqLength as int) as string
A function that pre-padd string with 0's to required Length

-0387.35

FUNCTION ByteReOrder (ByteStr\$,ReOrder\$ ) as string
A function that reorder bytes in string.
Detailes:
ReOrder\$  -
Defines the  order of bytes following  in ByteStr\$

abcde  initial string
2145
output order - i.e.
2 byte to 1 posicion

1 byte to 2 posicion
4 byte to 3 posicion
5 byte to 4 posicion

Examples:

number\$ =ByteReOrder ("0123","2143" )

Return
"1032"
------------------------
inpStr\$="1234":             print "inpStr\$=" ,inpStr\$
reOrder\$="222143":      print "reOrder\$=" ,reOrder\$
ssd\$=ByteReOrder (inpStr\$,reOrder\$ )
print "ByteReOrder="+ ssd\$

Return
ByteReOrder=2221
-------------------------
number\$ =ByteReOrder ("1234","143" )
Return  1434
-------------------------
ssd\$=ByteReOrder ("abcde","2149" )

Error:  ShowMessage( "ReOrder index outbound input string"):exit FUNCTION

there are no 9 byte in "abcde" string

FUNCTION CNumByte (Num, Num_Type as short ) as string

FUNCTION CNumByte  converts   number of Num_Type type to bytes sequence.

Num_Type can be next value:
CONST Num_SHORT = 2
CONST Num_WORD = 3
CONST Num_LONG = 4
CONST Num_DWORD = 5
CONST Num_SINGLE = 6
CONST Num_DOUBLE = 8

FUNCTION CByteNum (ByteStr\$,Num_Type as short ) as variant

FUNCTION CByteNum  converts bytes sequence to  number of Num_Type type

Num_Type can be next value:

CONST Num_SHORT = 2
CONST Num_WORD = 3
CONST Num_LONG = 4
CONST Num_DWORD = 5
CONST Num_SINGLE = 6
CONST Num_DOUBLE = 8

Examples:
iNitNum=1234.56789

SngStr\$=CNumByte (iNitNum, Num_siNGLE )

DblStr\$=CNumByte (iNitNum, Num_DouBLE )

print "Num_siNGLE=",CByteNum (SngStr\$,Num_siNGLE )
print "Num_DouBLE=",CByteNum (DblStr\$,Num_DouBLE )

Return
iNitNum=1234.567890000

SngStr\$=,R?D
DblStr\$=зЖф"EJ"@

Num_siNGLE=1234.567871094
Num_DouBLE=1234.567890000

LIKE Function - pattern matching routine for Rapid-Q by William Yu
This emulates the VB LIKE operator.
Thanks to Thomas Binder for the original C code

? Any single character.
* Zero or more characters.
# Any single digit (0-9).
[charlist] Any single character in charlist.
[!charlist] Any single character not in charlist.

A group of one or more characters (charlist) enclosed in brackets ([ ])  can be used to match any single character in string and can include almost  any character code, including digits.

Note: To match the special characters left bracket ([), question  mark (?), number sign (#), and asterisk (*), enclose them in brackets.
The right bracket (]) can't be used within a group to match itself, but  it can be used outside a group as an individual character.

By using a hyphen (-) to separate the upper and lower bounds of the range,  charlist can specify a range of characters. For  example, [A-Z] results in  a match if the corresponding character position in string contains any  uppercase letters in the range A-Z. Multiple ranges are included within  the brackets without  delimiters.

'-- Test code

print "Like('24','##')=", Like("24","##")

?"Like(aBBBa, a*a)=", Like("aBBBa","a*a")
?Like("F","[!A-Z]")
?Like("a2a","a#a")
?Like("aM5b","a[A-GL-P]#[!c-e]")
?Like("BAT123khg","B?T*")
?Like("CAT123khg","B?T*")

?Like("Combine(10, 20) = 30", "*(*?,*?)*=*#")

return

Like('24','##')=1
Like(aBBBa, a*a)=1
0
1
1
1
0
1

function TimeString (TimSec as integer) as string

TimeString=Hr\$+":"+Min\$+":"+Sec\$+" "

'-- **************************************************************************'
function SecTime (cTime\$ as string) as integer
TimeHH=val (field\$(cTime\$, ":",1))
TimeMM=val (field\$(cTime\$, ":",2))
TimeSS=val (field\$(cTime\$, ":",3))
result=TimeHH*3600+TimeMM*60+TimeSS
end function

'-- **************************************************************************'
function DayDate (cDate\$ as string) as integer

MM=val (field\$(cDate\$, "-",1))
Day=val (field\$(cDate\$, "-",2))
Year=val (field\$(cDate\$, "-",3))

result=365*(Year)+30*(MM)+(Day)
end function