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: FourthWorld, heatherlaine, Klaus, kevinmiller

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

Livecode scanf equivalent?

Post by mario.miele » Sat Aug 22, 2020 12:00 pm

Hi, is there a Livecode equivalent to scanf C function? It should be the opposite of the Livecode Format function.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Livecode scanf equivalent?

Post by Klaus » Sat Aug 22, 2020 12:33 pm

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 » Sat Aug 22, 2020 2:31 pm

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: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Livecode scanf equivalent?

Post by Klaus » Sat Aug 22, 2020 2:44 pm

Aha, sorry, no idea then...

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Livecode scanf equivalent?

Post by jacque » Sat Aug 22, 2020 4:58 pm

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: 10049
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Livecode scanf equivalent?

Post by FourthWorld » Sat Aug 22, 2020 6:09 pm

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 » Mon Aug 31, 2020 9:21 am

Effectively matchtext() seems to be the closer function to scanf at least for what concern the result, even if it uses regex.

Post Reply