Tyl Programming Language
▶ CONDITIONAL STATEMENT - PART 4
Compare Condition
Compare condition statement is any statement that compares two scalar variables:
counter > 0
Compare options: Some compare conditions:
counter > 0 ?
quantity >= 0 ?
letter 'A' ?
The equality symbol: '=', should not be used for assignments or comparisons.
In Tyl, the line: letter 'A', is an equality check between letter variable, and the string: 'A'.

Say we have a string variable: 'user_name', and we want to check if user_name has at least 3 characters:
user_name 'tintin86'
user_name_len len user_name

user_name_len >= 3 ? print 'User name is valid'
User name is valid
Disable user_name with value: 'aaa':
user_name 'aaa'

user_name 'aaa' ? print 'Invalid user name: `aaa`! Please select another name.'
Invalid user name: 'aaa'! Please select another name
In line: user_name 'aaa', user_name is compared to value: 'aaa'. If it is equal to: 'aaa', then the yes statement is executed, and the system prints: 'Invalid user name: 'aaa'! Please select another name.'.

It is posible to save the value: 'aaa', in a variable, and to compare user_name to it:
user_name 'aaa'
invalid_user_name 'aaa'

user_name invalid_user_name ? print 'Invalid user name: `aaa`! Please select another name.'
Here's Password Validator program:
err_msgs 'The password field is empty!' 'Password must be at least 8 characters!'

main »
 password 'r9-Jo;3='
 err_msg_ind validate password

 err_msg_ind >= 0 ?
  print err_msgs err_msg_ind
  
  print 'Password OK. Continue with login...'


validate pwd »
 pwd_len len pwd

 pwd_len ?
  pwd_len < 8 ? 1 -1
  
  0

Password OK. Continue with login...


PART 3