1. Enter procedures externally

I have another tricky problem I hope you guys can help out with.

I have a program I want the user to be able to enter procedures=
 in an EditText box, and have my program carry out the procedure=
 internally. Example:

procedure example()
openWindow(exampleWin,Modal)
end procedure

Now when the user enters example() in the EditText box, the=
 window opens. Is this possible, if so how?

Thanks in advance,
Chris

new topic     » topic index » view message » categorize

2. Re: Enter procedures externally

Sounds like creating an interpreter, but in this case you can do
something like this:

sequence s,rid
integer at
s = "example()"
at = find('(', s)
s = s[1..at-1]
rid = routine_id(s)
if rid = -1 then
    -- error
end if
call_proc(rid)

    -- Martin

----- Original Message -----
From: "Christopher B" <president at insight-concepts.com>
To: "EUforum" <EUforum at topica.com>
Sent: Saturday, May 25, 2002 11:22 AM
Subject: Enter procedures externally



I have another tricky problem I hope you guys can help out with.

I have a program I want the user to be able to enter procedures in an EditText
box, and
have my program carry out the procedure internally. Example:

procedure example()
openWindow(exampleWin,Modal)
end procedure

Now when the user enters example() in the EditText box, the window opens. Is
this
possible, if so how?

new topic     » goto parent     » topic index » view message » categorize

3. Re: Enter procedures externally

Give your user a chance to select from a row of numbered items,=
 take the number, and then in an if elsif etc row test it for the=
 routine to be performed

EUrs antione

new topic     » goto parent     » topic index » view message » categorize

4. Re: Enter procedures externally

Dobar den, Martino( I don't remeber the correct declination).

I guess your method has to fail if
 1)  Win32lib was included after the location of this function
 2)  The interpreter will not know which functions to include
     and might throwout some of those, user might want to enter.
Remember the new way include-files are handled?

EUrs antoine tammer

new topic     » goto parent     » topic index » view message » categorize

5. Re: Enter procedures externally

Goede dag, Antoine,
> Dobar den, Martino( I don't remeber the correct declination).
Dobry den, Martine, but sure better then my Dutch smile

> I guess your method has to fail if
> 1)  Win32lib was included after the location of this function
> 2)  The interpreter will not know which functions to include
>     and might throwout some of those, user might want to enter.
> Remember the new way include-files are handled?

Not sure whether I got your point, just what refman says:

The routine named by st must be visible, i.e. callable, at
the place where routine_id() is used to get the id number.
Indirect calls to the routine can appear earlier in the program
than the definition of the routine, but the id number can only
be obtained in code that comes after the definition of the routine.

I don't see why it should fail. But method like this:

s = parse(s)
if equal(s, "example") then
    example()
elsif ...

would be better for security reasons. But the "Execution of strings"
theme has been discussed many times on the list.

    Martin

new topic     » goto parent     » topic index » view message » categorize

6. Re: Enter procedures externally

It's only 1 word in Dutch, Martine and it has an 'n' in it.

I'm rusty on Slavic languages now, it's 6 years I didn't visit=
 Czechia, and I tend to mix up Czech, Slowak and Polish, sorry=
 for that.

Goedendag would be correct, with capital G or undercast g. I'm=
 sorry to have to point out that you didn't evaluate the second=
 reason, you ought to know that the new interpretertrows out=
 every function, variable or constant it doesnot find as being=
 used in the files you present it.
THIS WILL ONLY INCLUDE NAMED FUNCTIONS, not functions entered=
 that will be input from a dedicated functionlike the one we are=
 talking about, BECAUSE the interpreter has no way of knowing=
 what user is going to enter in the <call-determining>=
 function!!

Antoine

new topic     » goto parent     » topic index » view message » categorize

7. Re: Enter procedures externally

Ahoy Martine,

About establihing routine_id, I agree with your remarks, BUT that=
 would require the guy who put the question,(sorry X, I cleared=
 my cluttered mailbox)
to establish routine_ids for all functions he"d like his user to=
 be able to call. In such case my proposed solution will be=
 faster,I guess, although he would
still have to establish routine_ids 

Antoine

new topic     » goto parent     » topic index » view message » categorize

8. Re: Enter procedures externally

This is a multi-part message in MIME format.

------=_NextPart_000_0026_01C204BA.0B915FE0
	charset="iso-8859-1"

Antoine wrote:
> It's only 1 word in Dutch, Martine and it has an 'n' in it.

Ok, I'm just aimed with poor knowledge of German :)

> I'm rusty on Slavic languages now, it's 6 years I didn't visit Czechia,
> and I tend to mix up Czech, Slowak and Polish, sorry for that.

That's ok, I know it must be difficult to remeber all the declinations...
May I know what were you doing here?

> Goedendag would be correct, with capital G or undercast g. I'm sorry to have
> to point
out that
> you didn't evaluate the second reason, you ought to know that the new
> interpretertrows
out every > function, variable or constant it doesnot find as being used in the
files you
present it.

The interpreter doesn't throw away any functions, only the new 2-pass binder.
When it encounters something like routine_id(var) than it removes no
routine. I've just tried it with attached code.

> THIS WILL ONLY INCLUDE NAMED FUNCTIONS, not functions entered that will be
> input from a
dedicated
> functionlike the one we are talking about, BECAUSE the interpreter has no way
> of knowing
what
> user is going to enter in the <call-determining> function!!

If you mean that user supplies a function code at runtime, then yes, this would
require
an Eu-inside-Eu interpreter (I think there's a one in archives)

    Martin



------=_NextPart_000_0026_01C204BA.0B915FE0
Content-Type: application/octet-stream;
	name="test.ex"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="test.ex"

include get.e

procedure test1()
?1
end procedure

procedure test2()
?2
end procedure

sequence s
integer rid
while 1 do
	s= prompt_string(">")
	rid=routine_id(s)
	if rid=-1 then exit end if
	call_proc(rid, {})
end while
------=_NextPart_000_0026_01C204BA.0B915FE0--

new topic     » goto parent     » topic index » view message » categorize

9. Re: Enter procedures externally

Thank you for your help Martin.

Best regards,
Chris




On Sun, 26 May 2002 13:34:22 +0200, Martin Stachon wrote:
>
>Antoine wrote:
>>=A0It's only 1 word in Dutch, Martine and it has an 'n' in it.
>
>Ok, I'm just aimed with poor knowledge of German :)
>
>>=A0I'm rusty on Slavic languages now, it's 6 years I didn't=
 visit
>>Czechia,
>>=A0and I tend to mix up Czech, Slowak and Polish, sorry for=
 that.
>
>That's ok, I know it must be difficult to remeber all the
>declinations...
>May I know what were you doing here?
>
>>=A0Goedendag would be correct, with capital G or undercast g.=
 I'm
>>sorry to have to point
>out that
>>=A0you didn't evaluate the second reason, you ought to know that=
 the
>>new interpretertrows
>out every >=A0function, variable or constant it doesnot find as=
 being
>used in the files you
>present it.
>
>The interpreter doesn't throw away any functions, only the new=
 2-
>pass binder.
>When it encounters something like routine_id(var) than it=
 removes no
>routine. I've just tried it with attached code.
>
>>=A0THIS WILL ONLY INCLUDE NAMED FUNCTIONS, not functions entered=
 that
>>will be input from a
>dedicated
>>=A0functionlike the one we are talking about, BECAUSE the=
 interpreter
>>has no way of knowing
>what
>>=A0user is going to enter in the <call-determining>=A0function!!
>
>If you mean that user supplies a function code at runtime, then=
 yes,
>this would require
>an Eu-inside-Eu interpreter (I think there's a one in archives)
>
>=A0=A0Martin
>
>
>
>


--

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu