Ahmad Siavosh
Ahmad Siavosh

Reputation: 676

A Maple equivalent for Matlab's input function

I'm new to Maple, and I do really need the Matlab's input() function there. I searched a lot but there was no easy way or at least a straightforward way like Matlab to get inputs. Actually what I need is a way to get function definitions from user in Maple. I'd be happy if somebody helps :)

E.g.(Matlab code)

f = input("Enter your function : ");

Output :

Enter your function : x^2 + y^2 + log(10) + 2*exp(z)

What I'm asking is how can I implement something like this Matlab code in Maple ?

Upvotes: 2

Views: 432

Answers (1)

acer
acer

Reputation: 7271

How about using the readstat command? Eg,

restart:

f := readstat("Enter your function:");

A more sophisticated popup could be devised from Maplets code. As a simple example with Maplets,

restart:

maplet:=Maplets:-Elements:-Maplet(
      Maplets:-Elements:-InputDialog["ID1"](
         "Enter your function:",
         ':-onapprove'=Maplets:-Elements:-Shutdown(["ID1"]),
         ':-oncancel'=Maplets:-Elements:-Shutdown())):

f:=parse(Maplets:-Display(maplet)[]);

You didn't say how your end-user was otherwise going to interact with the session. Will the user run the whole worksheet? Have you considered making an entire interactive assembly with Embedded Components?

Upvotes: 2

Related Questions