cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

Defaultvalue for UIReadStringMessage(true);

DieterKotsch
5-Regular Member

Defaultvalue for UIReadStringMessage(true);

How can i define a Default value for the UIReadStringMessage(true);

The command appears in my jlinkapp without a defaultvalue. On page 79 of the helpfile you can read the note.

A default value is displayed in the text box as Input.

When user presses the Enter key as input in the user interface, the default value is not passed to the

Creo Object TOOLKIT Java method; instead, the method returns a constant string use_default_string. When this string is returned, the application

must interpret that the user wants to use the default value.

4 REPLIES 4
sjuraj
15-Moonstone
(To:DieterKotsch)

I do not know how to display default value at the input, but the string use_default_string is just flag for using default value you define in your code, so you can do:

String myDefaultValue = "my_parameter_name";

String result = session.UIReadStringMessage(true);


if(result.equals("use_default_string");

   result = myDefaultValue;


//rest of your code ...


If you need to inform user what is default string value you can display it in the message log using method UIDisplayMessage

Alternatively you can display default string using new process, which will create GUI and then dissapear, like the Android is displaying short messages e.g. when you set alarm.

DieterKotsch
5-Regular Member
(To:sjuraj)

HI

Thanks a lot.

But I'm looking for the to display a default value at the input or to define a Combobox at the input in Jlink.

sjuraj
15-Moonstone
(To:DieterKotsch)

Hi, if you want combobox you can easely create jDialog and fill it with combobox or listview. You can also fill jDialog with JFXPanel, which enable you to use JavaFX components into swing component. With JavaFX you can create really nice and modern looking GUI. I suppose you can create such thing as combobox in j-link. To create GUI is issue of java object toolkit.

You need to provide a specific pattern in the message file.
In PROTOOLKIT the default value to the read function is supplied by the preceding "ProMessageDisplay" function if its argument does include the special form "|||" within.
In ObjectToolkit it's barely the same; the default value is provided by the preceding "UIDisplayMessage" function, provided the message has the same form.

Here's an example from PROTOOLKIT examples folders:

message file (msd_ugmessages.txt) content:

%CPUSER Enter any integer between %0d and %1d: |||%2d
Enter any integer between %0d and %1d: |||%2d
#
#

and the code (UgMessagewindoeUse.c)

/*------------------------------------------------------------------*\
  Read an integer with a restricted range and a default value.  Message 
  will display as a prompt.
\*------------------------------------------------------------------*/
  err = ProMessageDisplay (msgfil,
      "USER Enter any integer between %0d and %1d: |||%2d", &irange[0],
      &irange[1], &default_int);
  err = ProMessageIntegerRead (irange, &i2);
  if (err != PRO_TK_NO_ERROR && err != PRO_TK_GENERAL_ERROR)
      return (err);
      
Now a similar example in Object Toolkit:

msg_user.txt:

enter desired string.
enter desired string.|||%0s
enter desired string.|||%0s
#

the code:

xstring desiredString, defaultString{ "Default" };
xstringsequence_ptr xDefaultValues = xstringsequence::create();
xDefaultValues->append(defaultString);
pfcGetCurrentSession()->UIDisplayMessage("msg_user.txt", "enter desired string.", xDefaultValues);
try {
desiredString = pfcGetCurrentSession()->UIReadStringMessage(xfalse);
}
catch (...) {
desiredString = "user aborted";
}
if (desiredString == xstring("use_default_string")) {
desiredString = defaultString;
}

Best regards.
Giuseppe.

Announcements

Top Tags