Livecode scanf equivalent?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
mario.miele
Posts: 6
Joined: Sat Dec 26, 2015 11:20 am

Livecode scanf equivalent?

Post by mario.miele »

Hi, is there a Livecode equivalent to scanf C function? It should be the opposite of the Livecode Format function.
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Livecode scanf equivalent?

Post 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
mario.miele
Posts: 6
Joined: Sat Dec 26, 2015 11:20 am

Re: Livecode scanf equivalent?

Post 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).
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Livecode scanf equivalent?

Post by Klaus »

Aha, sorry, no idea then...
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Livecode scanf equivalent?

Post by jacque »

Maybe matchText() is what you want?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10105
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Livecode scanf equivalent?

Post 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
mario.miele
Posts: 6
Joined: Sat Dec 26, 2015 11:20 am

Re: Livecode scanf equivalent?

Post 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.
Post Reply