|
Post by pierre on Oct 26, 2022 3:55:28 GMT -5
I cannot get to work the double precision and currency values with the NUMBERMANDLL.
The proposed function failes at the entry point in the dll. If I understand correctly, the required input value is a decimal NUMBER. That number is then formatted by the VAL(USING....) formula ---> it remains a NUMBER. When this number hits the dll, a non cntinuable protection violation occurs and LB crashes.
A few lines to illustrate this:
open "NUMBERMANDLL" for dll AS #NUM STRUCT tDbl,_ Dbl AS DOUBLE
Value = 123456.789 NumChrs = 0 tDbl.Dbl.struct = VAL(USING("######.###", Value)) print tDbl.Dbl.struct ValInStr$ = SPACE$(10) + CHR$(0) CALLDLL #NUM, "FN_SetCurVal", tDbl AS STRUCT, ValInStr$ AS STRUCT, NumChrs AS LONG <---- LB crashes here close #NUM
NB The Round function,in the same dll, uses the string representation of a decimal number.
pierre
|
|
|
Post by Walt Decker on Oct 26, 2022 10:42:15 GMT -5
My bad. Should work now. Re-download the zip.
I do not understand.
|
|
|
Post by pierre on Oct 26, 2022 11:29:47 GMT -5
My bad. Should work now. Re-download the zip. I do not understand. Thanks for the dll. Now it works . About the Round function, it was only meant as a comparison. You wrote the following: << There is a round function in NUMBERMANDLL: << "FN_RoundNum", DecNum$ AS STRUCT, NumDec AS LONG, RetVal AS LONG << DecNum$ = string representation of a decimal value; INPUT AND RETURN << NumDec = Number of decimal places to round << On return DecNum$ contains the rounded value So, as I had a problem while entering numeric values, I thought about the Round function that works very well, but with the string representation of a decimal value. That was all. pierre
|
|
|
Post by Walt Decker on Oct 26, 2022 12:21:35 GMT -5
Glad it works for you. I was not casting the dll input properly. I must have been asleep.
The round function does come in handy at times. I am happy it works for you.
If you have need for string values for longs and integers I can easily add those to the function.
|
|
|
Post by pierre on Oct 27, 2022 13:30:55 GMT -5
A brief follow-up on the FN_SetCurVal function:
The first dll call is now working. No more errors. For the input Value = 123456.789 , the 8 byte string obtained is: Év¾Ÿ$þ@ Running the second part (GetCurVal), I don't get the input Value back. It reads: 468322029915016
'-----------------------------------------------------------------------------------
open "NUMBERMANDLL" for dll AS #NUM
STRUCT tDbl,_ Dbl AS DOUBLE
Value = 123456.789 NumChrs = 0
tDbl.Dbl.struct = VAL(USING("######.###", Value)) ValInStr$ = SPACE$(10) + CHR$(0) CALLDLL #NUM, "FN_SetCurVal", tDbl AS STRUCT, ValInStr$ AS STRUCT, NumChrs AS LONG print ValInStr$
'----------------------------------------------------------------------------------- CurValStr$ = ValInStr$ CurInStr$ = SPACE$(10) + CHR$(0) CALLDLL #NUM, "FN_GetCurVal", CurValStr$ AS PTR, CurInStr$ AS STRUCT, NumChrs AS LONG print CurInStr$
close #NUM
'------------------------------------------------------------------------------------
|
|
|
Post by Walt Decker on Oct 28, 2022 12:24:11 GMT -5
I have added a couple of functions to NUMBERMANDLL:
"FN_SetStrCurVal", CurValStr$ AS PTR, CurOutStr$ AS STRUCT, _ RetVal AS LONG
"FN_SetStrCurValEX", CurValStr$ AS PTR, CurOutStr$ AS STRUCT, _ RetVal AS LONG
The numeric currency functions work; however, it might be wise to pares the return string to form a hexidecimal string to ensure that inner null strings are properly addressed.
' STRUCT tDbl, _ Dbl AS DOUBLE
OPEN "NUMBERMANDLL.DLL" FOR DLL AS #NUM tDbl.Dbl.struct = VAL(USING("#############.####", 78431234566.7859)) CurOutStr$ = SPACE$(20) CALLDLL #NUM, "FN_SetCurVal", tDbl AS STRUCT, CurOutStr$ AS STRUCT, _ RetVal AS LONG PRINT USING("############.####", tDbl.Dbl.struct), CurOutStr$, RetVal CurStr$ = LEFT$(CurOutStr$, RetVal) RetStr$ = SPACE$(20) CALLDLL #NUM, "FN_GetCurVal", CurStr$ AS PTR, RetStr$ AS STRUCT, RetVal AS LONG PRINT tDbl.Dbl.struct, RetStr$, RetVal
CurValStr$ = "7.843123456678592E11" CurOutStr$ = SPACE$(20) CALLDLL #NUM, "FN_SetStrCurVal", CurValStr$ AS PTR, CurOutStr$ AS STRUCT, _ RetVal AS LONG CurStr$ = CurOutStr$ RetStr$ = SPACE$(20) CALLDLL #NUM, "FN_GetCurVal", CurStr$ AS PTR, RetStr$ AS STRUCT, RetVal AS LONG PRINT CurValStr$, RetStr$
CurValStr$ = "784312345667.8592" CurOutStr$ = SPACE$(30) CALLDLL #NUM, "FN_SetStrCurValEX", CurValStr$ AS PTR, CurOutStr$ AS STRUCT, _ RetVal AS LONG CurStr$ = CurOutStr$ RetStr$ = SPACE$(20) CALLDLL #NUM, "FN_GetCurValEX", CurStr$ AS PTR, RetStr$ AS STRUCT, RetVal AS LONG PRINT CurValStr$, RetStr$, RetVal CLOSE #NUM
END '
|
|
|
Post by pierre on Oct 28, 2022 13:42:52 GMT -5
OK, thank you Walt
|
|