How to call functions inside Repeat-loop from other script

Hi All,

Require a method to proceed in scripting. Following is the overview of the same:

I need to iterate a set of funtions in a script file based on the inputs present in a text file. Inputs are accepted from a text file and all the funtions are present in a separate script file in the same suite.

I tried calling all the funtions inside the "repeat" loop. But the scripts are encountering an exception when the functions search for any image, saying - cannot open the image file :thedata.
My script looks something like below:

Script 1:

Start using "Script 2"

repeat with thedata = each line of file "input.txt"
function1()
statement 1.
function2()
statement 2.
end repeat

Stop using "Script 2"

Script 2:

funtion function1
if ImageFound(item 1 of thedata)
statement...
...
end if
return stmt
end function1

funtion function2
command...
statement...
...
end function2

Is it possible to script in the above way :?: If not so, please suggest any alternative to code the above :!:

Comments

  • Your function and script do not share the same variables. Therefore, you need to pass "theData" read in from your "input.txt" file to "function1" as a parameter.

    In addition, you cannot invoke a function as:
    function1
    

    A function must be invoked as part of an expression:
    put function1() 
    

    I would recommend that you write your functions as "to handlers". This way, you can invoke them as either functions or handlers.

    That is:

    Script1:
    start using "Script2"
    repeat with thedata = each line of file "input.txt"
    
         function1(thedata)
    ....
    ...
    ...
    


    Script2:
    to function1(data)
    
        if imageFound(item 1 of data)
             ....
    
        end if
        ... 
    end function1
    
    
Sign In or Register to comment.