Home » Developer & Programmer » Forms » Use of global variables
Use of global variables [message #118164] Tue, 03 May 2005 07:15 Go to next message
jonmich005
Messages: 53
Registered: April 2005
Member
I have a form with 20 columns.Their rows are being count in global.activ! And the columns where are values in are count in global.intervals!

Now my question is how I can check whether a field is changed.
Here you have my code:

go_block('lds_tl_grid');
tel_interval;
tel_activity;
:global.t:=1;
while :global.t<:global.intervals loop
go_item('tl_grid_int_'||:global.t);
first_record;
:global.teller:=0;
while to_number(:global.teller) < to_number(:global.activ) loop
:global.a:='';
:global.a:= name_in('tl_grid_int_')||to_number(:global.t);
if name_in('tl_grid_int_')||to_number(:global.t) = :global.a then
commit_form;
controle;
end if;
:global.teller:=to_number(:global.teller)+1;
next_record;
end loop;
:global.t:=:global.t+1;
end loop;

The global.a is to keep the databse value of the field which is checked.

Can anyone tell me why it odesn't work?
I think I've nowhere a check if my value is equal to my global value
Re: Use of global variables [message #118257 is a reply to message #118164] Tue, 03 May 2005 20:07 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
First off, I assume that ':global.intervals' is set in 'tel_interval'. IF not, then this may be your problem.

Now, two suggestions.

1) Try using a control block (CTRL) instead of globals. The control block has no base table and the items in it have 'type' ie. number, character, date, etc. You can still use the same item names but IMHO it is 'better' than using globals.

2) EITHER create a procedure which displays each of your globals and then place a call to that procedure between EACH statment in your code OR place 'useful(?)' message between each statment so that you can see the value in your globals at each step OR run the form in 9i/10g using debug mode and look at the values in the globals panel.

David
Re: Use of global variables [message #118274 is a reply to message #118257] Wed, 04 May 2005 01:51 Go to previous messageGo to next message
jonmich005
Messages: 53
Registered: April 2005
Member
I now have used 2 global variables.
One which is always empty and one with the value of my field and then I update each field even if it isn't changed.
This takes a little more time but now I'm going to see if it works.

Could you give me a little more explanation about a control block?
Re: Use of global variables [message #118277 is a reply to message #118164] Wed, 04 May 2005 02:02 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I use the term 'control' block, but others may have a different preferred name. Basically, it is a non-database block that is used to hold fields for which you only want a single occurrence. This is equivalent to the Forms 2 and 3 page 0 items. (If you know what they are.)

Global is treated as a block - therefore - create a real block called CTRL and use it instead of GLOBAL.

David
Re: Use of global variables [message #118278 is a reply to message #118277] Wed, 04 May 2005 02:06 Go to previous messageGo to next message
jonmich005
Messages: 53
Registered: April 2005
Member
So actually this is a block where no fields are showed on your form?
Jus create a block and then but none of the fields is shown?
Re: Use of global variables [message #118286 is a reply to message #118164] Wed, 04 May 2005 02:52 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Correct

[update - actually there are many times when you WILL display the fields from one of these non-database blocks. Running totals, messages]

[Updated on: Wed, 04 May 2005 03:06]

Report message to a moderator

Re: Use of global variables [message #118287 is a reply to message #118286] Wed, 04 May 2005 02:54 Go to previous messageGo to next message
jonmich005
Messages: 53
Registered: April 2005
Member
OK then I will try that!
But if I make two globals and the first one I make empty and the second one with the value of the database after the update, isn't this correct also?
Re: Use of global variables [message #118292 is a reply to message #118164] Wed, 04 May 2005 03:04 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
There are often many ways of writing a form. It is just that some of us prefer to do things a certain way. I DON'T like using globals EXCEPT for global things. That is, something that is going to be used across multiple forms and even in that case I prefer to use variables in database packages. If I had my way there would NOT be any globals. They are a hangover from Forms 2 and 3 (I haven't worked with Forms 1) where they were the only way to pass parameters between forms, and as many applications have been converted up through the versions of Forms, but not rewritten, the parameter passing is those applications is still done via globals.

David

[Updated on: Wed, 04 May 2005 03:06]

Report message to a moderator

Re: Use of global variables [message #118293 is a reply to message #118292] Wed, 04 May 2005 03:06 Go to previous message
jonmich005
Messages: 53
Registered: April 2005
Member
Ok I will see what I use and let you know something what it will be Laughing
Previous Topic: BLOB data is not showing on Query.
Next Topic: Problem in Inserting record.
Goto Forum:
  


Current Time: Thu Sep 19 17:53:34 CDT 2024