Page 1 of 1

Livecode scanf equivalent?

Posted: Sat Aug 22, 2020 12:00 pm
by mario.miele
Hi, is there a Livecode equivalent to scanf C function? It should be the opposite of the Livecode Format function.

Re: Livecode scanf equivalent?

Posted: Sat Aug 22, 2020 12:33 pm
by Klaus
Hi Mario,

not sure, maybe the ASK dialog?

Code: Select all

...
ask "Please enter your name:"
put it into tUserAnswer
## user clicked CANCEL:
if tUserAnswer = EMPTY then
## or:
## if the RESULT = "cancel" then
   exit to top
end if
answer "Your name is:" && tUserAnswer
...
Best

Klaus

Re: Livecode scanf equivalent?

Posted: Sat Aug 22, 2020 2:31 pm
by mario.miele
No, the scanf equivalent shoud fill a number of variables taking the values from partes of a string according to a template (look at the "format" Livecode function to have an idea, it makes to opposite).

Re: Livecode scanf equivalent?

Posted: Sat Aug 22, 2020 2:44 pm
by Klaus
Aha, sorry, no idea then...

Re: Livecode scanf equivalent?

Posted: Sat Aug 22, 2020 4:58 pm
by jacque
Maybe matchText() is what you want?

Re: Livecode scanf equivalent?

Posted: Sat Aug 22, 2020 6:09 pm
by FourthWorld
For anyone with time in their hands, this includes a list of scanf options:
https://en.m.wikipedia.org/wiki/Scanf_format_string

Probably most efficient to write an external for this, using any of the common C libs.

Re: Livecode scanf equivalent?

Posted: Mon Aug 31, 2020 9:21 am
by mario.miele
Effectively matchtext() seems to be the closer function to scanf at least for what concern the result, even if it uses regex.