Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

use global in a global ??

Quote Reply
use global in a global ??
Hallo everbody,

i want to create a Global with a big parameter and want to use it in many other globals. Is it possible and how is the syntax to call the global with the parameters
sample:
my $count = $DB->table('CatLinks','Links')->count( GT::SQL::Condition->new( statistik => '=' => '1', Status => 'IN' => ['200','201','202','203'],CategoryID => 'IN' => $id$) );
I want to fill the ['200','201','202','203'], in an global


my $count = $DB->table('CatLinks','Links')->count( GT::SQL::Condition->new( statistik => '=' => '1', Status => 'IN' => [globalname],CategoryID => 'IN' => $id$) );

Best thanks for help

Jupp
Quote Reply
Re: [jupp] use global in a global ?? In reply to
No, you can't call a global within a global, *but* you could add the values to the ConfigData.pm file, and the use that in your globals via $CFG, if you know how to edit that file. Or, you could create a function in a separate file to do what you want.

Might work, but not tried:

If you have a subroutine where the global is passed from the the template.

The globals are compiled before the template is parsed (has to be). So, a global can't know about any other globals during this initial compillation.
But, if a global tag such as BIG_NUMBER is compiled into the globals, and you want to use that inside another global, you *might* be able to do

<%other_subroutine BIG_NUMBER%>

inside your template, and in that case, since BIG_NUMBER has already been compiled, it is passed in to the compiled subroutine, and can be used like any other $tag-> value.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] use global in a global ?? In reply to
Hi pugdog,

many thanks for your help. I modify my ConfigData.pm . It runs

Cheers Jupp
Quote Reply
Re: [pugdog] use global in a global ?? In reply to
Theoritically would be possible to call another global from a global...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] use global in a global ?? In reply to
Hi,

I don't think you can call globals inside a global, without doing it like;

Code:
sub {

another_test() ? return 1 : return 0;

sub another_test {
return 1;
}

}

..but trying to do it "outside" of the current global, is another matter =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] use global in a global ?? In reply to
A global is basically a closure. You can anytime create closure in a global.
You do not need to create nested function, as you showed.

Here it is an example:
Code:
sub {
my $another_closure = sub {
return 1;
}
&$another_test() ? return 1 : return 0;
}

Quote:
..but trying to do it "outside" of the current global, is another matter =)
But originally I meant, that (theoritically, because I never tried) you can even access the $GLOBALS variable within a global, so you can call any of them as a closure.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Last edited by:

webmaster33: Jan 18, 2006, 4:16 AM
Quote Reply
Re: [webmaster33] use global in a global ?? In reply to
The code above had a bug:
Code:
sub {
my $another_closure = sub {
return 1;
}
return &$another_closure() ? 1 : 0;
}

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...