Page 1 of 1

Empty parameter in function

Posted: Fri Apr 03, 2015 9:58 pm
by croivo
I have this function:

Code: Select all

function play item1, item2, item3, item4, item5, item6

repeat with numberVar = 1 to 6
      put ("item" & numberVar) into theNameOfHolder
      
      if theNameOfHolder is empty then
         answer ("Variable " & theNameOfHolder & " is empty!")
      end if
      
   end repeat

end play
Very often I won't call all 6 parameters... So I need to check somehow if some 'item' variables are empty or not.
I tried with this if statemet to check if it's empty, but it's not working... Any ides?

Re: Empty parameter in function

Posted: Fri Apr 03, 2015 10:12 pm
by SparkOut
Quick answer: see "value" in the dictionary.

Re: Empty parameter in function

Posted: Fri Apr 03, 2015 10:57 pm
by croivo
Thanks :D

Re: Empty parameter in function

Posted: Fri Apr 03, 2015 11:26 pm
by Klaus
Hi croivo,

"play" is a reserved word in LC, so to avoid possible inconvenience
you really should rename your function! 8)


Best

Klaus

Re: Empty parameter in function

Posted: Fri Apr 03, 2015 11:39 pm
by croivo
Klaus wrote:Hi croivo,

"play" is a reserved word in LC, so to avoid possible inconvenience
you really should rename your function! 8)


Best

Klaus
Yes yes I know, at the moment of writing I was not thinking about the name too much...

Re: Empty parameter in function

Posted: Sat Apr 04, 2015 12:16 pm
by SparkOut
Longer answer, download, unzip and investigate this demo

Re: Empty parameter in function

Posted: Tue Apr 14, 2015 4:57 pm
by guenter.g
You can use the functions paramcount() and param() (see in dictionary)

Code: Select all

function play1 item1, item2, item3, item4, item5, item6
   repeat with tParam = 1 to paramcount()
      if param(tParam) is empty then
         answer ("item" & tParam && "is empty!")
      end if
   end repeat
end play1