How Can We Help?

Writing Text-to-Software Commands

You are here:
< Back

This topic gives you the rules for writing excellent Text-to-software commands. There are some other Help topics that include reference info for Text-to-software. You might want to check them out, too. They are:

Creating Smart Parts With Text-to-software Synonyms; and
Creating [Components] Using Text-to-software

I EQUALS APPLICATION
You and your application are one—at least in Text-to-Software. When you want your application to do something, start the command with “I”.

Creating Business Rules

To set up the logic of your application (For information about what logic is, refer to http://en.wikipedia.org/wiki/Computational_logic), start your sentence with “If”. When it sees a sentence that starts with “If”, Text-to-Software knows that you want it to create a business rule. Business rules aren’t forms or fields or things you can see on the screen. Business rules define what the application does. A business rule contains a transition and a description of what that transition does.

Business rules appear under use cases in the Software Lifecycle box on the Requirements Analysis tab.

NOTE! Once you have set up the transition, you can edit it through the Text-to-Software interface. For more information, see Defining Transitions Between Controller States.

The basic logic syntax Text-to-Software will be able to understand is:
IF [some condition] THEN [some statement].

For example:
If accountNumber equals portfolioVALUE then accountNumber is 10.

Would make a transition that has the event “accountNumber equals portfolioValue” and an action that sets the accountNumber to the value 10.

The value of accountNumber is obtained and set by the actual element named “accountNumber” in the application.

IF/IF NOT/THEN/ELSE
You can use “if”, “if not”, “then”, and “else” to construct commands that will make your application perform an action under certain circumstances.

“If”—Write “if” to make the application check if something is true before doing an action.

“If not”—Write “if not” to make the application check if something is not true before doing an action.

“Then”—Write “then” to tell your application what to do if the “if” statement is true.

“Else”—Write “else” to tell your application what to do if the “if” statement is not true.

The following are some examples.

Simple conditional “if” action statement
Here’s a simple statement that uses “if” to check if something is true before doing an action.
Text: I print if ready
Smalltalk: (ready) ifTrue: [(self print)]
NOTE! It’s okay if there are extra spaces in the sentence. Text-to-Software will ignore them.

Conversion of my to self and is to =
This example combines “if” with the “is” operator, checking to see if my name is Martin. If my name is Mark, it will print. If not, it won’t.
Text: I print if my name is ‘Mark’
Smalltalk: (self name = ‘Mark’) ifTrue: [(self print)]

Simple conditional “if” action statement
Here’s a statement that will print if something is not true, in this case, if the application is not ready.
Text: I print if not ready
Smalltalk: (ready) ifFalse: [(self print)]

If/then construction
This example combines an “if” statement with a “then” statement to evaluate if a condition is true, and if it is, to perform an action.
Text: if saGETeA corba client”s master application is not nil then I print.
Smalltalk: (SAGETEACorbaClient masterApplication != nil) ifTrue: [(self print)]

If/then/else construction
This example combines an “if” statement with a “then” statement to evaluate if a condition is true, and if it is, to perform an action. But if the “if” statement is false, then the “else” statement performs another action. In this case, if the master application is not nil, then the application prints, but if it is nil, then the application quits.
Text: If saGETeA corba client”s master application is not nil then I print else I quit.
Smalltalk: (SAGETEACorbaClient masterApplication != nil) ifTrue: [(self print)] ifFalse: [(self quit)]

ACTIONS
The verbs that turn into actions for your application are defined by the experts in your company. To get the list of action words you can use, talk to the person in your company who worked on the Text-to-Software project.

Using Conditional Statements/Operators

When you’re writing your text, you will need to tell your software to do certain things under certain circumstances. Say you think it might rain on your application, so you give it an umbrella. If your application walked around with its umbrella open all the time, it would look silly and the other applications would make fun of it. So you would write some text that tells the application to check if it’s raining, and if it is, to open the umbrella.

When you use these conditional statements, the application checks the thing before the statement with the thing after the statement.

Here are the conditions that you can set:

“is larger”—Write “is larger” to check if the first number or placeholder has a greater numerical value than the second number or placeholder. If you’re a mathie, it’s the equivalent of “>”. Don’t write “is larger than”—your text won’t work properly.

“is larger or equal”—Write “is larger or equal” to check if the first number or placeholder is equal to or has a greater numerical value than the second number or placeholder. If you’re a mathie, it’s the equivalent of “>=”. Don’t write “is larger than”—your text won’t work properly.

“is less”—Write “is less” to check if the first number or placeholder has a lower numerical value than the second number or placeholder. If you’re a mathie, it’s the equivalent of “<”. Don’t write “is less than”—your text won’t work properly.

“is less or equal”—Write “is less or equal” to check if the first number or placeholder is equal to or has a lower numerical value than the second number or placeholder. If you’re a mathie, it’s the equivalent of “<=”. Don’t write “is less than”—your text won’t work properly.

“is not equal”—Write “is not equal” to check if the first number or placeholder is equal to or has a lower numerical value than the second number or placeholder. If you’re a mathie, it’s the equivalent of “!=”. You can also write “is not” and get the same effect.

“is not”—Write “is not” to check if one item is the not the same as a second item. If you’re a mathie, it’s the equivalent of “!=”. You can also write “is not equal” and get the same effect.

“is equal”—Write “is equal” to check if the first number or placeholder is equal to the second number or placeholder. If you’re a mathie, it’s the equivalent of “<=”. This is the same as “is” and you can use them interchangeably.

“is”—Write “is” to check if one item is the same as a second item. If you’re a mathie, it’s the equivalent of “!=”. This is the same as “is equal” and you can use them interchangeably.

Using Boolean Operators

What tech call “Boolean operators” are simple words that you use to create conditions that the application has to check before performing the actions you tell it to. For example, maybe you only want your application to open its umbrella if it is both cloudy and raining. In that case, you would use an “and” operator to make your application check to see that it is cloudy and raining before opening its umbrella. Or maybe you would like your application to open its umbrella if it is raining, but not if it is windy. In that case, you could use a “not” statement so that your application would not open its umbrella if it is windy, even though it is raining.

The Boolean operators you can use are:

“And”—Write “and” to add another condition that has to be fulfilled before doing an action.

“Or”—Write “or” when you want your program to do one thing or another, but not both.

“Not”—Write “not” when you are looking for a condition to be not true. For example, you could tell your application to check if it is raining, and if is it not raining, to put its umbrella down. If you tried to write this command without using not, you would end up telling your application to check to see if it’s sunny, if it’s cloudy, if it’s snowing, and so on. You’ll find it simpler to just tell your application to check if it’s not raining by using a “not” statement.

Logical statement with “or”
This example is a simple logical statement that uses the “or” operator.
Text: my age is 3 or my age is 5
Smalltalk: (self age = 3 or:[(self age = 5)])

Logical statement with “and”
This example is a simple logical statement that uses the “and” operator.
Text: saGETeA corba client”s master application is not nil and my name is nil.
Smalltalk: (SAGETEACorbaClient masterApplication != nil and:[(self name = nil)])

Multiple statement conversion separated by dot
Put a dot (period) at the end of a sentence to let the application know where the command ends.
Text: I print if ready. I see if not blind
Smalltalk: (ready) ifTrue: [(self print)]. (blind) ifFalse: [(self see)].

Conversion of my to self and is not to !=
This example combines an if statement with the “is” operator and the “not” Boolean, checking to see if my name is Mudassar. If my name is not Mudassar, it will print. If my name is Mudassar, it won’t.
Text: I print if my name is not ‘Mudassar’
Smalltalk: (self name != ‘Mudassar’) ifTrue: [(self print)]

Convert expression sagetea corba client”s master application to SAGETEACorbaClient masterApplication
In this example, the application will print if the master application is not nil.
Text: I print if not sagetea corba client”s master application is nil
Smalltalk: (SAGETEACorbaClient masterApplication = nil) ifFalse: [(self print)]

Convert expression saGETeA corba client”s master application to SAGETEACorbaClient masterApplication. SAGETEACorbaClient class name is defined with false letters cases
Text: I print if saGETeA corba client”s master application is not nil
Smalltalk: (SAGETEACorbaClient masterApplication != nil) ifTrue: [(self print)]

MasterApplication method is not spelled correctly but method name is still well guessed
In this example, the Text-to-Software monkeys are pretty smart in converting the text to SmallTalk code. The word “master” has a typo, but the monkeys recognize it and convert it correctly anyway. Clever monkeys.
Text: I print if saGETeA corba client”s masterS application is not nil
Smalltalk: (SAGETEACorbaClient masterApplication != nil) ifTrue: [(self print)]

Complex logical “if“ statement with ”and” action statement
This example uses “and” to require two conditions before printing.
Text: I print if ready and funny
Smalltalk: (ready and:[(funny)]) ifTrue: [(self print)]

Complex logical “if” action statement with ”ors”
This example uses “or” to check out three conditions before printing. If all three conditions are true, the application will print, but the application will also print if only two of them are true, or only one of them is true. The only case where the application won’t print is if none of the conditions are true.
Text: I print if ready or steady or funny
Smalltalk: (ready or:[(steady or:[(funny)])]) ifTrue: [(self print)]

Complex logical “if” action statement with “ands” and “ors”
This example combines an “and” statement with an “or” statement. The first condition (ready) must be true for the application to print, but only one of the last two conditions (steady or funny) has to be true. If the application will print if the application is:
— Ready and steady
— Ready and funny
— The application will also print if ready and steady and funny.
Text: I print if ready and steady or funny
Smalltalk: (ready and:[(steady or:[(funny)])]) ifTrue: [(self print)]

If/then construction with “and” and “or” in logical statement with “not”
This example shows you how to combine “and” and “or” to check three different conditions. In order to print in this scenario, the master application has to be not nil, but either my name has to be not nil or my surname has to be not nil. The application will print if the master application is not nil and my name is not nil, and it will print if the master application is not nil and my surname is not nil. It will also print if the master application is not nil and my name is not nil and my surname is not nil. It won’t print if the master application is nil, or if the master application is not nil and my name and my surname are both nil.
Text: If saGETeA corba client”s master application is not nil and my name is not nil or my surname is not nil then I print.
Smalltalk: (SAGETEACorbaClient masterApplication != nil and:[(self name != nil or:[(self surname != nil)])]) ifTrue: [(self print)]

If/then/else construction with “and” and “or” in logical statement
This example combines the “and” and “or” operators with an if/then/else construction. In this case, if the master application is not nil and my name is nil, the application will print. If one, or both, of the two requirements are not met, the application will not print, and it will quit.
Text: If saGETeA corba client”s master application is not nil and my name is nil then I print else I quit.
Smalltalk: (SAGETEACorbaClient masterApplication != nil and:[(self name = nil)]) ifTrue: [(self print)] ifFalse: [(self quit)]

Writing Complex Commands

Once you’ve got the hang of writing simple commands without destroying the fabric of reality as we know it, you can string them together to make complex applications just like any software development geek.

Here are a couple of examples:
EXAMPLE 1—This example shows how to combine an if/then statement with a Boolean operator (in this case, “and”) to make the application check for multiple conditions before looking at the application’s download time. In this case, the application’s address can’t be blank, and the application’s street address has to be “Zagorska 12/35”.

Text:
‘if saGETeA corba client”s master application”s address is not nil
and saGETeA corba client”s master application”s address”s street is equal ”Zagorska 12/35”
then my master application”s application download time”s minutes .’

Smalltalk:
‘((SAGETEACorbaClient masterApplication address != nil)
and:[(SAGETEACorbaClient masterApplication address street = ”Zagorska 12/35”)])
ifTrue: [(self masterApplication applicationDownloadTime minutes)]’

EXAMPLE 2—This example sets three conditions. The master application’s address can’t be blank, the number of users of the application has to be more than three, and the number of users of the application has to be more than the number of clients.

Text:
‘if saGETeA corba client”s master application”s address is not nil
and sagetea corba server”s master application”s users is larger 3
and sagetea corba client”s master application”s users”s size is larger sagetea corba client”s master application”s clients”s size
then sagetea corba client”s master application”s print status .’

Smalltalk
‘((SAGETEACorbaClient masterApplication address != nil)
and:[((SAGETEACorbaServer masterApplication users > 3)
and:[(SAGETEACorbaClient masterApplication users size > SAGETEACorbaClient masterApplication clients size)])])
ifTrue: [(SAGETEACorbaClient masterApplication printStatus)]’ .

Previous Working with Use Cases and Requirements
Table of Contents