Handling Function Returns

Hi,
I am new to Eggplant so please bear with me...
I have a function called dialDigits which return 1 or 0.
Now when i call this function, as dialDigits "1 2 3", and it returns 1 or 0, I want to to be able to decide whether to continue script execution in one line..Currently I have
dialDigits "1 2 3"
if the result is 1
log "success"
end if

I want to be able to do something like

if the result of dialDigits "1 2 3" is 1
log "sucess"
end if

So that it can be made into one line..I am not sure what the syntax is to do this...

Thanks
Sanjit

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    if dialDigits("1 2 3") is 1 then
         log "Success"
    else
          logError "Failure"
    end if
    
    "1 2 3" seems like a strange value for a parameter. That's actually a single string containing 3 numbers separated by two spaces. Do you mean to pass a list of values? If so, that would look like this:
    if dialDigits(1,2,3) is 1 then...
    
    The declaration of your function to take 3 parameters would look like this:
    function dialDigits val1, val2, val3
          put val1
          add 4 to val2
        -- do stuff
          return someVal
    end dialDigits
    
  • SanjitSanjit Member
    Thanks Matt for the quick response..So one thing if I wanted to exit script executionon failure, would I do "exit all"?
  • EggplantMattEggplantMatt ForumAdmin admin
    Yes, "exit all" ensures everything stops.
Sign In or Register to comment.