Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    Posts
    3

    Unanswered: passing a string to a method

    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

  2. #2
    Join Date
    Mar 2003
    Location
    Indiana, USA
    Posts
    100
    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

  3. #3
    Join Date
    Jan 2003
    Posts
    3

    passing a string to a method

    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

  4. #4
    Join Date
    Aug 2003
    Location
    Bologna - Italy
    Posts
    209
    You can also simply remove "var":

    method TakeString(Hint string)


    Bye!
    The only failure is not trying to do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •