Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #2557 > unrolled thread
| Started by | Peter Billam <peter@www.pjb.com.au> |
|---|---|
| First post | 2016-05-01 11:39 +0000 |
| Last post | 2016-05-02 05:48 +0000 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.postscript
How to test if a procedure is defined ? Peter Billam <peter@www.pjb.com.au> - 2016-05-01 11:39 +0000
Re: How to test if a procedure is defined ? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2016-05-01 08:04 -0600
Re: How to test if a procedure is defined ? Peter Billam <peter@www.pjb.com.au> - 2016-05-02 01:06 +0000
Re: How to test if a procedure is defined ? luser- -droog <mijoryx@yahoo.com> - 2016-05-01 19:45 -0700
Re: How to test if a procedure is defined ? Peter Billam <peter@www.pjb.com.au> - 2016-05-02 05:48 +0000
| From | Peter Billam <peter@www.pjb.com.au> |
|---|---|
| Date | 2016-05-01 11:39 +0000 |
| Subject | How to test if a procedure is defined ? |
| Message-ID | <slrnnibqmm.54q.peter@box8.pjb.com.au> |
Greetings. I'm wanting to put together something like perl or lua 'require', by testing if some procedure is defined, and if not then run-ning the PS 'library' file that will define it. But I don't see how to test if a procedure is defined. Anything like gloop type or gloop gcheck just crashes if gloop is undefined, before type or gcheck get executed. /gloop type just reports nametype, even if gloop doesn't exist. Is there eg: a way to invoke gloop within a crash-free sandbox, eg like pcall in lua ? Any other way to test if it's defined ? Thanks, regards, Peter -- Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html
[toc] | [next] | [standalone]
| From | Martin Leese <please@see.Web.for.e-mail.INVALID> |
|---|---|
| Date | 2016-05-01 08:04 -0600 |
| Message-ID | <ng5271$ufi$1@dont-email.me> |
| In reply to | #2557 |
Peter Billam wrote:
> Greetings. I'm wanting to put together something like perl or lua
> 'require', by testing if some procedure is defined, and if not
> then run-ning the PS 'library' file that will define it.
> But I don't see how to test if a procedure is defined. Anything like
> gloop type or gloop gcheck
> just crashes if gloop is undefined, before type or gcheck get executed.
> /gloop type
> just reports nametype, even if gloop doesn't exist.
> Is there eg: a way to invoke gloop within a crash-free sandbox,
> eg like pcall in lua ? Any other way to test if it's defined ?
Try:
yourdict /gloop known
or, if the appropriate dictionary is on the dictionary stack:
/gloop where
--
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
[toc] | [prev] | [next] | [standalone]
| From | Peter Billam <peter@www.pjb.com.au> |
|---|---|
| Date | 2016-05-02 01:06 +0000 |
| Message-ID | <slrnnida14.1og.peter@box8.pjb.com.au> |
| In reply to | #2558 |
On 2016-05-01, Martin Leese <please@see.Web.for.e-mail.INVALID> wrote:
> Peter Billam wrote:
>> I'm wanting to put together something like perl or lua
>> 'require', by testing if some procedure is defined, and if
>> not then run-ning the PS 'library' file that will define it.
> Try:
> yourdict /gloop known
> or, if the appropriate dictionary is on the dictionary stack:
> /gloop where
Yes :-) where is what I needed (never used it before). Concretely:
/randomrgb where not { (/home/pjb/ps/lib/colours.ps) run } if
Thanks,
Peter
--
Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html
[toc] | [prev] | [next] | [standalone]
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2016-05-01 19:45 -0700 |
| Message-ID | <79ad39d3-c85b-45ad-a352-ec1828161d9b@googlegroups.com> |
| In reply to | #2559 |
On Sunday, May 1, 2016 at 8:07:57 PM UTC-5, Peter Billam wrote:
> On 2016-05-01, Martin Leese <please@see.Web.for.e-mail.INVALID> wrote:
> > Peter Billam wrote:
> >> I'm wanting to put together something like perl or lua
> >> 'require', by testing if some procedure is defined, and if
> >> not then run-ning the PS 'library' file that will define it.
> > Try:
> > yourdict /gloop known
> > or, if the appropriate dictionary is on the dictionary stack:
> > /gloop where
>
> Yes :-) where is what I needed (never used it before). Concretely:
>
> /randomrgb where not { (/home/pjb/ps/lib/colours.ps) run } if
>
`where` return the dict in the true case, so you probably want
something more like
/randomrgb where { pop }{ (/home/pjb/ps/lib/colours.ps) run } ifelse
[toc] | [prev] | [next] | [standalone]
| From | Peter Billam <peter@www.pjb.com.au> |
|---|---|
| Date | 2016-05-02 05:48 +0000 |
| Message-ID | <slrnnidqhp.2s3.peter@box8.pjb.com.au> |
| In reply to | #2560 |
On 2016-05-02, luser- -droog <mijoryx@yahoo.com> wrote:
>> > Peter Billam wrote:
>> /randomrgb where not { (/home/pjb/ps/lib/colours.ps) run } if
>
> `where` returns the dict in the true case,
Ah... indeed.
> so you probably want something more like
> /randomrgb where { pop }{ (/home/pjb/ps/lib/colours.ps) run } ifelse
Thanks :-)
Peter
--
Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web