Contains vs Equal To

Dear all,

I am working on a little application that has a series of text fields.

Each text field represents a step in the endotracheal intubation sequence.

Something like the following code would be easy to implement

if TextField1.Text = “pre-oxygenate” then

The problem arises when users use different wording to describe the same process such as pre-oxygenation.

I am trying to find a way to use “contains given text” rather than “equals to the given text”. This is rather easy to do in AppleScript but I am not sure how to do it in XOJO.

Any suggestions would be appreciated.

Thank you,


You can use String.IndexOf for this

If s.IndexOf("oxy") > -1 Then

Can you replace the text fields with pop up menus shoo you can better control the inputs?

1 Like

Hi, Kem,

Thank you for the suggestion.

I considered using poppupmenus - this would simplify the process.

From the teaching standpoint, popups will create a bias of availability - the users will need to rank the available options rather than creating the text field entries from scratch.

This is a problem for every test software. It’s usually done wrong. I see the results of it show up daily on a certain subreddit.

In my opinion, the best way to solve this is to have the instructor provide each of what they will accept for a correct answer. You would need to store an array of the correct answers.

1 Like

Normalize the inputs by removing punctuation and whitespace, then use regular expressions that will flexibly check the possibilities.

But even then, spelling might be an issue.

Hi, all,

I used the method suggested by Greg.

Here is the code.

s As String


if s.IndexOf(“oxy”) > -1 then

Canvas holds an image with the checked checkbox. As soon as “oxytocin’s” is detected, the text field text is replaced with the normalized name for the step, and the canvas with the checkbox becomes visible.

This will definitely work. Big thank you to Greg, Kem and Tim.