Announcement

Collapse
No announcement yet.

Strange errors I don't find what I have wrong here

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

  • Strange errors I don't find what I have wrong here

    Dear programmers

    I have written an dll for my thesis but I can't compile it there are compile time errors and I don't find how I can fixed this errors.

    Code:
    #COMPILE DLL
    #DIM ALL
    
    %USEMACROS = 1
    #INCLUDE "WIN32API.INC"
    GLOBAL ghInstance AS DWORD
    
    DECLARE SUB TimeInit()
    DECLARE FUNCTION TimeRead() AS DOUBLE
    DECLARE SUB Delay(BYVAL ms AS DOUBLE)
    DECLARE SUB RealTime()
    DECLARE SUB NormalTime()
    
    'I have need this size of 64 bits integer Int64
    DIM StartTime AS GLOBAL QUAD
    DIM TimeUnit  AS GLOBAL DOUBLE : TimeUnit = 0.000838096515
    
    SUB TimeRead()
        DEF f AS QUAD
        DEF x AS LONG
    
        x = QueryPerformanceFrequency(f)
        TimeUnit = (1000 / f)
        x = QueryPerformanceCounter(StartTime)
    END SUB
    
    SUB TimeInit()
        DEF t AS QUAD
        DEF x AS LONG
    
        x = QueryPerformanceCounter(t)
        FUNCTION = (TimeUnit * (t - StartTime))
    END SUB
    
    SUB Delay(dDelayTime AS DOUBLE)
        DEF TimeStart AS DOUBLE
    
        TimeStart = TimeRead()
        DO WHILE TimeRead < (TimeStart + dDelayTime) : LOOP
    END SUB
    
    SUB RealTime()
        SetPriorityClass (GetCurrentProcess(), %REALTIME_PRIORITY_CLASS)
    END SUB
    
    SUB NormalTime()
        SetPriorityClass (GetCurrentProcess(), %NORMAL_PRIORITY_CLASS)
    END SUB
    
    '-------------------------------------------------------------------------------
    ' Main DLL entry point called by Windows...
    '
    FUNCTION LIBMAIN (BYVAL hInstance   AS LONG, _
                      BYVAL fwdReason   AS LONG, _
                      BYVAL lpvReserved AS LONG) AS LONG
    
        SELECT CASE fwdReason
    
        CASE %DLL_PROCESS_ATTACH
            'Indicates that the DLL is being loaded by another process (a DLL
            'or EXE is loading the DLL).  DLLs can use this opportunity to
            'initialize any instance or global data, such as arrays.
    
            ghInstance = hInstance
    
            FUNCTION = 1   'success!
    
            'FUNCTION = 0   'failure!  This will prevent the EXE from running.
    
        CASE %DLL_PROCESS_DETACH
            'Indicates that the DLL is being unloaded or detached from the
            'calling application.  DLLs can take this opportunity to clean
            'up all resources for all threads attached and known to the DLL.
    
            FUNCTION = 1   'success!
    
            'FUNCTION = 0   'failure!
    
        CASE %DLL_THREAD_ATTACH
            'Indicates that the DLL is being loaded by a new thread in the
            'calling application.  DLLs can use this opportunity to
            'initialize any thread local storage (TLS).
    
            FUNCTION = 1   'success!
    
            'FUNCTION = 0   'failure!
    
        CASE %DLL_THREAD_DETACH
            'Indicates that the thread is exiting cleanly.  If the DLL has
            'allocated any thread local storage, it should be released.
    
            FUNCTION = 1   'success!
    
            'FUNCTION = 0   'failure!
    
        END SELECT
    
    END FUNCTION
    This is the error log report
    ===================

    PowerBASIC for Windows
    PB/Win Version 9.00
    Copyright (c) 1996-2008 PowerBasic Inc.
    Venice, Florida USA
    All Rights Reserved

    Error 484 in E:\PROGRA~1\PBWin90\Samples\Timers32.bas(14:001): Requires Procedure (Function/Method...)
    Line 14: DIM StartTime AS GLOBAL QUAD
    ==============================
    Compile failed at 18:17:32 on 29/10/2008

    Can someone help me?

    Kind regards
    Stephane

  • #2
    Have you tried changing line 14 to:

    GLOBAL StartTime AS QUAD ?
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      > TimeUnit = 0.000838096515

      Executable statements must be located within in a procedure or method.
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        ...And at least one of these should be EXPORTed if you want to ever use this DLL...

        ie...

        Function DoNothing(Byval input as long) Export As Long
        Function = input
        End Function
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment

        Working...
        X