Re: Who's up for a little game?

new topic     » goto parent     » topic index » view thread      » older message » newer message
coconut said...

This program certainly need a function like that

include std/regex.e as re 
function ask(sequence prompt, sequence filter) 
/* 

print prompt and wait for an answer 
filter is a regular expression to filter answer 
*/ 
re:regex valid_answer=re:new(filter,CASELESS) 
sequence answer 
 
   puts(1,prompt) 
   while 1  do 
      answer=gets(0) 
      answer=answer[1..$-1]  
      if sequence(re:find(valid_answer,answer)) then 
         exit 
      else 
        puts(1,"\ninvalid answer, try again\n"&prompt) 
      end if 
   end while 
   return answer 
end function 
 

Hi

To do what?

Chris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu