Script IF = string

Ask and answer questions related to any type of OSA scripting.
Post Reply
Message
Author
Automate
Posts: 1691
Joined: Sat Dec 11, 2010 1:44 pm
Location: US

Script IF = string

#1 Post by Automate » Tue Jan 11, 2011 2:32 pm

Does the script IF statement work with strings? what is the proper syntax?

I tried

Code: Select all

IF Myobject.Property = "mystring" THEN
and

Code: Select all

IF Myobject.Property = mystring THEN
and neither one seems to be true even though Myobject.Property is set to 'mystring'.

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Script IF = string

#2 Post by Vaughn » Tue Jan 11, 2011 4:48 pm

I just made this test script in the editor and ran it, it worked fine:

IF System.Occupant String = "Eric is here" THEN
SPEECH-VanMain.Run Method.Say."Test good"
END IF

Now the current script editor is bad about handling its intellisense inserts and I seem to get hidden characters in my scripts, and it will break them. So if you have a line that just won't work, retype it or copy/paste it into notepad and back.

Vaughn

Overeating
Posts: 1
Joined: Wed Jan 07, 2015 2:33 am

Re: Script IF = string

#3 Post by Overeating » Wed Jan 07, 2015 2:36 am

neither one seems to be true even though Myobject.Property is set to 'mystring'.

Automate
Posts: 1691
Joined: Sat Dec 11, 2010 1:44 pm
Location: US

Re: Script IF = string

#4 Post by Automate » Wed Jan 07, 2015 9:19 am

Did you check the script processor log?

janetfdoss
Posts: 1
Joined: Thu Apr 30, 2015 9:27 pm
Location: 1435 Snider Street Pueblo, CO 81003
Contact:

Re: Script IF = string

#5 Post by janetfdoss » Sat May 16, 2015 3:17 am

String a = new String("aa");
String b = new String("aa");
boolean check1 = a == b; // false
boolean check1 = a.intern() == b.intern(); // true

Check the above code with your characters. Hope it will help you. In case it does not provide any kind of help. Then ping me i will help you.

the happy family show
Last edited by janetfdoss on Mon Oct 26, 2015 9:10 pm, edited 1 time in total.

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Script IF = string

#6 Post by Vaughn » Sat May 16, 2015 8:18 am

In the latest version I fixed a IF Blah = "" THEN, as the "" where not working, I can retest the " on other things.


BUT the internal scripting is not really " " based so try without quotes at all...

I will run me test script in a few minutes and see how it acts and will post it.


Vaughn

Vaughn
Site Admin
Posts: 1432
Joined: Thu May 13, 2010 2:17 pm

Re: Script IF = string

#7 Post by Vaughn » Sat May 16, 2015 11:35 am

I have done

IF Vaughn.Full Name = "Vaughn Rupp" THEN

IF Vaughn.Full Name = Vaughn Rupp THEN

IF Vaughn.Full Name = "" THEN

and all pass for me, I still have to test != on the same data to make sure it is not always passing TRUE, but the = seems to work fine.

Are you actually typing "Property"? Try with the name of A property, like Full Name above is a property I added to PERSON in 046. The Property keyword is not actually used anywhere.


Vaughn

Post Reply