Jump to content

Dll LIKE functionally using a3x


KXM
 Share

Recommended Posts

I wanted to see if I could get it to work, and to some extent did. It's really just a lot of strinstr stuff. Not really suitable for production use. The more I play with it, the more I realize it would really need to built into the AutoIt core.

I haven't figured out a good way to pass back info. But thinking about stdin/out.

#include-once
#include <array.au3>
#include <Constants.au3>


Global $aParams_A3XGlobal[1], $iError_A3XGlobal = 0, $hPID_A3XGlobal = 0

Func _a3xCall($sPath, $sFunc, ByRef $aParamas, $bRunWait = False)
    Local $sParamas = ''
    
    For $v in $aParamas
        If IsArray($v) Then
            $sParamas &= __ParseArray($v) & ','
            ContinueLoop
        EndIf
        
        $sParamas &= $v & ','
    Next
    
    $sParamas = StringTrimRight($sParamas, 1)
    
    If $bRunWait Then
        $hPID_A3XGlobal = RunWait(@ScriptFullPath & ' /AutoIt3ExecuteScript "' & $sPath & '" Call::' & $sFunc & ' Paramas::' & $sParamas)
    Else
        $hPID_A3XGlobal = Run(@ScriptFullPath & ' /AutoIt3ExecuteScript "' & $sPath & '" Call::' & $sFunc & ' Paramas::' & $sParamas, '', '', $STDERR_CHILD + $STDOUT_CHILD + $STDIN_CHILD)
    EndIf
EndFunc  ;==>_a3xCall

Func _A3XClose()
    ProcessClose($hPID_A3XGlobal)
    $aParams_A3XGlobal = ''
    $iError_A3XGlobal = 0
    $hPID_A3XGlobal = 0
EndFunc  ;==>_A3XClose

Func _ParseA3XCall($sParamas)
    Local $aSplit, $sFunc, $aFuncParams
    
    $aSplit = StringSplit( StringTrimLeft($sParamas, (StringInStr($sParamas, 'Call::') + 5)), 'Paramas::', 1)
    $sFunc = $aSplit[1]
    
    $aFuncParams = StringSplit($aSplit[2], ',')
    _ArrayDelete($aFuncParams, 0)
    
    For $s in $aFuncParams
        _ArrayAdd($aParams_A3XGlobal, __VarentToType($s))
    Next
    
    $aParams_A3XGlobal[0] = UBound($aParams_A3XGlobal) - 1
    
    Call(StringStripWS($sFunc, 8))
    If @error Then
        MsgBox(0, '', 'Called Function non-exantiant: ' & $sFunc)
    EndIf
    
    ConsoleWrite('Exit Code: ' & $iError_A3XGlobal)
EndFunc  ;==>_ParseA3XCall

Func _Return($v)
    ConsoleWrite($v)
EndFunc  ;==>_Return

;helpers
Func __VarentToType($v)
    Local $sCheck, $n = Number($v)
    
    $sCheck = StringLeft($v, 1)
    If $sCheck == '"' Or $sCheck == "'" Then
        $v = StringTrimLeft($v, 1)
    EndIf
    
    $sCheck = StringRight($v, 1)
    If $sCheck == '"' Or $sCheck == "'" Then
        $v = StringTrimRight($v, 1)
    EndIf
    
    Select
        Case StringInStr($v, 'Array::', 1)
            Return  StringSplit (StringReplace($v, 'Array::', ''), '|', 1)
            
        Case $v = 'true'
            Return True
            
        Case $v = 'false'
            Return False
            
        Case $n <> 0
            Return $n
            
        Case Else
            If $v == 0 And $n == 0 Then Return 0
            
            Return String($v)
            
    EndSelect
EndFunc  ;==>__VarentToType

Func __ParseArray(ByRef $aArray)
    If Not IsArray($aArray) Then
        SetError(1)
        Return False
    EndIf
    
    $sSendString = _ArrayToString($aArray, '|')
    Return 'Array::' & $sSendString
EndFunc  ;==>__ParseArray

a3xConcepts.zip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...