Hello
I using 2011a. modifying an existing script by adding an additional udf. I need to use the return value (which basically is a count) as the limit in a For loop. When I run it it says "uninitialized variable etc etc"
I have place a message(..) in the function and I know it's doing what it's supposed to do.
All my UDF's are defined before the main section.
Can someone tell me what I'm doing wrong?
Thanks
Likely cause is faulty logic in your script but since you haven't provided the logic, it is difficult to point out the fault.
Should have added that not properly closing a structure block with an 'endif', 'next', or 'endwhile' as the case my be can sometimes cause errors that seemingly defy explanation.
Hello
Thx for replying.
Here is the script
I'm guessing it has to do with the way I break out of the while @true
but I don't know how to correct it
Thanks for looking at it and helping me
It is not entirely clear how much of your script is intentional as apposed to incidental but one thing is certain. Never use a goto statement to break out of a structure of any kind. The following script illustrates one of several possible alternatives but you would need to base your script on your actual intentions.
#definefunction getddirct(ddiroot)
ddirct=0
;dirchange(ddiroot)
;currdir=dirget()
dirlist=diritemize(ddiroot:"*.*")
nCount = ItemCount(dirlist, @Tab)
for i = 1 to nCount
dataxxxdir = ItemExtract(i, dirlist, @Tab) ; or
;;dataxxxdir = ddiroot:ItemExtract(i, dirlist, @Tab) ?????
firstfour = strindex(dataxxxdir,"data",1,@fwdscan)
if firstfour <> 0
ddirct=ddirct+1
endif
next
return ddirct
#endfunction
;********************* M A I N ***********************
dirchange("C:\Projects")
currdir=dirget()
ddirct = getddirct(currdir)
message("ddirct is",ddirct)
hi
yeah I thought it was a bad idea. I got my value by changing the udf to a subroutine
but i'm still working on cleaning up the logic
thanks a lot
You can get the value from a user defined function by placing your function call on the right-hand side of an assignment statement with a variable on the left. But a subroutine works too.
That's good to know
thanks for your help