Home » Developer & Programmer » Forms » check global variable (forms 6i)
check global variable [message #442614] Tue, 09 February 2010 07:34 Go to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

can we check global variable's value is create or not and if created then how can i get it value...


Re: check global variable [message #442615 is a reply to message #442614] Tue, 09 February 2010 07:43 Go to previous messageGo to next message
cookiemonster
Messages: 10852
Registered: September 2008
Location: Rainy Manchester
Senior Member
Why don't you just read what form builder help has to say about global variables? It does tell you this stuff.
Re: check global variable [message #442676 is a reply to message #442615] Tue, 09 February 2010 23:03 Go to previous messageGo to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

i see in builder help. i don't find that how can i get the value of global variable or check that the global variable exists or not...
Re: check global variable [message #442678 is a reply to message #442676] Tue, 09 February 2010 23:11 Go to previous messageGo to next message
tamzidulamin
Messages: 131
Registered: October 2009
Location: Dhaka
Senior Member

You can check the value of GLOBAL variable by the following way.

 If :global.variable_name is not null then
     If :global.variable_name = '' then --Your desired value.
        Your required action here....
     End If;   
 End If;


Regards

Tamzidul Amin
Re: check global variable [message #442682 is a reply to message #442678] Tue, 09 February 2010 23:27 Go to previous messageGo to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

I use this code but now this time my requirement is this that ...

i made a project and i have many forms...

i want that when any body log-in by using log-in form then his session created and i pass this user name to every form by using global variable.. but now my task is this that when any body what to open any other form in the project folder... then forms raise this error...

FRM-40815: Variable GLOBAL.%s does not exist.

i want that when any body open any form in the project folder then forms check that if global variable created or exists then its open else its close the form.

i check this global variable in PRE-FORM...

but when i open any form without using log-in form then it raise error...

FRM-40815: Variable GLOBAL.%s does not exist.

i want that it can not raise error... if GLOBAL variable exists then its open else its close without any error...

Re: check global variable [message #442683 is a reply to message #442682] Tue, 09 February 2010 23:33 Go to previous messageGo to next message
tamzidulamin
Messages: 131
Registered: October 2009
Location: Dhaka
Senior Member
Dear,

Your must have declare all GLOBAL varibales in NEW-FORM-INSTANCE
in to your LOGIN form.Otherwise when u assign some value into your Global variable the form raise
Quote:
FRM-40815: Variable GLOBAL.%s does not exist.
.

Regards,

Tamzidul Amin.
Re: check global variable [message #442685 is a reply to message #442683] Wed, 10 February 2010 00:00 Go to previous messageGo to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

thanks your reply sir...

I Write this code in PRE-FORMS

IF :GLOBAL.USER_NAME IS NULL  THEN 
  :PARAMETER.USER_RIGHTS := 'N';
ELSE
   CHK_RIGHT('OPEN_FRM'); --this is procedure check user rights
     IF :PARAMETER.USER_RIGHTS='N' THEN 
        SET_ALERT_PROPERTY('COMMON_ALRT', ALERT_MESSAGE_TEXT, 'You have no Rights to Open this Form...!');
	ALRT := SHOW_ALERT('COMMON_ALRT');
     ELSE 
       --MDI_ICO := WIN_API_UTILITY.GET_ACTIVE_WINDOW;
       --WIN_API_SESSION.CHANGE_MDI_ICON(MDI_ICO, '.\Icons\awc3.ico', 0);
       SET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,WINDOW_STATE,MAXIMIZE);
	SET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,TITLE,PRG_TITLE);
	SET_WINDOW_PROPERTY('WINDOW1',TITLE,:PARAMETER.FRM_NAME);
	A_CNTR_FRM('WINDOW1');
     END IF;

END IF;


and write in when_new_form_instance this code...

IF :PARAMETER.USER_RIGHTS = 'N' THEN 
   EXIT_FORM(NO_VALIDATE);
end if;


if i use this above code then, when any body want to open any form without log-in form then just raise this error and close the forms...

FRM-40815: Variable GLOBAL.%s does not exist.



Your must have declare all GLOBAL varibales in NEW-FORM-INSTANCE
in to your LOGIN form.Otherwise when u assign some value into your Global variable the form raise


I Think you say that i write code like this...


PRE-FORM TRIGGER
   CHK_RIGHT('OPEN_FRM'); --this is procedure check user rights
     IF :PARAMETER.USER_RIGHTS='N' THEN 
        SET_ALERT_PROPERTY('COMMON_ALRT', ALERT_MESSAGE_TEXT, 'You have no Rights to Open this Form...!');
	ALRT := SHOW_ALERT('COMMON_ALRT');
     ELSE 
       --MDI_ICO := WIN_API_UTILITY.GET_ACTIVE_WINDOW;
       --WIN_API_SESSION.CHANGE_MDI_ICON(MDI_ICO, '.\Icons\awc3.ico', 0);
       SET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,WINDOW_STATE,MAXIMIZE);
	SET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,TITLE,PRG_TITLE);
	SET_WINDOW_PROPERTY('WINDOW1',TITLE,:PARAMETER.FRM_NAME);
	A_CNTR_FRM('WINDOW1');
  

when_new_form_instance 
[code]
IF :GLOBAL.USER_NAME = IS NULL THEN 
   EXIT_FORM(NO_VALIDATE);
end if;
[/code]




if i use global variable in when_new_form_instance

than first form open and then again this error comes...

FRM-40815: Variable GLOBAL.%s does not exist.


i hope you understand my problem...
Re: check global variable [message #442696 is a reply to message #442676] Wed, 10 February 2010 00:23 Go to previous messageGo to next message
Littlefoot
Messages: 19326
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
allianz2010 wrote on Wed, 10 February 2010 06:03
i see in builder help. i don't find that how can i get the value of global variable or check that the global variable exists or not...

How come you didn't see the DEFAULT_VALUE built-in, then?
Re: check global variable [message #442708 is a reply to message #442696] Wed, 10 February 2010 01:36 Go to previous messageGo to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

i see in form builder before my posts...
BEGIN 
  /* 
  ** Default the value of GLOBAL.Command_Indicator if it is 
  ** NULL or does not exist. 
  */ 
  Default_Value('***','global.command_indicator'); 
  /* 
  ** If the global variable equals the string we defaulted 
  ** it to above, then it must have not existed before 
  */ 
  IF :Global.Command_Indicator = '***' THEN 
    Message('You must call this screen from the Main Menu'); 
    RAISE Form_Trigger_Failure; 
  END IF; 
END; 



i write this code for get/check the value ... by using ... this code...

DEFAULT_VALUE('***','GLOBAL.USER_NAEM'); 

but its also raise error...

FRM-40815: Variable GLOBAL.%s does not exist.
Re: check global variable [message #442716 is a reply to message #442708] Wed, 10 February 2010 02:43 Go to previous messageGo to next message
Littlefoot
Messages: 19326
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
It means that, at the moment of global variable fetch, it doesn't exist. Where did you put DEFAULT_VALUE, and what raises the error (which trigger)?

Make sure that it is first declared, and then use it.
Re: check global variable [message #442839 is a reply to message #442716] Wed, 10 February 2010 23:20 Go to previous messageGo to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

sir thanks for your reply...

i have a suggestion for you... and many people whose post just like you...

when any body come on any forum for solution of our problem...
then you people just tell him... no body knows about his knowledge ...

if you can give the answers then give him the answer with some/any example ....

you have a many knowledge against that person....

i post in this blog but i can't find any answer completed... which i think that now its complete...

so please sir if you think that you can give the answer...
then please give him the complete the answer.... with example...
Re: check global variable [message #442864 is a reply to message #442839] Thu, 11 February 2010 00:53 Go to previous messageGo to next message
Littlefoot
Messages: 19326
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'm afraid that I was misunderstood.

Obviously, you did find documentation about DEFAULT_VALUE; that's fine.

Then you posted this:
DEFAULT_VALUE('***','GLOBAL.USER_NAEM'); 
and said that you still got the error.

Then I asked WHERE DID YOU PUT IT and what raises the error, and - instead of a reply as "into the WHEN-NEW-FORM-INSTANCE trigger, while WHEN-VALIDATE-ITEM raises an error" or wherever / whatever it is, there's a suggestion for me.

OK, fine, thank you, but - you still have a problem, and all I can tell (as you don't answer questions) is to repeat: you first have to declare a variable, then use it.
Re: check global variable [message #442865 is a reply to message #442864] Thu, 11 February 2010 01:12 Go to previous messageGo to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

Thanks for your reply.. sir....

i mention my problem with detail in my previous reply.. in this post...

my actual problem is this that
i create a global variable in log-in form...
and i get this global variable on other forms. successfully..
but when i open any other form in my project folder without using log-in form....

now its mean no any global variable is created....
now it raise the error...
Quote:

FRM-40815: Variable GLOBAL.%s does not exist.


now my requirement is this that if any person want to try open form in project folder then if global variable is not created then forms closed without any error or message....

and i use this line in my code.. for check that any global variable is created or not...
Quote:

DEFAULT_VALUE('***','GLOBAL.USER_NAEM');


than now its also raise the error...
Quote:

FRM-40815: Variable GLOBAL.%s does not exist.


sorry for my previous reply my behavior not right...
actually i try to do this for previous 3 or 4 days...
and my work not complete however my boss give me 4 another assignment...

again sorry...
Re: check global variable [message #442881 is a reply to message #442865] Thu, 11 February 2010 02:22 Go to previous messageGo to next message
Littlefoot
Messages: 19326
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
allianz2010 wrote on Thu, 11 February 2010 08:12

and i use this line in my code.. for check that any global variable is created or not...
Quote:

DEFAULT_VALUE('***','GLOBAL.USER_NAEM');


than now its also raise the error...
Quote:

FRM-40815: Variable GLOBAL.%s does not exist.


Could you, please, answer two questions?
1) where did you put DEFAULT_VALUE, into which trigger? (trigger_1)
2) which trigger raises FRM-40815? (trigger_2)


Trigger that raises FRM-40815 (trigger_2) must fire after trigger that declares a global variable (trigger_1).
Re: check global variable [message #442993 is a reply to message #442881] Thu, 11 February 2010 22:16 Go to previous messageGo to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

Quote:

Could you, please, answer two questions?
1) where did you put DEFAULT_VALUE, into which trigger? (trigger_1)
2) which trigger raises FRM-40815? (trigger_2)

1st question's Answers...

i use these lines in PRE-FORM trigger...
DEFAULT_VALUE('***','GLOBAL.USER_NAEM');

IF :GLOBAL.USER_NAME = '***' THEN
:PARAMETER.USER_RIGHTS='N'
END IF;

2nd question's Answers is:
PRE-FORMS raise the error....
Re: check global variable [message #443003 is a reply to message #442993] Fri, 12 February 2010 00:12 Go to previous messageGo to next message
Littlefoot
Messages: 19326
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Poor you (what else to say ...).

This is your code, which doesn't work (formatted, so that you'd see the difference, if you look closely):
DEFAULT_VALUE('***', 'GLOBAL.USER_NAEM');

IF :GLOBAL.USER_NAME = '***' THEN
   :PARAMETER.USER_RIGHTS = 'N' 
END IF;


This is my code, which does work:
DEFAULT_VALUE('***','GLOBAL.USER_NAME');

IF :GLOBAL.USER_NAME = '***' THEN
   :PARAMETER.USER_RIGHTS := 'N';
END IF;

How many differences do you see?

Your turn.
Re: check global variable [message #443007 is a reply to message #443003] Fri, 12 February 2010 00:42 Go to previous messageGo to next message
allianz2010
Messages: 101
Registered: October 2009
Location: Pakistan
Senior Member

Thanks for your reply..
sorry for my English...
sir which mistake you get...

i know about that..

Quote:

DEFAULT_VALUE('***','GLOBAL.USER_NAME');

IF :GLOBAL.USER_NAME = '***' THEN
:PARAMETER.USER_RIGHTS := 'N';
END IF;


i write this code here directly...

because i delete these lines when its not worked...

but now i get the value of my global variable... and do my work properly....

i write these lines in PRE-FORM TRIGGER...
DEFAULT_VALUE('***','GLOBAL.USER_NAME');
IF :GLOBAL.USER_NAME = '***' THEN
   :PARAMETER.USER_RIGHTS := 'N';
END IF;


AND " EXIT_FORM(NO_VALIDATE); " does not worked in PRE-FORM Trigger.. then i create a parameter. and update its value in PRE-FORM TRIGGER and check its value in WHEN-NEW-FORM-INSTANCE TRIGGER..
like this...
IF :PARAMETER.USER_RIGHTS='N' THEN 
	EXIT_FORM(NO_VALIDATE);
end if;


i don't know that how it be done....
but now it be done...

and sir which mistake you get if i write these lines in forms developer and compile it then it gives the error....

thanks for your cooperation...

now my form close without any error....
Re: check global variable [message #443009 is a reply to message #443007] Fri, 12 February 2010 00:50 Go to previous messageGo to next message
Littlefoot
Messages: 19326
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I didn't quite get it: did you solve the problem or not?

As of EXIT_FORM not working in PRE-FORM trigger: why wouldn't you put the whole code into the WHEN-NEW-FORM-INSTANCE trigger, so that you wouldn't need to user a parameter?
-- WHEN-NEW-FORM-INSTANCE

DEFAULT_VALUE('***', 'GLOBAL.USER_NAME');
IF :GLOBAL.USER_NAME = '***' THEN
   EXIT_FORM (NO_VALIDATE);
END IF;
Re: check global variable [message #443210 is a reply to message #443009] Sat, 13 February 2010 12:35 Go to previous message
Littlefoot
Messages: 19326
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
LF: This is the first part of @allianz2010's last message; the original message has been split from this topic as it addresses a completely different problem (icons in Forms).

allianz2010

Thanks for your reply... and sorry for my late reply...
because yesterday i leave the office....

my problem is now solved....
Previous Topic: Menu Tree
Next Topic: How to change the forms trigger sequence
Goto Forum:
  


Current Time: Tue Jul 29 09:11:05 CDT 2014

Total time taken to generate the page: 0.22620 seconds