Replacement Text and Functions

headley27
headley27 Member Posts: 188
I am having trouble passing replacement text strings into text constants when using functions. For example:

Text Constants
    Text001 = SomeText %1. Text002 = SomeText %1 %2 SomeText. Text003 = SomeText %3.
IF CONFIRM(Text001 + '\\' + Text002 + '\\' + Text003, 'ReplaceText1', 'ReplaceText2', 'ReplaceText3') = TRUE THEN BEGIN
The Dialog I would like to see is:
    SomeText ReplaceText1. SomeText ReplaceText1 ReplaceText2 SomeText. SomeText ReplaceText3.
When I compile I get a message:
    Type conversion is not possible because 1 of the operators contains an invalid type. Boolean := Text
My cursor moves to the position following the first comma:
    IF CONFIRM(Text001 + '\\' + Text002 + '\\' + Text003,
|'ReplaceText1', 'ReplaceText2', 'ReplaceText3') = TRUE THEN BEGINI can only assume that the function expects a boolean 'Default' value but sees my replacement text string:
    Ok := Dialog.CONFIRM(String
[, Default] [, Value1] ,...)How do I pass replacement text values into a function or pass them into a text variable prior to running the function?
//I realize this will not work but it will provide an example of my need
txtConfirm := Text001 + '\\' + Text002 + '\\' + Text003, 'ReplaceText1', 'ReplaceText2', 'ReplaceText3') 
IF CONFIRM(txtConfirm) = TRUE THEN BEGIN
Thank you for your assistance.

Answers

  • SPost29
    SPost29 Member Posts: 148
    You were so close!! :D

    just add either True or false where the default is and you should have it

    true means yes is the button with focus, false makes No the button with focus


    so it's

    if confirm('blah %1 blah %2 blah',TRUE,textone, texttwo) then
    OR
    if confirm('blah %1 blah %2 blah',FALSE,textone, texttwo) then

    CONFIRM
    Use this function to create a dialog box which prompts the user for a yes or no answer. The system centers the dialog box on the screen for you.

    Ok := CONFIRM(String [, Default] [, Value1] ,...)
    Ok

    Data type: boolean

    This return parameter reflects the user's selection.

    Ok will be...
    If you entered...

    TRUE
    Yes

    FALSE
    No


    String

    Data type: code or text constant

    The system displays this string in the dialog box. Use a back slash (\) to indicate a new line. The string can be a multilanguage enabled text constant.

    Default

    Data type: boolean

    Describes what the computer should use as the default button. If you do not specify a default, the system uses No.

    Comments
    The system sizes the message window for you. The height of the window corresponds to the number of lines and the width corresponds to the length of the longest line.

    OR


    The help:

    CONFIRM
    Use this function to create a dialog box which prompts the user for a yes or no answer. The system centers the dialog box on the screen for you.

    Ok := CONFIRM(String [, Default] [, Value1] ,...)
    Ok

    Data type: boolean

    This return parameter reflects the user's selection.

    Ok will be...
    If you entered...

    TRUE
    Yes

    FALSE
    No


    String

    Data type: code or text constant

    The system displays this string in the dialog box. Use a back slash (\) to indicate a new line. The string can be a multilanguage enabled text constant.

    Default

    Data type: boolean

    Describes what the computer should use as the default button. If you do not specify a default, the system uses No.

    Comments
    The system sizes the message window for you. The height of the window corresponds to the number of lines and the width corresponds to the length of the longest line.
  • headley27
    headley27 Member Posts: 188
    Crap.

    I can't believe how easy that was.

    I've used the Default property many times before but never in combination with replacement text.

    I was banging my head against the wall with this one. ](*,)

    Thanks so much !!!
  • DenSter
    DenSter Member Posts: 8,307
    Just remember there are no multiple overloads in NAV. Only parameters at the end of the parameter list may be optional. As soon as you use one of them, you have to use all previous ones.
  • headley27
    headley27 Member Posts: 188
    Good to know.

    Thanks. :D