From: razordev on
Hi All,

I want to define a path name eg:

path "/home/name/webs/photos"

in a package and use this throughout my application.

Not sure exactly how to do this?

Grateful for any assistance.

Best,














From: Gerald W. Lester on
razordev wrote:
> Hi All,
>
> I want to define a path name eg:
>
> path "/home/name/webs/photos"
>
> in a package and use this throughout my application.
>
> Not sure exactly how to do this?
>
> Grateful for any assistance.

Setting it:
set path "/home/name/webs/photos"
or
set :;path "/home/name/webs/photos"

Using it:
set photo [file join $path me.jpg]
or
set photo [file join $::path me.jpg]


Now the big question, why were you unsure? What lead you to be unsure to
begin with?


--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald.Lester(a)kng-consulting.net |
+------------------------------------------------------------------------+
From: Keith on



On 6/25/10 11:12 PM, in article
vTgVn.344590$9e5.35447(a)news.usenetserver.com, "Gerald W. Lester"
<Gerald.Lester(a)KnG-Consulting.net> wrote:

> razordev wrote:
>> Hi All,
>>
>> I want to define a path name eg:
>>
>> path "/home/name/webs/photos"
>>
>> in a package and use this throughout my application.
>>
>> Not sure exactly how to do this?
>>
>> Grateful for any assistance.
>
> Setting it:
> set path "/home/name/webs/photos"
> or
> set :;path "/home/name/webs/photos"
>
> Using it:
> set photo [file join $path me.jpg]
> or
> set photo [file join $::path me.jpg]
>
>
> Now the big question, why were you unsure? What lead you to be unsure to
> begin with?
>

If you are using it in different procedures then you need to declare.
If you are using namespace

proc ::foofoo {a } {
variable path
set photo [file join $path me.jpg]
}

In a regular procedure use global
proc foofoo {a } {
global path
set photo [file join $path me.jpg]
}


--�
Best Regards,�Keith
http://home.comcast.net/~kilowattradio/






From: Gerald W. Lester on
Keith wrote:
>
>
> On 6/25/10 11:12 PM, in article
> vTgVn.344590$9e5.35447(a)news.usenetserver.com, "Gerald W. Lester"
> <Gerald.Lester(a)KnG-Consulting.net> wrote:
>
>> razordev wrote:
>>> Hi All,
>>>
>>> I want to define a path name eg:
>>>
>>> path "/home/name/webs/photos"
>>>
>>> in a package and use this throughout my application.
>>>
>>> Not sure exactly how to do this?
>>>
>>> Grateful for any assistance.
>> Setting it:
>> set path "/home/name/webs/photos"
>> or
>> set :;path "/home/name/webs/photos"
>>
>> Using it:
>> set photo [file join $path me.jpg]
>> or
>> set photo [file join $::path me.jpg]
>>
>>
>> Now the big question, why were you unsure? What lead you to be unsure to
>> begin with?
>>
>
> If you are using it in different procedures then you need to declare.
> If you are using namespace


Sorry, wrong, the second method I gave will work with no "declares"
(variable, global and upvar are not a declaration of a variable but rather
makes a link in the local context frame to another context). Also the
information I gave was for the question the OP asked. To generalize, you
can *always* use the fully qualified name of a global variable that resides
in any namespace to access it from any other context.

> proc ::foofoo {a } {
> variable path
> set photo [file join $path me.jpg]
> }

Since the procedure is at the global namespace this is the same as the
procedure below...

> In a regular procedure use global
> proc foofoo {a } {
> global path
> set photo [file join $path me.jpg]
> }

which is the same as:

proc foofoo {a} {
set photo [file join $::path me.jpg]
}





--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald.Lester(a)kng-consulting.net |
+------------------------------------------------------------------------+
From: John Seal on
"Gerald W. Lester" <Gerald.Lester(a)KnG-Consulting.net> wrote in message
news:vTgVn.344590$9e5.35447(a)news.usenetserver.com...
> set :;path "/home/name/webs/photos"

Typo alert! That should be ::path (two colons) not :;path (colon and
semicolon).