• Support
  • Articles
  • Resources
  • Products

Waiting for character loop

Moderator: boris

5 postsPage 1 of 1

Saud
Beginner

Posts:
26
Joined: Sun Jun 01, 2008 9:14 am
by Saud » Thu Sep 08, 2016 7:14 am
Hi,
I use wait command to wait for character form host and then take action.
This works fine if I use it for one condition in the loop, but if I want multiple condition problem start because it will keep just waiting for the first character and not move to next until this is fulfilled,
Do we have some sort of receiving character register so that I can just use IF command and then loop through all the conditions at the same time.
Example the current code with problem:

Code: Select all

  1. while 1
  2. wait 'A'
  3. dispstr  ' text some'
  4. wait 'B'
  5. dispstr  'Some text'
  6. wait 'c'
  7. dispstr  'Some text'
  8. endwhile


Please help.
Thanks
Saud
Trevor
Guru

Posts:
467
Joined: Wed Jul 26, 2006 8:47 am
by Trevor » Sat Sep 10, 2016 8:49 pm
You can wait for multiple strings with wait command. E.g.

Code: Select all

  1. wait 'A' 'B' 'C'
  2. if result == 1 then
  3.     dispstr  ' text for A'
  4. elseif result == 2 then
  5.     dispstr  ' text for B'
  6. elseif  result == 3 then
  7.     dispstr  ' text for C'
  8. else
  9.     ; deal with timeout
  10. endif
  11.  
Saud
Beginner

Posts:
26
Joined: Sun Jun 01, 2008 9:14 am
by Saud » Thu Sep 22, 2016 6:54 am
Trevor,

Can I do OR like below example whay doesn’t works.

wait 'A' 'B' 'C'

if result == 1|2|3 then

dispstr ' text for A'


Thanks
boris
Moderator, LogMeTT and TTLEditor developer

Posts:
1590
Joined: Sat Jan 08, 2005 2:52 pm
by boris » Thu Sep 22, 2016 4:26 pm
You can achieve your goal by replacing wait with waitregex. If you are not familiar with regular expressions, use this free tool to build them http://www.ultrapico.com/expressodownload.htm
Thanks.
Best regards,
Boris
Trevor
Guru

Posts:
467
Joined: Wed Jul 26, 2006 8:47 am
by Trevor » Fri Sep 23, 2016 10:48 am

Code: Select all

  1. wait 'A' 'B' 'C' 'D' 'E'
  2. if (result == 1) || (result == 2) || (result == 3)  then
  3.     dispstr ' text for A, B or C'
  4. endif


or

Code: Select all

  1. wait 'A' 'B' 'C' 'D' 'E'
  2. if (result >= 1) && (result <= 3) then
  3.     dispstr ' text for A, B or C'
  4. endif
  5.  
Display posts from previous:
Sort by:

5 postsPage 1 of 1

Users browsing this forum: No registered users