Execute Subroutines

Verb: goSubs

Runs a dynamic list of subroutines based on their names, and new routines can be added during the execution of the command.


goSubs --routines(List<String>)


Script Designer Required AcceptedTypes Description
--routines Subroutines Required List<Text> List with the names of the subroutines to be executed.
The name of the subroutine is given when creating it, and the creation process occurs in the following ways:
  • Select a script command block, in "Design" mode, right-click and go in the option "Advanced > Extract Routine";
  • Create a subroutine manually, in "Design" mode, from the "View > Routines > New Routine" menu; or, in "Script" mode, insert the verb of the command "beginSub", insert the instructions and end with the command "endSub".
  • Example

    Example 1: Two subroutines are created, "subroutineA" and "subroutineB", in addition to a list called "newSubRoutine". In this context, the Add to Collection command is used to add the name "subRoutineA" to the list, so that when using the Execute Subroutines command, this subroutine is executed. Note that, in the "subRoutineA" instruction block, the name "subRoutineB" is added, again by the Add to Collection command, to the "newSubRoutine" list, so that the "subRoutineB" subroutine is dynamically executed by the Execute Subroutines command, previously used.

    defVar --name newSubRoutine --type List --innertype String
    add --collection "${newSubRoutine}" --value subRoutineA
    goSubs --routines ${newSubRoutine}
    beginSub --name subRoutineA
    	add --collection "${newSubRoutine}" --value subRoutineB
    	logMessage --message "Execution of subroutine A started." --type "Info"
    beginSub --name subRoutineB
    	logMessage --message "Execution of subroutine B started" --type "Info"

    Example 2: After adding the names of the two subroutines (subRoutineA and subRoutineB), the list of subroutines in the Execute Subroutines command is informed. In this other context, the subroutines show the current time when they are being executed.

    defVar --name subRoutinesList --type List --innertype String --value "[subRoutineA,subRoutineB]"
    defVar --name currentDate --type DateTime
    goSubs --routines ${subRoutinesList}
    beginSub --name subRoutineA
       getCurrentDateAndTime --localorutc "LocalTime" currentDate=value
       logMessage --message "Current date of subroutine A: ${currentDate}" --type "Info"
    beginSub --name subRoutineB
       getCurrentDateAndTime --localorutc "LocalTime" currentDate=value
       logMessage --message "Current date of subroutine B:${currentDate}" --type "Info"

    See Also

  • Run Subroutine If