Macro: EXTERNAL$FUNCTION

Module location: FMAC line 13322 (view source)

External$Function Command Flag GET_|MSG_ FunctionName {"FunctionName"} DLLName {Parameters ...} Returns DataType

  #IFTYPE !5 S

    // check that the function name is not one of our reserved internal functions
    #IFSAME !3 GET_
      #IFSAME FN$!4  __F__
        #ERROR DFERR_COMP_ILLEGAL_EXTERNAL_FUNCTION_DEFINTION !4 is an internal function name
      #ENDIF
    #ENDIF

    #IFDEF !3!4 // if defined as object, function, property, external, an error
      // We have an error. This just generates more accurate information
      #IFSAME !3 GET_  // function errors can  be name already used as Object, global function, or reg function
        #IF (GET_!4>$40000000)
          #ERROR DFERR_COMP_ILLEGAL_EXTERNAL_FUNCTION_DEFINTION !4 is already defined as an object
        #ELSE
          #IF (GET_!4<0)
            #ERROR DFERR_COMP_ILLEGAL_EXTERNAL_FUNCTION_DEFINTION !4 is already defined as a global function
          #ELSE
            #ERROR DFERR_COMP_ILLEGAL_METHOD_DEFINTION !4 is already defined as a function or external_function
          #ENDIF
        #ENDIF
      #ELSE  // if procecure it can be global or regular
        #IF (MSG_!4<0)
          #ERROR DFERR_COMP_ILLEGAL_EXTERNAL_FUNCTION_DEFINTION !4 is already defined as a global procedure
        #ELSE
          #ERROR DFERR_COMP_ILLEGAL_EXTERNAL_FUNCTION_DEFINTION !4 is already defined as a procedure or external_procedure
        #ENDIF
      #ENDIF
    #ELSE
      MESSAGE$ADDRESS !3!4 // create any symbol (for global)
      CHECK$METHOD$ARGUMENT$LIST !7 !8 !9
      #DATA
      #FREG !3!4 GLOBAL !7 !8 !9
      #DPUSH !3!4      // Message ID
      #DPUSH !2        // Load Type
      #DPUSH |CS"!6"   // DLL Name
      #DPUSH !5     // Function Name
      GET$RETURN$TYPE !7 !8 !9  // Push Return Type
      !A [] !1 |CI0 |VL
    #ENDIF
  #ELSE
    EXTERNAL$FUNCTION !1 !2 !3 !4 |CS"!4" !5 !6 !7 !8 !9
  #ENDIF