Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a func as an argument to a proc or func

Status
Not open for further replies.

efittery

Programmer
Feb 13, 2003
21
US
I have:

strfmt s0 "%-33s%d", "vacWorkflow.fillStatus", 1
logTransmitWait("DISPLAY_WORKFLOW_LIST ^M", s0)

I would like to have:

logTransmitWait("DISPLAY_WORKFLOW_LIST ^M", createWatchString("vacWorkflow.fillstatus", 1)

func createWatchString : string
param string watchString
param integer value
strfmt s0 "%-33s%d", watchString, value
return s0
endfunc

I tried this approach and got the error condition that the argument list of logTransmitWait didn't match the arguments. The function returns a string and the argument list of logTransmitWait uses a string as the second argument.

I wouldn't mind using a macro, but I wasn't successful doing that either.

any suggestions?


 
Your function should work only you have omitted a required right perenthesis

You should use
Code:
logTransmitWait("DISPLAY_WORKFLOW_LIST ^M", createWatchString("vacWorkflow.fillstatus", 1))

instead of
Code:
logTransmitWait("DISPLAY_WORKFLOW_LIST ^M", createWatchString("vacWorkflow.fillstatus", 1)
 
actually I was using:

logTransmitWait("DISPLAY_WORKFLOW_LIST ^M", createWatchString("vacWorkflow.fillstatus", 1))

as you suggest. I just made a typo in the original post.

You say, "should work"... have you ever used this construct when programming with ASPECT?
 
Yes, I have used similar. I also copied your example and got it to work as I would have expected. See Below.

Code:
proc main
logTransmitWait("DISPLAY_WORKFLOW_LIST ^M", createWatchString("vacWorkflow.fillstatus", 1))
endproc

func createWatchString : string
   param string watchString
   param integer value
   strfmt s0 "%-33s%d", watchString, value
   return s0
endfunc

proc logTransmitWait
param string aaa, bbb
usermsg "`"%s`"`n`"%s`"" aaa bbb
endproc
 
I also tried it as a function and it also works. Let us know if you have any other problems with it or with either of my examples.

Code:
proc main
string result = logTransmitWait("DISPLAY_WORKFLOW_LIST ^M", createWatchString("vacWorkflow.fillstatus", 1))
if nullstr result
   usermsg "Function is working as expected"
else
   errormsg "%sFunction did not work as expected." result
endif
endproc

func createWatchString : string
   param string watchString
   param integer value
   strfmt s0 "%-33s%d", watchString, value
   return s0
endfunc

func logTransmitWait : string
param string aaa, bbb
string ExpectedStr1 = "DISPLAY_WORKFLOW_LIST ^M"
string ExpectedStr2 = "vacWorkflow.fillstatus           1"
string ErrorStr = ""
if not strcmp ExpectedStr1 aaa
   ErrorStr = "First variables did not match`n"
endif
if not strcmp ExpectedStr2 bbb
   strfmt ErrorStr "%sSecond variables did not match`n" ErrorStr
endif
return ErrorStr
endfunc
 
first thing is thanks....

second thing is.... I wish I had my old code ( blew it away ) to figure out what I did wrong.

third thing is..... I will try this out - I am sure your right. It wouldn't make any sense otherwise.
 
What you provided works fine. thanks

Maybe I was just getting to fried last night and I just thought it didn't work.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top