Post Reply 
Don't execute a function if a routine is called outside the program
07-03-2015, 03:20 PM (This post was last modified: 07-03-2015 03:35 PM by salvomic.)
Post: #1
Don't execute a function if a routine is called outside the program
hi,
there is a way to don't execute a command if a function is not called inside the program, but externally (EXPORT...)?

I've a code like this one:
Code:

EXPORT ascendant(...)
BEGIN
// routine...
  ch:= MSGBOX("Another calculation?", 1);
  IF (ch<>0)  THEN changeData(); END;
END;

I would like to execute changeData(); only if ascendant() is called inside a program (to return to its menu, and so on) but not when the function is called externally (passing parameters...).

In other words: the function should ask itself: "who is calling?"...

Thank you

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-03-2015, 06:22 PM
Post: #2
RE: Don't execute a function if a routine is called outside the program
Salvo,

If I understand your question correctly, this should work:

Code:

changedata();
local a:=0;

EXPORT ascendant()
BEGIN
 local ch;
 ch:=msgbox("another calculation?",1);
 if ch<>0 and a==1 then
  changedata();
  a:=0;
 end 
END;

local changedata()
begin
 print();
 print("changedata ran");
end;

export calling_program()
begin
 a:=1;
 ascendant();
end;

When you execute ascendant from the Home screen, changedata is not executed. When calling_program executes ascendant the flag "a" is set to 1 first and changedata is executed. You can't set "a" to 1 externally if you make it local.

I don't know if the prime has user flags like the 48 thru 50g series has or not. I'm still learning HPPPL.

Cheers,

Road
Find all posts by this user
Quote this message in a reply
07-03-2015, 06:27 PM (This post was last modified: 07-03-2015 10:16 PM by salvomic.)
Post: #3
RE: Don't execute a function if a routine is called outside the program
(07-03-2015 06:22 PM)roadrunner Wrote:  Salvo,

If I understand your question correctly, this should work:

...

thanks Road, I'll try it; it seems a good workaround.
Never I know if the Prime has user flags.

I'll let you know then.

Salvo

EDIT: It worked, but I had to define a variable as global (internalfun:=0) to pass values through the routines...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: