Issue with arrays

Hello!!!

I have add some dialogs into my script, but I am facing an issue when I try to pass this array string so to add custom names to my dialog buttons. Using this code from Katalon’s examples…

Object[] possibleValues = {"First", "Second", "Third" }
Object message_result = JOptionPane.showOptionDialog(null, "Message Text", "Message Title", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, possibleValues, possibleValues [0])

I get: unexpected token: First @ line 102, column 31.

Any idea why is this happening?

Thank you in advance!!!

A few suggestions.
1: change the curly brackets for straight brackets like you have after “Object” in your first line.

2: change your reference “Object” to String. A String is an Object and the contents of your list are Strings, so you are more tightly data binding–unless you are going to put other Object types in the “possibleValues” list–like:
String[] possibleValues = ["First", "Second", "Third" ]
3. the return data type of your message_result seems to be an “int”, which is not an Object (there is a difference between an “Integer”, which is an Object, and an “int”, which is a primitive date type. Sorry for being too picky, but it is something we have to be careful of while programming. You may be better off going like:
def message_result = JOptionPane.showOptionDial...

“def” let’s Groovy programming language determine the data type. If you hover your mouse over “message_result” within KS, you will see what I mean.

2 Likes

Done!!! Thank you very much!!! :slightly_smiling_face: