View Full Version : passing a string to a method
waterstone
02-26-03, 15:38
| I have a form level method:
method TakeString(var Hint string)
endmothod
I attempt to call it from a uiobjects mouseenter method like this
TakeString("Hello There")
I get the syntax error "parameter mismatch on the TakeString statement.
According to the help files, I can pass a string by value.
I know I can do the following
var Passit string endvar
Passit = "Hello There"
TakeString(Passit)But I'd really like to pass the literal.
I'm sure I'm missing something obvious.
TIA,
Waterstone |
Just an guess but the word var means variable you are passing an constant. ( var means it can return an value; you can't return an value to an constant.)
Try using TakeString(String("Hello There"))
or removing the var in the method defination.
Tim S
waterstone
03-17-03, 08:00
| Tim,
Thanks for the suggestion. While the suggestion did not work because the called method cannot have a string literal as an argument, your post prompted me to use constants to define the values I wanted to pass, making the code much neater.
method ShowHints(const Hint String)
message(Hint)
HintText = Hint
HintBox.visible = true
endMethod
Then called it with predefined constants
ShowHint(Report01) where Report01 is a constant declared at the form level.
Thanks Again,
Stephen |
You can also simply remove "var":
method TakeString(Hint string)
Bye!
vBulletin v3.5.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.