Announcement

Collapse
No announcement yet.

This code crashes when called a few times in a row...

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

  • This code crashes when called a few times in a row...

    Hi
    This code works fine if called from the main form button press once. You can press the button 4 or 5 times in a row fast and it still works.
    HOWEVER, if you press the button very fast a bunch of times in row this will crash the program.
    I cant figure out why i can't trap the error?

    Code:
    '------------------------------------------------------------------------------
     FUNCTION POKE_4050() AS LONG
    
       LOCAL THREAD_HANDLE         AS LONG
       LOCAL THREAD_RESULT         AS LONG
    
    
        THREAD CREATE THREADED_POKE_4050(0) TO THREAD_HANDLE
    
        TEXT_TO_SCREEN_ONE "THREAD CREATED - " + STR$(THREAD_HANDLE)  '<-- for debug
        THREAD CLOSE  THREAD_HANDLE TO THREAD_RESULT
        TEXT_TO_SCREEN_ONE "THREAD CLOSED - " + STR$(THREAD_RESULT)    '<-- for debug
    
     END FUNCTION
    '------------------------------------------------------------------------------
     THREAD FUNCTION THREADED_POKE_4050(BYVAL NO_VALUE AS LONG ) AS LONG
    
      ON ERROR GOTO ERROR_CONTROL
    
      LOCAL CONTROLLER_UNIQUE_ID  AS LONG
      LOCAL FILE_NUMBER AS LONG
    
      FOR CONTROLLER_UNIQUE_ID = 1 TO 96
        IF GL_CONTROLLER_IP_ADDRESS(CONTROLLER_UNIQUE_ID) <> "" AND GL_CONTROLLER_NAME(CONTROLLER_UNIQUE_ID) <> "" THEN
    
        FILE_NUMBER = FREEFILE
        TEXT_TO_SCREEN_ONE "FILE NUMBER = " + STR$(FILE_NUMBER)   '<-- for debug
    
        TRY
         TCP OPEN PORT 4050 AT GL_CONTROLLER_IP_ADDRESS(CONTROLLER_UNIQUE_ID) AS FILE_NUMBER
         TEXT_TO_SCREEN_ONE "[S] VERTX_CONTACT_CONTROLLER " + GL_CONTROLLER_IP_ADDRESS(CONTROLLER_UNIQUE_ID)
        CATCH
         TEXT_TO_SCREEN_ONE "TCP OPEN ERROR " + GL_CONTROLLER_IP_ADDRESS(CONTROLLER_UNIQUE_ID)
        END TRY
    
        TRY
         TCP NOTIFY FILE_NUMBER, RECV CLOSE TO GL_hDlg AS %POKE_TCP_MASTER_EVENT
         TEXT_TO_SCREEN_ONE "P2"
        CATCH
         TEXT_TO_SCREEN_ONE "TCP NOTIFY ERROR " + GL_CONTROLLER_IP_ADDRESS(CONTROLLER_UNIQUE_ID)
        END TRY
    
        SLEEP 100
    
        TRY
         TCP SEND FILE_NUMBER, "0045;0010; " + GL_CONTROLLER_IP_ADDRESS(CONTROLLER_UNIQUE_ID)
         TEXT_TO_SCREEN_ONE "P3"
         CATCH
        TEXT_TO_SCREEN_ONE "TCP SEND ERROR"
        END TRY
    
       END IF
      NEXT
    
      EXIT FUNCTION
    
      ERROR_CONTROL:
      MSGBOX ERROR$
    
     END FUNCTION
    '------------------------------------------------------------------------------

  • #2
    Actually I can get the debugger to break on error and it is saying Subscript/Pointer out of range in the main form callback...
    So it looks like the problem is not in this function...

    Comment


    • #3
      I am going to move this to a new thread as the problem has nothing to do with the above listed code.

      Comment

      Working...
      X