Announcement

Collapse
No announcement yet.

Last pointer type and/or var type bug

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mike Trader
    replied
    Tom,
    Thats it! - Damn you guys are good!

    The result turned out to be 7 digits
    Thx so much

    ------------------
    Kind Regards
    Mike

    Leave a comment:


  • Tom Hanlin
    replied
    Make sure that the returned value is no more than six digits, then, or split it into
    WORDs and return as two SINGLEs. Otherwise, your data is likely to wind up corrupted
    by the limited precision of a SINGLE.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Mike Trader
    replied
    Tom,

    yes I know its stupid, but EL only allows floats (SINGLEs) so thats what i have to return in order to be able to use it in EL. I guess they made that restriction so that novices would not have to deal wioth variable type declarations

    ------------------
    Kind Regards
    Mike

    Leave a comment:


  • Tom Hanlin
    replied
    Why is FindELDate converting to a SINGLE instead of returning the DWORD?
    This is inefficient and may cause loss of accuracy. If you've got to use
    floating point here for some reason, think DOUBLE.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Mike Trader
    started a topic Last pointer type and/or var type bug

    Last pointer type and/or var type bug

    I have sucesfully (thanks to your help) retrieved variable values from memory for all the functions in "elkit32.dll" except one - FindAddress_Date

    Here is how Omega describe it:

    Parameters:
    lpDate - A pointer to a Date array element in EasyLanguage.

    nOfs - Specifies the bar offset. The offset is backwards if Ofs is positive or forward if Ofs is negative.

    Returns:
    A pointer to the value of a Date array element offset by nOfs.

    Remarks:
    All Date values are in Julian date format. If a 'YYMMDD' format is desired, you must call the tool kit function JulianToDate.

    where ...

    DWORD JulianToDate(WORD wJulianDay);

    Parameters:
    wJulianDay - Julian day.

    Returns:
    The date converted to 'YYMMDD' format from a Julian date.

    Remarks:
    This function converts a date value from the Julian format to the 'YYMMDD' format.

    So here is my dll ....

    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #COMPILE DLL "Test.dll" ' A Dll to call ALL Functions from elkit32.dll
    #INCLUDE "WIN32API.INC"

    DECLARE FUNCTION FindAddress_Date LIB "elkit32.dll" ALIAS "FindAddress_Date" _
    (BYVAL DatePtr AS DWORD, BYVAL BarOffset AS LONG) AS DWORD

    DECLARE FUNCTION FindAddress_Time LIB "elkit32.dll" ALIAS "FindAddress_Time" _ ' works fine
    (BYVAL TimePtr AS DWORD, BYVAL BarOffset AS LONG) AS DWORD

    DECLARE FUNCTION FindAddress_Open LIB "elkit32.dll" ALIAS "FindAddress_Open" _ ' works fine
    (BYVAL OpenPtr AS DWORD, BYVAL BarOffset AS LONG) AS DWORD

    DECLARE FUNCTION FindAddress_High LIB "elkit32.dll" ALIAS "FindAddress_High" _ ' works fine
    (BYVAL HighPtr AS DWORD, BYVAL BarOffset AS LONG) AS DWORD

    DECLARE FUNCTION FindAddress_Low LIB "elkit32.dll" ALIAS "FindAddress_Low" _ ' works fine
    (BYVAL LowPtr AS DWORD, BYVAL BarOffset AS LONG) AS DWORD

    DECLARE FUNCTION FindAddress_Close LIB "elkit32.dll" ALIAS "FindAddress_Close" _ ' works fine
    (BYVAL ClosePtr AS DWORD, BYVAL BarOffset AS LONG) AS DWORD

    DECLARE FUNCTION JulianToDate LIB "elkit32.dll" ALIAS "JulianToDate" _ ' works fine
    (BYVAL JulDay AS WORD) AS DWORD

    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION FindELDate ALIAS "FindELDate" ( BYVAL ELDatePtr AS DWORD ,_ ' Dword that contains a Long Pointer
    BYVAL ELBarOffset AS LONG )EXPORT AS SINGLE

    LOCAL JulDate AS WORD, dwDate AS DWORD, LongPtr AS LONG PTR

    LongPtr = FindAddress_Date ( ELDatePtr, ELBarOffset )
    JulDate = CWRD(@LongPtr)
    dwDate = JulianToDate(JulDate)

    'FUNCTION = CSNG( @LongPtr ) ' Return Julian
    FUNCTION = CSNG( dwDate ) ' Return a YYMMDD
    END FUNCTION

    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    EL Code:
    DefineDLLFunc: "Test.dll", Float, "FindELDate", lpDword, Long;
    FoundDate = FindELDate ( &Date, 0 );

    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Results1: (Time is allways 15:15 on Daily Bars - only weekdays are trading days)

    Actual Bar 00011 ( 12/10/99 15:15 ) Actual Date = 991210 Returned Date = 19991210
    Actual Bar 00012 ( 12/13/99 15:15 ) Actual Date = 991213 Returned Date = 19991212
    Actual Bar 00013 ( 12/14/99 15:15 ) Actual Date = 991214 Returned Date = 19991214
    Actual Bar 00014 ( 12/15/99 15:15 ) Actual Date = 991215 Returned Date = 19991216
    Actual Bar 00015 ( 12/16/99 15:15 ) Actual Date = 991216 Returned Date = 19991216
    Actual Bar 00016 ( 12/17/99 15:15 ) Actual Date = 991217 Returned Date = 19991216
    Actual Bar 00017 ( 12/20/99 15:15 ) Actual Date = 991220 Returned Date = 19991220
    Actual Bar 00018 ( 12/21/99 15:15 ) Actual Date = 991221 Returned Date = 19991220
    Actual Bar 00019 ( 12/22/99 15:15 ) Actual Date = 991222 Returned Date = 19991222
    Actual Bar 00020 ( 12/23/99 15:15 ) Actual Date = 991223 Returned Date = 19991224
    Actual Bar 00021 ( 12/27/99 15:15 ) Actual Date = 991227 Returned Date = 19991228
    Actual Bar 00022 ( 12/28/99 15:15 ) Actual Date = 991228 Returned Date = 19991228
    Actual Bar 00023 ( 12/29/99 15:15 ) Actual Date = 991229 Returned Date = 19991228
    Actual Bar 00024 ( 12/30/99 15:15 ) Actual Date = 991230 Returned Date = 19991230
    Actual Bar 00025 ( 12/31/99 15:15 ) Actual Date = 991231 Returned Date = 19991232
    Actual Bar 00026 ( 01/03/00 15:15 ) Actual Date = 1000103 Returned Date = 20000104
    Actual Bar 00027 ( 01/04/00 15:15 ) Actual Date = 1000104 Returned Date = 20000104
    Actual Bar 00028 ( 01/05/00 15:15 ) Actual Date = 1000105 Returned Date = 20000104
    Actual Bar 00029 ( 01/06/00 15:15 ) Actual Date = 1000106 Returned Date = 20000106
    Actual Bar 00030 ( 01/07/00 15:15 ) Actual Date = 1000107 Returned Date = 20000108
    Actual Bar 00031 ( 01/10/00 15:15 ) Actual Date = 1000110 Returned Date = 20000110
    Actual Bar 00032 ( 01/11/00 15:15 ) Actual Date = 1000111 Returned Date = 20000112
    Actual Bar 00033 ( 01/12/00 15:15 ) Actual Date = 1000112 Returned Date = 20000112
    Actual Bar 00034 ( 01/13/00 15:15 ) Actual Date = 1000113 Returned Date = 20000112
    Actual Bar 00035 ( 01/14/00 15:15 ) Actual Date = 1000114 Returned Date = 20000114
    Actual Bar 00036 ( 01/18/00 15:15 ) Actual Date = 1000118 Returned Date = 20000118
    Actual Bar 00037 ( 01/19/00 15:15 ) Actual Date = 1000119 Returned Date = 20000120
    Actual Bar 00038 ( 01/20/00 15:15 ) Actual Date = 1000120 Returned Date = 20000120
    Actual Bar 00039 ( 01/21/00 15:15 ) Actual Date = 1000121 Returned Date = 20000120


    Results2: (Match Results1)

    Actual Bar 00011 ( 12/10/99 15:15 ) Actual Jul = 36504 Returned Jul = 60001944
    Actual Bar 00012 ( 12/13/99 15:15 ) Actual Jul = 36507 Returned Jul = 60001948
    Actual Bar 00013 ( 12/14/99 15:15 ) Actual Jul = 36508 Returned Jul = 60001948
    Actual Bar 00014 ( 12/15/99 15:15 ) Actual Jul = 36509 Returned Jul = 60001948
    Actual Bar 00015 ( 12/16/99 15:15 ) Actual Jul = 36510 Returned Jul = 60001952
    Actual Bar 00016 ( 12/17/99 15:15 ) Actual Jul = 36511 Returned Jul = 60001952
    Actual Bar 00017 ( 12/20/99 15:15 ) Actual Jul = 36514 Returned Jul = 60001952
    Actual Bar 00018 ( 12/21/99 15:15 ) Actual Jul = 36515 Returned Jul = 60001956
    Actual Bar 00019 ( 12/22/99 15:15 ) Actual Jul = 36516 Returned Jul = 60001956
    Actual Bar 00020 ( 12/23/99 15:15 ) Actual Jul = 36517 Returned Jul = 60001956
    Actual Bar 00021 ( 12/27/99 15:15 ) Actual Jul = 36521 Returned Jul = 60001960
    Actual Bar 00022 ( 12/28/99 15:15 ) Actual Jul = 36522 Returned Jul = 60001960
    Actual Bar 00023 ( 12/29/99 15:15 ) Actual Jul = 36523 Returned Jul = 60001964
    Actual Bar 00024 ( 12/30/99 15:15 ) Actual Jul = 36524 Returned Jul = 60001964
    Actual Bar 00025 ( 12/31/99 15:15 ) Actual Jul = 36525 Returned Jul = 60001964
    Actual Bar 00026 ( 01/03/00 15:15 ) Actual Jul = 36528 Returned Jul = 60001968
    Actual Bar 00027 ( 01/04/00 15:15 ) Actual Jul = 36529 Returned Jul = 60001968
    Actual Bar 00028 ( 01/05/00 15:15 ) Actual Jul = 36530 Returned Jul = 60001968
    Actual Bar 00029 ( 01/06/00 15:15 ) Actual Jul = 36531 Returned Jul = 60001972
    Actual Bar 00030 ( 01/07/00 15:15 ) Actual Jul = 36532 Returned Jul = 60001972
    Actual Bar 00031 ( 01/10/00 15:15 ) Actual Jul = 36535 Returned Jul = 60001976
    Actual Bar 00032 ( 01/11/00 15:15 ) Actual Jul = 36536 Returned Jul = 60001976
    Actual Bar 00033 ( 01/12/00 15:15 ) Actual Jul = 36537 Returned Jul = 60001976
    Actual Bar 00034 ( 01/13/00 15:15 ) Actual Jul = 36538 Returned Jul = 60001976
    Actual Bar 00035 ( 01/14/00 15:15 ) Actual Jul = 36539 Returned Jul = 60001980
    Actual Bar 00036 ( 01/18/00 15:15 ) Actual Jul = 36543 Returned Jul = 60001984
    Actual Bar 00037 ( 01/19/00 15:15 ) Actual Jul = 36544 Returned Jul = 60001984
    Actual Bar 00038 ( 01/20/00 15:15 ) Actual Jul = 36545 Returned Jul = 60001984
    Actual Bar 00039 ( 01/21/00 15:15 ) Actual Jul = 36546 Returned Jul = 60001984

    As you can see in Results1 I am allmost there. It looks like some sort of rounding error is occuring somewhere. The JulianToDate function is working as expected but the function FindAddress_Date is not. There are no Odd dates!?

    Also the Julian date returned by the function is considerably larger than the julian dat returned by an EL function yet when it goes through DateToJulian in "elkit32.dll" it comes out at allmost the right date.

    I am so close. Could one of you wizards scan my code and see if there is anything I might have missed. I have tried everything I can think of.

    I also dont understand why the argument to JulianToDate is a WORD when clearly the return from FindAddress_Date is a LONG PTR (a LONG in effect). why would a developer do that?


    ------------------
    Kind Regards
    Mike
Working...
X