Jump to content
Sign in to follow this  
EdDyreen

HowTo Advanced Debug

Recommended Posts

EdDyreen

Want to do something like:

$Parameters = 'Something, Else, Here'

ThisSub ( Eval ( 'Parameters' ) )

Func ThisSub ( $Something, $Else, $Here )
    ...
    ThisSub2 ( 'bla, bla, bla' )
    ...
EndFunc

it isn't working !

the reason i want to do this is because i want this functionality in AU3 which I exploited heavily in COMMAND.COM, CMD:

Set "Debug.Sub=:ThisSub2"

%CallMySub% ThisSub /Something /Else /Here

Echo.endoftest
pause
exit

::Call ( :Suboutine star )
::
:: SJAB v137 beta
::
:: if /i ["@Suboutine"] neq [":CallMySub"] call @Suboutine @star
::
::INPUT:
:: @SubRoutine  STRING  Required;   SubRoutine that will be called
:: @star    STRING  Optional;   Parameters that will be passed to @SubRoutine
::
:: WARNING (
::
::  -Needs to stay on top of :CallMySub () since;
::  ;. This in no SubRoutine !
::
::  -Disables error handling for @SubRoutine since;
::  ;. Speed is important here !
::
::  -Cannot use :Debug since;
::  ;. This in not a SubRoutine !
::
::  -if %* contains "(" or ")" a normal if /i [""] == [""] () construction fails !
::  ;) This is solved by using if /i [""] == [""]
:: )
::
::(
    ::set "Debug.Sub=:Call"
    ::(
        ::%Debug.Define% echo. &echo.inside ::Call star: &echo.%*
    ::)

    ::%Debug.Define% echo.PROC PAR
    ::(
        @set "FirstPARAM=%1"

        ::%Debug.Define% echo. FirstPARAM=!FirstPARAM!_
    ::)

    ::%Debug.Define% echo.VALID
    ::(
        @if not defined FirstPARAM echo. :( not defined %%1 [ERROR] &pause &exit 1

        ::%Debug.Define% echo. FirstPARAM=!FirstPARAM!_
    ::)

    ::%Debug.Define% echo.Perform
    ::(
        shift &if /i ["!FirstPARAM!"] neq ["CallMySub"] (
            ::
            echo.>nul

            set /a Sub.Depth += 1
            call set Sub.!Sub.Depth!.Name=:%%0

            ::%Debug.Define% echo. call :%* &%Debug.Pause%
            echo.>nul
        )
        if /i ["!FirstPARAM!"] neq ["CallMySub"] call :%* &set /a Sub.Depth -= 1 &goto :eof
    ::)
::)

:CallMySub ( :Suboutine star )
::
:: SJAB v1.35 beta
::
:: call @Suboutine @star with error handling
::
::INPUT:
:: @SubRoutine  STRING  Required;   SubRoutine that will be called
:: @Parameters  STRING  Optional;   Parameters that will be passed to @SubRoutine
::
:: WARNING (
::
::  -Cannot use :Debug since;
::  ;( :CallMySub is a dependency of :Debug !
::
::  -Cannot use %Debug.Equals% since;
::  ;( :CallMySub is a dependency of %Debug.Equals% !
::
:: )
::
::(
    ::set "Debug.Sub=:CallMySub"
    ::(
        ::if /i ["!Debug.Sub!"] == [":CallMySub"] echo. &echo.inside :CallMySub star: &echo.%*
    ::)

    set /a Sub.Depth += 1

    set "Par.AsIS=" &( for /l %%! in ( 0, 1, !Par.C! ) do set "Par.%%!=" ) &set /a Par.C = -1

    :CallMySub.LOOP_0 ()
    ::(
        call set CallMySub.b=%%1
        shift

        ::%Debug.Define% echo. CallMySub.b=!CallMySub.b!_
        if defined CallMySub.b (
            ::
            set /a Par.C += 1

            if !Par.C! gtr 0 if defined Par.AsIS (
                ::
                set "Par.AsIS=!Par.AsIS! !CallMySub.b!"

            ) else  set "Par.AsIS=!CallMySub.b!"

            set Par.!Par.C!=!CallMySub.b!

            ::%Debug.Define% echo. Par.!Par.C!=!CallMySub.b!_
            echo.>nul

            goto :CallMySub.LOOP_0
        )
    ::)

    set "Sub.!Sub.Depth!.Name=:!Par.0!"
    set "Sub.!Sub.Depth!.Par.C=!Par.C!"

    for /l %%! in ( 1, 1, !Par.C!
    ) do (
        set "Sub.!Sub.Depth!.Par.%%!=!Par.%%!!"
        ::
        if defined Sub.!Sub.Depth!.Par.AsIS (
            ::
            set "Sub.!Sub.Depth!.Par.AsIS=!Sub.%Sub.Depth%.Par.AsIS! !Par.%%!!"

        ) else  set "Sub.!Sub.Depth!.Par.AsIS=!Par.%%!!"
    )
    ::if /i ["!Debug.Sub!"] == [":CallMySub"] for /l %%! in ( 1, 1, !Par.C! ) do echo. Sub.!Sub.Depth!.Par.%%!=!Sub.%Sub.Depth%.Par.%%!!_

    ::if /i ["!Debug.Sub!"] == [":CallMySub"] echo. call !Sub.%Sub.Depth%.Name! !Sub.%Sub.Depth%.Par.AsIS! &%Debug.Pause%
    call !Sub.%Sub.Depth%.Name! !Sub.%Sub.Depth%.Par.AsIS!

    ( for %%! in ( Par.AsIS Use ) do set "Sub.!Sub.Depth!.%%!=" ) &for /l %%! in ( 1, 1, !Sub.%Sub.Depth%.Par.C! ) do set "Sub.!Sub.Depth!.Par.%%!="

    set /a Sub.Depth -= 1
::
::if /i ["!Debug.Sub!"] == [":CallMySub"] %Debug% "outside :CallMySub" &%Debug.Pause%
goto :eof
::)

:Debug ( /Debug.Pause "MSG:STRING" "etc.." )
::
:: SJAB v137 beta
::
:: Show MSG &pause if necessary
::
::INPUT:
:: @Debug.Pause STRING  Optional;   if '@Degug.Sub' equ '@Sub.(@Sub.Depth).Name' pause
:: @Message     STRING  Optional;   MSG >> : ToConsole ()
::
:: WARNING (
::
::  -Uses call since;
::  ;. Must have no dependencies !
::
:: )
::
SetLocal
::(
    ::set "Debug.Sub=!Sub.%Sub.Depth%.Name!"
    ::(
        ::%Debug.Equals% echo. &echo.inside !Sub.%Sub.Depth%.Name! () star: &echo.%*_ &%Debug.Pause%
    ::)

    ::%Debug.Equals% echo.PROC PAR
    ::(
        ::%Debug.Equals% for %%! in ( Sub.!Sub.Depth!.Name Debug.Sub ) do echo. %%!=!%%!!_
    ::)

    ::%Debug.Equals% echo.VALID
    ::(
        ::%Debug.Equals% for %%! in ( Sub.!Sub.Depth!.Name Debug.Sub ) do echo. %%!=!%%!!_
    ::)

    ::%Debug.Equals% echo.Perform &%Debug.Pause%
    ::(
        set /a Debug.Par.C = 0
        ::
        :Debug.Loop_0 ()
        ::(
            call set Debug.b=%%1
            shift

            if defined Debug.b (
                ::
                set /a Debug.Par.C += 1

                if [!Debug.b:~0^,1!] == [^"] if [!Debug.b:~-1!] == [^"] set "Debug.b=!Debug.b:~1,-1!"
                ::
                if defined Debug.b                  set "Debug.b=!Debug.b:""="!^"

                set "Debug.Par.!Debug.Par.C!=!Debug.b!"

                ::%Debug.Equals% echo. Debug.Par.!Debug.Par.C!=!Debug.b!_
                goto :Debug.Loop_0 %()%
            )
        ::)

        ::%Debug.Equals% echo. if /i ['Debug.Par.1=!Debug.Par.1!_'] == ['/Debug.Pause'] ( &%Debug.Pause%
        set /a Debug.Pause.IsValid = 0
        ::
        if /i ["!Debug.Par.1!"] == ["/Debug.Pause"] (
            ::
            set /a Debug.Pause.IsValid = 1

            for /l %%! in ( 1, 1, !Debug.Par.C!
            ) do (
                set /a $ = %%! + 1
                ::
                call set "Debug.Par.%%!=%%Debug.Par.!$!%%"
            )
            ::
            set /a Debug.Par.C -= 1
        )

        ::%Debug.Equals% for %%! in ( Debug.Par.C ) do echo. %%!=!%%!!_
        ::%Debug.Equals% for /l %%! in ( 1, 1, !Debug.Par.C! ) do echo. Debug.Par.%%!=!Debug.Par.%%!!_

        ::%Debug.Equals% echo. Show MSG &%Debug.Pause%
        for /l %%! in ( 1, 1, !Debug.Par.C!
        ) do (
            echo.!Debug.Par.%%!!
        )

        ::%Debug.Equals% echo. if Debug.Pause.IsValid=!Debug.Pause.IsValid!_ neq 0 %Debug.Pause%
        if !Debug.Pause.IsValid! neq 0 %Debug.Pause%
    ::)
::
::%Debug.Equals% echo.outside !Sub.%Sub.Depth%.Name! () &%Debug.Pause%
EndLocal &goto :eof ()
::)

:ERR.Set.THIS ( "STRING" )
::
:: SJAB v1.35 beta
::
:: Displays Error Message about "STRING"
::
::INPUT:
:: @STRING  STRING  Optional;   STRING to display
::
::(
    ::set "Debug.Sub=:ERR.Set.THIS"
    ::(
        ::%Debug% "" "inside !Sub.%Sub.Depth%.Name! Sub.!Sub.Depth!.Par.AsIS:" &echo.!Sub.%Sub.Depth%.Par.AsIS!_
        set "Sub.!Sub.Depth!.Use=:ERR.Set.THIS ( "STRING" )"
    ::)

    ::%Debug% "PROC PAR"
    ::(
    ::)

    ::%Debug% "VALID"
    ::(
    ::)

    ::%Debug% "Perform"
    ::(
        if !ERR! equ 0 set /a ERR = -1

        set /a EXIT.CODE = !ERR!

        set /a ERR.MSG.C = 0

        %AddErrMsg% "Operations ABORTED ^!, Interception by :ERR.Set.THIS"
        %AddErrMsg% ""

        set /a Sub.Depth -= 1

        if defined Sub.Name.Array (
            ::
            set "Sub.Name.Array=!Sub.Name.Array! !Sub.%Sub.Depth%.Name!"

        ) else (

            for /l %%! in ( 1, 1, !Sub.Depth! ) do if defined Sub.Name.Array (
                ::
                set "Sub.Name.Array=!Sub.Name.Array! !Sub.%%!.Name!"

            ) else  set "Sub.Name.Array=!Sub.%%!.Name!"
        )

        set "Sub.Name=!Sub.%Sub.Depth%.Name!"
        set "Sub.Use=!Sub.%Sub.Depth%.Use!"
        set "Sub.Par.AsIS=!Sub.%Sub.Depth%.Par.AsIS!"

        for %%! in ( Sub.Use Sub.Par.AsIS ) do if defined %%! set %%!=!%%!:^"=""!

        set /a Sub.Depth += 1

        %AddErrMsg% " Sub.Name.Array : !Sub.Name.Array!"
        %AddErrMsg% " Sub.Name       : !Sub.Name!"
        %AddErrMsg% " Sub.Use        :"
        %AddErrMsg% " !Sub.Use!"
        %AddErrMsg% ""
        %AddErrMsg% " Sub.Par.AsIS   :"
        %AddErrMsg% " !Sub.Par.AsIS!_"
        %AddErrMsg% ""

        %AddErrMsg% " Sub.forward    : [ERROR:!ERR!]"

        if !Sub.%Sub.Depth%.Par.C! equ 0 (
            ::
            %AddErrMsg% " Unhandled exception ^!"

        ) else (

            for /l %%! in ( 1, 1, !Sub.%Sub.Depth%.Par.C!
            ) do (
                set "VAR=!Sub.%Sub.Depth%.Par.%%!!"

                %Dequote.IfEven% VAR

                %AddErrMsg% " !VAR!"
            )
        )

        %AddErrMsg% ""
        %AddErrMsg% " Please mail ED@ED.ED for technical support"
        if exist "!FullPathFile.LOGFile!" (
            ::
            %AddErrMsg% " &don't forget to include the Logfile ^!"
            %AddErrMsg% " '!FullPathFile.LOGFile!' "
        )
        %AddErrMsg% ""
        %AddErrMsg% " :/ Press any key to exit to DOS..."

        for %%! in ( "!FullPathFile.CMDOW!" ) do if exist %%! %%! @ /ena

        Color 0C

        set "?=" &cls &for /l %%! in ( 0, 1, !ERR.MSG.C! ) do ( ( if defined ? (echo.) else set "?=defined" ) &set /p "?= !ERR.MSG.%%!!" <nul )

        >nul pause
    ::)
::
::%Debug% /Debug.Pause "outside !Sub.%Sub.Depth%.Name!"
%EXIT% &goto :eof
::)

What will happen is that :CallMySub () will call :ThisSub () passing it the parameters ( /Something /Else /Here )

Inside :ThisSub () there are :Debug () statements which WON'T be executed since:

Debug.Sub=:ThisSub2

Sub.%Sub.Depth%.Name=:ThisSub

doesn't match !

yet from the moment :ThisSub () executes the command %CallMySub% :ThisSub2 ( 'bla, bla, bla' )

:CallMySub () will set Sub.%Sub.Depth%.Name=:ThisSub2 &then it will call :ThisSub2 ( 'bla, bla, bla' )

since there now is a match every :Debug statements will be executed !

these debug statement do things like echoing information about which Sub is in debug mode, what parameters it requires, has received, any errors, pause for input etc...

The

set /a Sub.Depth += 1 that :CallMySub () performs before calling the actiual sub i'm asking for &

set /a Sub.Depth -= 1 that :CallMySub () performs after calling the actiual sub

are especially important, hence they allow the debug intercepter :ERR.Set.THIS () to display detailed information like:

There was a fatal error in :ThisSub2 () at 3 levels deep

nesting: Your APP, ThisSub, ThisSub2

ThisSub2 needs this parameters: ........

And was called with these parameters: .........

The error returned from ThisSub2 is: ........

The errorlevel returned from ThisSub2 is: ......

This error is FATAL the APP will exit

bla bla bla ......

This will make it easier for me to debug complex CMD programs which are otherwise very difficult to debug

So actiually what I want to do in AU3 is:

$Debug=ThisSub2

CallMySub ( ThisSub, 'Something, Else, Here' )

exit

Func CallMySub ( SubRoutine, Parameters )
    ...
    $Sub_Depth += 1
    ThisSub ( eval ( Parameters ) )
    $Sub_Depth -= 1
    ...
EndFunc

Func ThisSub ( $Something, $Else, $Here )
    ...
    ThisSub2 ( 'bla, bla, bla' )
    ...
EndFunc

Func ThisSub2 ( $Something, $Else, $Here )
    ...
EndFunc

instead of

$Debug=ThisSub2

ThisSub ( $Something, $Else, $Here )

exit

Func ThisSub ( $Something, $Else, $Here )
    ...
    $Sub_Depth += 1
    ThisSub2 ( 'bla, bla, bla' )
    $Sub_Depth -= 1
    ...
EndFunc

Func ThisSub2 ( $Something, $Else, $Here )
    $Sub_Depth += 1
    ...
    $Sub_Depth -= 1
EndFunc

You see ?, why would every function have to increase &decrease $Sub_Depth while this can simply be done by a CallMySub

The big problem is that CallMySub can impossibly now which parameters the sub to be called requires &on top of that every function must be called with exactly the amount of parameters 'certainly not more !' it requires.

so far this what i have in AU3:

Func CallMySub ( $SubRoutine, $Par_AsIS = '' )
;
; SJAB v1.65 beta
;
; Call a SubRoutine with error handling
;
;INPUT:
; $SubRoutine   STRING/BYVAL    Required;       SubRoutine that will be called
; $Par_AsIS     STRING/BYVAL    Optional;       Parameters that will be passed to @SubRoutine eg: '/Par_FIX: "STRING", /PAR_OPT'
;
;OUTPUT:
; $Sub_Array    ARRAY           Return GLOBAL;  where $Sub_Array[$Sub_Depth][0] = $SubRoutine
;                                               where $Sub_Array[$Sub_Depth][ 1-$PAR_COUNT ] = valid parameters
;(
    ;set "Debug_Sub=CallMySub"
    ;(
        ;if $Debug_Sub = 'CallMySub' Then DEBUG ( 'inside CallMySub star: ' &@CRLF &$Parameters &'_' )
    ;)

    $Sub_Depth += 1

    $Array_Pars = _StringExplode ( $Par_AsIS, "/", 0 )

    $PAR_COUNT = UBound ( $Array_Pars )
    ;
    ReDim $Sub_Array[$Sub_Depth][ $PAR_COUNT ]
    ;
    $PAR_COUNT -= 1

    $Sub_Array[ $Sub_Depth - 1 ][0] = $SubRoutine

    For $Element_0 = 1 To $PAR_COUNT Step 1

        $Array_Par      = _StringExplode ( $Array_Pars[$Element_0], ':', 0 )
        ;
        $Par_COUNT_1    = UBound ( $Array_Par ) - 1

        For $Element_1 = 0 To $Par_COUNT_1 Step 1
            ;
            $PAR = $Array_Par[$Element_1]
            ;
            If $Element_1 = 0 Then
                ;
                $PAR_0 = $PAR
                $PAR_0 = StringReplace ( $PAR_0, ' ', '', 0, 2 )
                $PAR_0 = StringReplace ( $PAR_0, ',', '', 0, 2 )
                ;
                $Sub_Array[ $Sub_Depth - 1 ][$Element_0] = $PAR_0
                ;
            Else
                ;
                $PAR_1 = $PAR
                $PAR_1 = StringTrimLeft ( $PAR_1, StringInStr ( $PAR_1, '"', 2 ) )
                $PAR_1 = StringLeft ( $PAR_1, StringInStr ( $PAR_1, '"', 2, -1 ) - 1 )  
                ;
                $Sub_Array[ $Sub_Depth - 1 ][$Element_0] = $PAR_1
                ;
            EndIf
            ;
        Next
        ;
    Next

    $Parameters = ''
    
    For $Element = 1 To $Par_COUNT Step 1
        ;
        If $Parameters = '' Then
            ;
            $Parameters = $Sub_Array[ $Sub_Depth - 1 ][$Element]
            ;
        Else
            ;
            $Parameters = $Parameters &', ' &$Sub_Array[ $Sub_Depth - 1 ][$Element]
            ;
        EndIf
        ;
    Next




;ThisSub ( Eval ( 'Parameters' ) )

MsgBox ( 0, '', Eval ( 'Parameters' ) )

_ArrayDisplay ( $Sub_Array, '$Sub_Array' )
Exit

EndFunc
Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites
99ojo

Well that's strange, it seems to work if i make them optional :D

Func ThisSub ( $Par_FIX = 0, $PAR_OPT_0 = 0, $PAR_OPT_1 = 0 )

MsgBox ( 0, '', '$Par_FIX:' &$Par_FIX &'_ $PAR_OPT_0:' &$PAR_OPT_0 &'_ $PAR_OPT_1' &$PAR_OPT_1 &'_' )

MsgBox ( 0, '', 'OK' )

Exit

But I don't wan't them optional ! :huggles:

Hi,

maybe i missunderstand you:

ThisSub (1,2,3) ; parameters 1,2,3 see output msgbox
ThisSub () ; Parameters none, see output msgbox shows defined values of your function
Exit

Func ThisSub ( $Par_FIX = 0, $PAR_OPT_0 = 0, $PAR_OPT_1 = 0 )
    MsgBox ( 0, '', '$Par_FIX:' &$Par_FIX &'_ $PAR_OPT_0:' &$PAR_OPT_0 &'_ $PAR_OPT_1' &$PAR_OPT_1 &'_' )
    MsgBox ( 0, '', 'OK' )
EndFunc

Maybe this helps you or shows you a way. You also have a look at helpfile for function call:

$Parameters = 'Something,Else,Here'
$var = StringSplit ($Paramaters, ",",2)
ThisSub ( $var [0], $var [1], $var [2]  )

Func ThisSub ( $Something, $Else, $Here )
    ...
    ThisSub2 ( 'bla, bla, bla' )
    ...
EndFunc

;-))

Stefan

Share this post


Link to post
Share on other sites
EdDyreen

Hi,

maybe i missunderstand you:

Maybe this helps you or shows you a way. You also have a look at helpfile for function call:

$Parameters = 'Something,Else,Here'
$var = StringSplit ($Paramaters, ",",2)
ThisSub ( $var [0], $var [1], $var [2]  )

Func ThisSub ( $Something, $Else, $Here )
    ...
    ThisSub2 ( 'bla, bla, bla' )
    ...
EndFunc

;-))

Stefan

But when u use:

ThisSub ( $var [0], $var [1], $var [2]  )

U already know the number of parameters that will be passed to ThisSub ()

The Problem is:

CallMySub ( ThisSub, 'Something, Else, Here' )

Func CallMySub ( $SubRoutine, $Parameters )

    $Sub_Depth += 1

    Call ( $SubRoutine, eval ( 'Parameters' ) )

    $Sub_Depth -= 1

EndFunc

Func ThisSub ( $Par0, $Par1 = 0, $Par2 = 0 )

EndFunc

Where CallMySub can be used to call any Function with a variable amount of parameters depending on the function that is being called.

The reason is that i want to avoid having to set $Sub_Depth inside EVERY called Function !

But ALL parameters are being passed to $Par0

and $Par1 &$Par2 stay empty !

Edited by EdDyreen

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites
EdDyreen

Well it seems like it just can't be done in AU3, too bad

I've worked around it kinda, but now all my function are limited to use a maximum of 9

parameters, should be enough though. :D

Select
        ;
        Case $Par_COUNT = 0
            ;
            Call ( $SubRoutine )
            ;
        Case $Par_COUNT = 1
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
            )
            ;
        Case $Par_COUNT = 2
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][2] _
            )
            ;
        Case $Par_COUNT = 3
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][2] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][3] _
            )
            ;
        Case $Par_COUNT = 4
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][2] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][3] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][4] _
            )
            ;
        Case $Par_COUNT = 5
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][2] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][3] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][4] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][5] _
            )
            ;
        Case $Par_COUNT = 6
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][2] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][3] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][4] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][5] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][6] _
            )
            ;
        Case $Par_COUNT = 7
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][2] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][3] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][4] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][5] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][6] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][7] _
            )
            ;
        Case $Par_COUNT = 8
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][2] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][3] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][4] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][5] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][6] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][7] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][8] _
            )
            ;
        Case $Par_COUNT = 9
            ;
            Call (                                   _
                    $SubRoutine                      _
                    ,$Sub_Array[ $Sub_Depth - 1 ][1] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][2] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][3] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][4] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][5] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][6] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][7] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][8] _
                    ,$Sub_Array[ $Sub_Depth - 1 ][9] _
            )
            ;
        Case Else
            ;
            ERR_Set_THIS ( 'Func CallMySub ( ' &$SubRoutine &' ) parameter overflow !'
            ;
    EndSelect

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites
EdDyreen

Problem Solved no more limit in number of args thanks to build in function :D

Local $ArgArray[1] = [ 'CallArgArray' ]
;
For $Element = 1 To $Par_COUNT Step 1
    ;
    ReDim $ArgArray[ $Element + 1 ]
    ;
    $ArgArray[$Element] = $Sub_Array[ $Sub_Depth - 1 ][$Element]
    ;
Next
;
Call ( $SubRoutine, $ArgArray )

• Any number images • Images of any size • Any number of URLs • Any number of lines

Share this post


Link to post
Share on other sites
james3mg

If you passed the parameters as any number of elements in a single array variable, your function could then extract the parameters from the array.

Dim $Parameters[3] = ['Something','Else','Here']
ThisSub ( $Parameters  )

Dim $Parameters[Random(1,5,1)];random number of parameters
For $i=0 To UBound($Parameters)-1
    $Parameters[$i]=Chr(Random(65,90,1));each parameter will be a random uppercase letter, just as an example.
Next
ThisSub ( $Parameters )

Func ThisSub ( $_params);naturally, you'd do something more useful with the parameters than just count and display them.
    MsgBox(0,"ThisSub",UBound($_params)&" parameters passed")
    Local $str=""
    For $_i=0 To UBound($_params)-1
        $str&=$_params[$_i]&@CRLF
    Next
    MsgBox(0,"ThisSub Parameters:",$str)
EndFunc

Edit: looks like you found the solution yourself before I posted...nice job :D

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.