COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### How to insert some commands before an existing environment?

• Email
• Follow

For example, I want to insert some commands such as
\centering
and some other commands come from ccaption package before the other
commands in the figure environment,
and no need to use a new environment name.

How to implement this effect?
I've tried the following codes, but it didn't work.

\def\tempfigure\figure
\renewcommand\figure
{\tempfigure
\hangcaption
\captiontitlefont{\sffamily}
\centering}

But, the following codes do work well:
\begin{figure}
\hangcaption
\captiontitlefont{\sffamily}
\centering
.....
\end{figure}

 0
Reply rockyzhz (6) 12/20/2009 7:20:47 PM

See related articles to this posting

In article <1080cf52-5e6f-4b78-9f6f-4d9aa19c7ecf@u18g2000pro.googlegroups.com>,
Rocky Zhang <rockyzhz@gmail.com> writes:
>For example, I want to insert some commands such as
>\centering
>and some other commands come from ccaption package before the other
>commands in the figure environment,
>and no need to use a new environment name.
>
>How to implement this effect?
>I've tried the following codes, but it didn't work.
>
>\def\tempfigure\figure

i presume you mean

\def\tempfigure{\figure}

all (other) bets are off if you _didn't_ do that -- i can't imagine
what the diagnostics might be like.

>\renewcommand\figure
> {\tempfigure
>  \hangcaption
>  \captiontitlefont{\sffamily}
>  \centering}

\tempfigure is "just" \figure, so the first thing \figure does is to
call itself.  hence the diagnostic.

\let\tempfigure\figure

makes a "frozen" copy of \figure, which isn't changed by subsequent
redefinition, so use that instead of the (corrected) \def.

(note the confusing fact that \let doesn't want braces round its
second argument, like \def does.  this is the sort of thing you get,
dabbling in tex internals (which i presume you don't often do, from

>But, the following codes do work well:
>\begin{figure}
>  \hangcaption
>  \captiontitlefont{\sffamily}
>  \centering
>....
>\end{figure}

of course.
--
Robin Fairbairns, Cambridge

 0

rf10@cl.cam.ac.uk (Robin Fairbairns) writes:

> In article
> Rocky Zhang <rockyzhz@gmail.com> writes:
>>For example, I want to insert some commands such as
>>\centering
>>and some other commands come from ccaption package before the other
>>commands in the figure environment,
>>and no need to use a new environment name.
>>
>>How to implement this effect?
>>I've tried the following codes, but it didn't work.
>>
>>\def\tempfigure\figure
>
> i presume you mean
>
> \def\tempfigure{\figure}
>
> all (other) bets are off if you _didn't_ do that -- i can't imagine
> what the diagnostics might be like.

\tempfigure would be a macro that has to be called like
\tempfigure\figure\renewcommand\figure. Its expansion text is
\tempfigure\hangcaption\captiontitlefont{\sffamily} \centering. \figure
is never changed, and as long as \tempfigure doesn't appear in the
document, there is no difference at all, and no diagnostic messages.

\documentclass{article}
\def\tempfigure\figure
\renewcommand\figure
{\tempfigure
\hangcaption
\captiontitlefont{\sffamily}
\centering}
\begin{document}
\ttfamily
\meaning\figure\par
\meaning\tempfigure
\end{document}

--
Change “LookInSig” to “tcalveu” to answer by mail.

 0

> i presume you mean
>
> \def\tempfigure{\figure}
>
> all (other) bets are off if you _didn't_ do that -- i can't imagine
> what the diagnostics might be like.
>
> \tempfigure is "just" \figure, so the first thing \figure does is to
> call itself. =A0hence the diagnostic.
>
> \let\tempfigure\figure

yeah, I changed the \def command into \let, that codes go well.
But there is still a problem that how to pass the PLACEMENT parameter
to the redefined figure environment?

I've tried some codes with PLACEMENT parameter, and then the figure(or
table) appeared at the end of document.

> makes a "frozen" copy of \figure, which isn't changed by subsequent
> redefinition, so use that instead of the (corrected) \def.
>
> (note the confusing fact that \let doesn't want braces round its
> second argument, like \def does. =A0this is the sort of thing you get,
> dabbling in tex internals (which i presume you don't often do, from
>
>
> of course.
> --
> Robin Fairbairns, Cambridge


 0

Rocky Zhang <rockyzhz@gmail.com> wrote:

> > i presume you mean
> >
> > \def\tempfigure{\figure}
> >
> > all (other) bets are off if you _didn't_ do that -- i can't imagine
> > what the diagnostics might be like.
> >
> > \tempfigure is "just" \figure, so the first thing \figure does is to
> > call itself. �hence the diagnostic.
> >
> > \let\tempfigure\figure
>
> yeah, I changed the \def command into \let, that codes go well.
> But there is still a problem that how to pass the PLACEMENT parameter
> to the redefined figure environment?
>
> I've tried some codes with PLACEMENT parameter, and then the figure(or
> table) appeared at the end of document.

\makeatletter
\hangcaption
\captiontitlefont{\sffamily}
\centering}
\makeatother

The macro \@floatboxreset is the last thing which is executed
before examining the floating environment's content. With that
code we supplement the definition of \@floatboxreset with the
desired commands.

But if you want every caption in that style, why not simply putting
the commands

\hangcaption
\captiontitlefont{\sffamily}

into the preamble?

Ciao
Enrico

 0

On 12=E6=9C=8821=E6=97=A5, =E4=B8=8A=E5=8D=885=E6=97=B635=E5=88=86, Enrico =
Gregorio <grego...@math.unipd.it> wrote:
> Rocky Zhang <rocky...@gmail.com> wrote:
> > > i presume you mean
>
> > > \def\tempfigure{\figure}
>
> > > all (other) bets are off if you _didn't_ do that -- i can't imagine
> > > what the diagnostics might be like.
>
> > > \tempfigure is "just" \figure, so the first thing \figure does is to
> > > call itself. =C3=8Ahence the diagnostic.
>
> > > \let\tempfigure\figure
>
> > yeah, I changed the \def command into \let, that codes go well.
> > But there is still a problem that how to pass the PLACEMENT parameter
> > to the redefined figure environment?
>
> > I've tried some codes with PLACEMENT parameter, and then the figure(or
> > table) appeared at the end of document.
>
> \makeatletter
> =C2=A0 \hangcaption
> =C2=A0 \captiontitlefont{\sffamily}
> =C2=A0 \centering}
> \makeatother
>
> The macro \@floatboxreset is the last thing which is executed
> before examining the floating environment's content. With that
> code we supplement the definition of \@floatboxreset with the
> desired commands.
>
> But if you want every caption in that style, why not simply putting
> the commands
>
> \hangcaption
> \captiontitlefont{\sffamily}
>
> into the preamble?
Because I want to display the figure and table in different style.
>
> Ciao
>


 0

Rocky Zhang <rockyzhz@gmail.com> wrote:

> On 1221, 535p, Enrico Gregorio <grego...@math.unipd.it> wrote:
> > Rocky Zhang <rocky...@gmail.com> wrote:
> > > > i presume you mean
> >
> > > > \def\tempfigure{\figure}
> >
> > > > all (other) bets are off if you _didn't_ do that -- i can't imagine
> > > > what the diagnostics might be like.
> >
> > > > \tempfigure is "just" \figure, so the first thing \figure does is to
> > > > call itself. �hence the diagnostic.
> >
> > > > \let\tempfigure\figure
> >
> > > yeah, I changed the \def command into \let, that codes go well.
> > > But there is still a problem that how to pass the PLACEMENT parameter
> > > to the redefined figure environment?
> >
> > > I've tried some codes with PLACEMENT parameter, and then the figure(or
> > > table) appeared at the end of document.
> >
> > \makeatletter
> > � \hangcaption
> > � \captiontitlefont{\sffamily}
> > � \centering}
> > \makeatother
> >
> > The macro \@floatboxreset is the last thing which is executed
> > before examining the floating environment's content. With that
> > code we supplement the definition of \@floatboxreset with the
> > desired commands.
> >
> > But if you want every caption in that style, why not simply putting
> > the commands
> >
> > \hangcaption
> > \captiontitlefont{\sffamily}
> >
> > into the preamble?
> Because I want to display the figure and table in different style.

Use the caption package instead of ccaption.

Ciao
Enrico

 0

On 12=E6=9C=8821=E6=97=A5, =E4=B8=8A=E5=8D=885=E6=97=B635=E5=88=86, Enrico =
Gregorio <grego...@math.unipd.it> wrote:
> Rocky Zhang <rocky...@gmail.com> wrote:
> > > i presume you mean
>
> > > \def\tempfigure{\figure}
>
> > > all (other) bets are off if you _didn't_ do that -- i can't imagine
> > > what the diagnostics might be like.
>
> > > \tempfigure is "just" \figure, so the first thing \figure does is to
> > > call itself. =C3=8Ahence the diagnostic.
>
> > > \let\tempfigure\figure
>
> > yeah, I changed the \def command into \let, that codes go well.
> > But there is still a problem that how to pass the PLACEMENT parameter
> > to the redefined figure environment?
>
> > I've tried some codes with PLACEMENT parameter, and then the figure(or
> > table) appeared at the end of document.
>
> \makeatletter
> =C2=A0 \hangcaption
> =C2=A0 \captiontitlefont{\sffamily}
> =C2=A0 \centering}
> \makeatother
>
> The macro \@floatboxreset is the last thing which is executed
> before examining the floating environment's content. With that
> code we supplement the definition of \@floatboxreset with the
> desired commands.
I've search the definition of \g@addto@macro, and then find it in the
"source2e".
every float environment?
> But if you want every caption in that style, why not simply putting
> the commands
>
> \hangcaption
> \captiontitlefont{\sffamily}
>
> into the preamble?
>
> Ciao
>


 0

Rocky Zhang <rockyzhz@gmail.com> wrote:

> On 1221, 535p, Enrico Gregorio <grego...@math.unipd.it> wrote:
> > Rocky Zhang <rocky...@gmail.com> wrote:
> > > > i presume you mean
> >
> > > > \def\tempfigure{\figure}
> >
> > > > all (other) bets are off if you _didn't_ do that -- i can't imagine
> > > > what the diagnostics might be like.
> >
> > > > \tempfigure is "just" \figure, so the first thing \figure does is to
> > > > call itself. �hence the diagnostic.
> >
> > > > \let\tempfigure\figure
> >
> > > yeah, I changed the \def command into \let, that codes go well.
> > > But there is still a problem that how to pass the PLACEMENT parameter
> > > to the redefined figure environment?
> >
> > > I've tried some codes with PLACEMENT parameter, and then the figure(or
> > > table) appeared at the end of document.
> >
> > \makeatletter
> > � \hangcaption
> > � \captiontitlefont{\sffamily}
> > � \centering}
> > \makeatother
> >
> > The macro \@floatboxreset is the last thing which is executed
> > before examining the floating environment's content. With that
> > code we supplement the definition of \@floatboxreset with the
> > desired commands.
> I've search the definition of \g@addto@macro, and then find it in the
> "source2e".
> every float environment?

Yes.

Ciao
Enrico

 0

Robin Fairbairns wrote:
> \let\tempfigure\figure
>
> makes a "frozen" copy of \figure, which isn't changed by subsequent
> redefinition, so use that instead of the (corrected) \def.
>
> (note the confusing fact that \let doesn't want braces round its
> second argument, like \def does.  this is the sort of thing you get,
> dabbling in tex internals (which i presume you don't often do, from

On the other hands, \let allows you to use an equal sign. It's not
necessary, but I think it makes the code much more readable:

\let\tempfigure=\figure

--
You should make a point of trying every experience once -- except
incest and folk-dancing.
-- A. Bax, "Farewell My Youth"

Eduardo M KALINOWSKI
eduardo@kalinowski.com.br

 0

On 12=D4=C221=C8=D5, =C9=CF=CE=E74=CA=B124=B7=D6, r...@cl.cam.ac.uk (Robin =
Fairbairns) wrote:
..com>,
>  Rocky Zhang <rocky...@gmail.com> writes:
>
> >For example, I want to insert some commands such as
> >\centering
> >and some other commands come from ccaption package before the other
> >commands in the figure environment,
> >and no need to use a new environment name.
>
> >How to implement this effect?
> >I've tried the following codes, but it didn't work.
>
> >\def\tempfigure\figure
>
> i presume you mean
>
> \def\tempfigure{\figure}
>
> all (other) bets are off if you _didn't_ do that -- i can't imagine
> what the diagnostics might be like.
>
> >\renewcommand\figure
> > {\tempfigure
> >  \hangcaption
> >  \captiontitlefont{\sffamily}
> >  \centering}
>
> \tempfigure is "just" \figure, so the first thing \figure does is to
> call itself.  hence the diagnostic.
>
> \let\tempfigure\figure
>
> makes a "frozen" copy of \figure, which isn't changed by subsequent
> redefinition, so use that instead of the (corrected) \def.
>
> (note the confusing fact that \let doesn't want braces round its
> second argument, like \def does.  this is the sort of thing you get,
> dabbling in tex internals (which i presume you don't often do, from
>
> >But, the following codes do work well:
> >\begin{figure}
> >  \hangcaption
> >  \captiontitlefont{\sffamily}
> >  \centering
> >....
> >\end{figure}
>
> of course.
> --
> Robin Fairbairns, Cambridge

Many thanks to everyone, I've got the particular solutions for figure
and table environments
as the following:

\makeatletter
\renewenvironment{figure}[2][\@empty]
{\ifx\@empty#1\@float{figure}\else\@float{figure}[#1]\fi
\hangcaption
\captiontitlefont{\sffamily}
\centering
#2
}
{\end@float}
\renewenvironment{table}[2][]
{\ifx\@empty#1\@float{table}\else\@float{table}[#1]\fi
\captionnamefont{\hfill}
\captiondelim{\hfill}
\captionstyle{\\}
\captiontitlefont{\sffamily}
\centering
#2
}
{\end@float}
\makeatother

Thanks again.

 0

Rocky Zhang <rockyzhz@gmail.com> wrote:

> Many thanks to everyone, I've got the particular solutions for figure
> and table environments
> as the following:
>
> \makeatletter
> \renewenvironment{figure}[2][\@empty]
>  {\ifx\@empty#1\@float{figure}\else\@float{figure}[#1]\fi

This test doesn't work: if you write \begin{figure}[], it fails.
The default placement for the figure environment is in the macro
\fps@figure (there is \fps@table for "table"); therefore something like

\renewenvironment{figure}[1][\fps@figure]
{\edef\@temp{\noexpand\@float{figure}[#1]}\@temp
...}
{...}

would be more robust (unless you are using babel for French).
I would /never/ add an argument to such environment: this makes
the code not portable to other classes. I don't see any benefit
from writing

\begin{figure}[tp]{\small}

\begin{figure}[tp]
\small

(I guess that your idea is that the second argument contains
declarations for the current figure or table environment).

Ciao
Enrico

 0

On 12=D4=C222=C8=D5, =CF=C2=CE=E710=CA=B126=B7=D6, Enrico Gregorio <grego..=
..@math.unipd.it> wrote:
> Rocky Zhang <rocky...@gmail.com> wrote:
> > Many thanks to everyone, I've got the particular solutions for figure
> > and table environments
> > as the following:
>
> > \makeatletter
> > \renewenvironment{figure}[2][\@empty]
> >  {\ifx\@empty#1\@float{figure}\else\@float{figure}[#1]\fi
>

> This test doesn't work: if you write \begin{figure}[], it fails.
> The default placement for the figure environment is in the macro
> \fps@figure (there is \fps@table for "table"); therefore something like
Oh, I see. In fact, I've tried the command \fps@TYPE, and it didn't
work. thanks:-)
>
> \renewenvironment{figure}[1][\fps@figure]
>   {\edef\@temp{\noexpand\@float{figure}[#1]}\@temp

Here why not use \@float{figure}[#1] directly? Could you elaborate the
difference between them?

>    ...}
>   {...}
>
> would be more robust (unless you are using babel for French).
> I would /never/ add an argument to such environment: this makes
> the code not portable to other classes. I don't see any benefit
> from writing
>
> \begin{figure}[tp]{\small}
>
>
> \begin{figure}[tp]
> \small
immediately. But it seems that the latter form is also compatible with
my original redefinition.
>
> (I guess that your idea is that the second argument contains
> declarations for the current figure or table environment).
>
> Ciao
> Enrico


 0

On 12=D4=C223=C8=D5, =C9=CF=CE=E712=CA=B134=B7=D6, Rocky Zhang <rocky...@gm=
ail.com> wrote:
> On 12=D4=C222=C8=D5, =CF=C2=CE=E710=CA=B126=B7=D6, Enrico Gregorio <grego=
....@math.unipd.it> wrote:
>
> > Rocky Zhang <rocky...@gmail.com> wrote:
> > > Many thanks to everyone, I've got the particular solutions for figure
> > > and table environments
> > > as the following:
>
> > > \makeatletter
> > > \renewenvironment{figure}[2][\@empty]
> > >  {\ifx\@empty#1\@float{figure}\else\@float{figure}[#1]\fi
>
> Thank you for your patient!
Sorry ,                     ~~~~~I mean patience.
>
> > This test doesn't work: if you write \begin{figure}[], it fails.
> > The default placement for the figure environment is in the macro
> > \fps@figure (there is \fps@table for "table"); therefore something like
>
> Oh, I see. In fact, I've tried the command \fps@TYPE, and it didn't
> work. thanks:-)
>
>
>
> > \renewenvironment{figure}[1][\fps@figure]
> >   {\edef\@temp{\noexpand\@float{figure}[#1]}\@temp
>
> Here why not use \@float{figure}[#1] directly? Could you elaborate the
> difference between them?
>
> >    ...}
> >   {...}
>
> > would be more robust (unless you are using babel for French).
> > I would /never/ add an argument to such environment: this makes
> > the code not portable to other classes. I don't see any benefit
> > from writing
>
> > \begin{figure}[tp]{\small}
>
>
> > \begin{figure}[tp]
> > \small
>
> immediately. But it seems that the latter form is also compatible with
> my original redefinition.
>
>
>
>
>
> > (I guess that your idea is that the second argument contains
> > declarations for the current figure or table environment).
>
> > Ciao
> > Enrico- =D2=FE=B2=D8=B1=BB=D2=FD=D3=C3=CE=C4=D7=D6 -
>
> - =CF=D4=CA=BE=D2=FD=D3=C3=B5=C4=CE=C4=D7=D6 -


 0

Rocky Zhang <rockyzhz@gmail.com> wrote:

> On 12��22��, ���10�26�, Enrico Gregorio <grego...@math.unipd.it> wrote:
> > Rocky Zhang <rocky...@gmail.com> wrote:
> > > Many thanks to everyone, I've got the particular solutions for figure
> > > and table environments
> > > as the following:
> >
> > > \makeatletter
> > > \renewenvironment{figure}[2][\@empty]
> > >  {\ifx\@empty#1\@float{figure}\else\@float{figure}[#1]\fi
> >
>
> Thank you for your patient!
>
> > This test doesn't work: if you write \begin{figure}[], it fails.
> > The default placement for the figure environment is in the macro
> > \fps@figure (there is \fps@table for "table"); therefore something like
> Oh, I see. In fact, I've tried the command \fps@TYPE, and it didn't
> work. thanks:-)
> >
> > \renewenvironment{figure}[1][\fps@figure]
> >   {\edef\@temp{\noexpand\@float{figure}[#1]}\@temp
>
> Here why not use \@float{figure}[#1] directly? Could you elaborate the
> difference between them?

Because the expansion of \@float needs to look at the actual characters
that form the optional argument, doing a "loop" on them.

With this \edef, TeX is presented with the token list

\@float{figure}[<expansion of #1>]

Assuming  \def\fps@figure{htp}, a call such as

\begin{figure}

would give

\@float{figure}[htp]

In the case the optional argument is specified, say

\begin{figure}[tp]

the \edef would really do nothing, but would present TeX the
list \@float{figure}[tp].

Actually this doesn't take care for an empty optional argument
either, as it should. :(

So I suggest you something else, again with \@floatboxreset:

\makeatletter
\def\zh@figure{figure}
\def\zh@table{table}
\ifx\@currenvir\zh@figure
\hangcaption
\fi
\ifx\@currenvir\zh@table
\captionnamefont{\hfill}%
\captiondelim{\hfill}%
\captionstyle{\\}%
\fi
\captiontitlefont{\sffamily}
\centering
}
\makeatother

The code in \@floatboxreset is executed at each call of \@float,
but with the conditional inside the code we can distinguish whether
the environment is figure or table and act differently: the macro
\@currenvir contains the current environment's name. Of course you
are not be calling \figure or \table directly, are you? :)

OTOH, with the caption package it's very easy to specify different
setting for figure and table captions:

\captionsetup[figure]{<setup>}
\captionsetup[table]{<setup>}

Ciao
Enrico

 0

On 12=E6=9C=8823=E6=97=A5, =E4=B8=8A=E5=8D=881=E6=97=B609=E5=88=86, Enrico =
Gregorio <grego...@math.unipd.it> wrote:
> Rocky Zhang <rocky...@gmail.com> wrote:
> > On 12=C3=AF=C3=A522=C3=A9=C3=8D, =C3=AC=C3=A5=C3=AB 10=C3=A6=C2=B126=C3=
=A1=E2=80=A6, Enrico Gregorio <grego...@math.unipd.it> wrote:
> > > Rocky Zhang <rocky...@gmail.com> wrote:
> > > > Many thanks to everyone, I've got the particular solutions for figu=
re
> > > > and table environments
> > > > as the following:
>
> > > > \makeatletter
> > > > \renewenvironment{figure}[2][\@empty]
> > > > =C2=A0{\ifx\@empty#1\@float{figure}\else\@float{figure}[#1]\fi
>
> > Thank you for your patient!
>
> > > This test doesn't work: if you write \begin{figure}[], it fails.
> > > The default placement for the figure environment is in the macro
> > > \fps@figure (there is \fps@table for "table"); therefore something li=
ke
> > Oh, I see. In fact, I've tried the command \fps@TYPE, and it didn't
> > work. thanks:-)
>
> > > \renewenvironment{figure}[1][\fps@figure]
> > > =C2=A0 {\edef\@temp{\noexpand\@float{figure}[#1]}\@temp
>
> > Here why not use \@float{figure}[#1] directly? Could you elaborate the
> > difference between them?
>
> Because the expansion of \@float needs to look at the actual characters
> that form the optional argument, doing a "loop" on them.
>
> With this \edef, TeX is presented with the token list
>
> \@float{figure}[<expansion of #1>]
>
> Assuming =C2=A0\def\fps@figure{htp}, a call such as
>
> \begin{figure}
>
> would give
>
> \@float{figure}[htp]
>
> In the case the optional argument is specified, say
>
> \begin{figure}[tp]
>
> the \edef would really do nothing, but would present TeX the
> list \@float{figure}[tp].
>
> Actually this doesn't take care for an empty optional argument
> either, as it should. :(
>
> So I suggest you something else, again with \@floatboxreset:
>
> \makeatletter
> \def\zh@figure{figure}
> \def\zh@table{table}
> =C2=A0 \ifx\@currenvir\zh@figure
> =C2=A0 =C2=A0 \hangcaption
> =C2=A0 \fi
> =C2=A0 \ifx\@currenvir\zh@table
> =C2=A0 =C2=A0 \captionnamefont{\hfill}%
> =C2=A0 =C2=A0 \captiondelim{\hfill}%
> =C2=A0 =C2=A0 \captionstyle{\\}%
> =C2=A0 \fi
> =C2=A0 \captiontitlefont{\sffamily}
> =C2=A0 \centering
> =C2=A0}
> \makeatother
>
> The code in \@floatboxreset is executed at each call of \@float,
> but with the conditional inside the code we can distinguish whether
> the environment is figure or table and act differently: the macro
> \@currenvir contains the current environment's name. Of course you
> are not be calling \figure or \table directly, are you? :)
>
> OTOH, with the caption package it's very easy to specify different
> setting for figure and table captions:
>
> \captionsetup[figure]{<setup>}
> \captionsetup[table]{<setup>}
>
> Ciao
>

Thank you for your wanderful explain! :-)

 0

15 Replies
202 Views

Similar Articles

12/10/2013 10:18:50 PM
page loaded in 215856 ms. (0)

Similar Artilces:

If the records does not exist, insert it
If this is not an appropriate ng, let me know and please redirect me. I am not sure if my question is Oracle specific or if it is OK to ask Oracle specific questions here. I have a many to many relationship. I've learned that when that happens you are to make an intermediate table between the two. So, I've got a table with 2 fields, an ID from the one side and an ID from the other. In my application I am writing all the upserts for all my entities. In doing so, I've come across my first upsert of this type. Normally, my upserts looks like this: BEGIN UPDATE PROSP...

Is there a command to open a file as well as to create the directory if it is not exist?
Hi, The following code would give the following error, if the dir 'xy' does not exist. print() on closed filehandle OUT at ./open.pl line 7. I'm wondering if there is a perl command that is smart enough to create an directory automatically when it opens a file for write. Thanks, Peng #!/usr/bin/perl use strict; use warnings; open(OUT, '>xy/abx.txt'); print OUT "Hello World\n"; Peng Yu <PengYu.UT@gmail.com> wrote: >I'm wondering if there is a perl command that is smart enough to >create an directory automatically when it opens a file for...

environment inheritance
when executing a 'system( some_other program );' from within a perl script the environment it inherits, specifically the path, is unexpected. i login to the work station and an environment is defined and used for subsequent shells. and so it seems it is used for the 'system' command. i would prefer that it use the environment of the shell from which the perl script is called. as they are different (i intentionally changed it) and changing the other, the login environment, requires that i log out and login once more. is there a way to make the system call use the curre...

Select Other command
Is anyone having success with the select other command? It use to work fine for me but with the new changes they added in 2005, I can't get it to work reliably for me anymore. Any tricks to getting it to work or is it just broke? I have found that it really doesn't work well in terms of clicking on a face and having it get out of the way to pick another. The best usage I have found is to use the "pick it out of the list" functionality. That method seems to work pretty well, but different than it used to be. WT "McBurger" <burgers@burgershotmail....

SPRAY command
I was looking for a command to test links between 2 ip-addresses, and I found the following command in the Sys Admin guide (2) SPRAY I used this, as follows, and got the following result back: (1ste try) spray -c 100 -l 65500 mxdev sending 100 packets of length 8845 to mxdev ... 34 packets (34.000%) dropped by mxdev 4 packets/sec, 38869 bytes/sec (2nd try) spray -c 100 -l 65500 mxdev sending 100 packets of length 8845 to mxdev ... 43 packets (43.000%) dropped by mxdev 3 packets/sec, 33572 bytes/sec Is this reliable - if so, it means I have serious network...

Interactive command
I want a command that puts me into a mode where typing n invokes command do-n-thing, typing p invokes do-p-thing, hitting return exits me from the mode, and all other keystrokes are ignored. This would be a bit like doing an incremental search, where each keystroke modifies the search string or takes you to the next or previous occurrence, or escapes you from the search. However, I don't really need to modify the minibuffer much. What's the standard way to do that? Hamad bin Turki Salami wrote: > I want a command that puts me into a mode where typing n > invokes command do-n-...

fill Command
Using the fill command in Photoshop edit command after selecting with the magic wand command does not work . but the fill command works in the layer mode . Kurt Knoll Photographs of the Canadian northwest. But it works normally on my other older computer. www.kurtknoll.com/midway/html xray@monarch.net On Dec 26, 3:45 pm, "Kurt Knoll" <kkno...@yahoo.com> wrote: > Using the fill command in Photoshop edit command after selecting with the > magic wand command does not work . but the fill command works in the layer > mode . > Kurt Knoll > Photographs of the Canad...

inserting lines
I want to know how to add a line , say "foobar" , after a line which says, for example "string1", in a inout file. how can I do this ? (I'm pretty new to Perl) PG wrote: > I want to know how to add a line , say "foobar" , after a line which says, > for example "string1", in a inout file. > > how can I do this ? What have you tried so far? What is an "inout" file? DS PG ha escrito: > I want to know how to add a line , say "foobar" , after a line which says, > for example "string1", in a inou...

Nop insertion
hi This is both an architecture and compiler question. Are there inorder architectures that need precise number of nops inserted between operations. If so, how does a compiler guarantee that ? I am especially thinking of producers and consumers in faraway basic blocks. Any pointers to any exiting work? thanks shrey [There have been a few, it's typically done by the assembler. -John] shrey wrote: > hi > This is both an architecture and compiler question. > > Are there inorder architectures that need precise number of nops > inserted between operati...

unix command (!)
I'm running MATLAB 14SP1 and the unix command is not functioning properly via calling unix() directly or with the ! character. >> unix('ls') ans = 127 >> unix('dir') ans = 127 >> unix('cd ~') ans = 127 >> Does anyone have any suggestions as to what the problem may be? Thanks. JiggaHertz: <SNIP problems with <unix>... can you show the output from [res,msg]=unix('ls') us In article <LL9Kd.48$cr2.20@llnews.ll.mit.edu>, JiggaHertz@nospam.com says... > I'm running MATLAB 14SP1 a... Disabling commands Hi guys, I'm trying to figure out how to prevent accidental reboots of a production system we have here. The root account is used a lot, and there's no chance of that changing. sudo is not an option either. So, would it be best to rename the commands, or just change root's default PATH to include another place before sbin where warnings named after the commands exist? i.e. set bin in front of sbin and then having a script called reboot in bin, just echoing a warning. TIA Tony tonyalbers wrote: > Hi guys, > > I'm trying to figure out how to prevent accidental rebo... how insert a package I should insert a package in my design for fixed point operation which is the correct operation to do this? bye marco On Thu, 22 Jul 2004 15:38:36 GMT, "Marco Bongiovanni" <marcobongiovanni@aliceposta.it> wrote: >I should insert a package in my design for fixed point operation >which is the correct operation to do this? You don't "insert" a package; you compile it into a library, then make the library and package visible using context clauses. Do you have a suitable fixed-point package already? If so, tell us which one you want to use, and we may be ... Path command Hi; Can you tell me in which file need I put this path command to make effect in all system=B4s users ? PATH=3D$PATH:/opt/VRTSvmsa/bin:/usr/ucb: Thanks On Wed, 08 Oct 2008 05:39:01 -0700, apogeusistemas wrote: > Can you tell me in which file need I put this path command to > make effect in all system�s users ? > > > PATH=\$PATH:/opt/VRTSvmsa/bin:/usr/ucb: Yes, I can, but it will do you far more good to read the appropriate man page - login(1). Dave Uhring wrote: > On Wed, 08 Oct 2008 05:39:01 -0700, apogeusistemas wrote: > >> Can you tell me in which file n...

sum command
I have a file named a which contains x'610a'. When I do sum a, I get: "107 1 a". I don't see how to get that answer. Could someone help? On 2007-07-29 02:16:46 +0100, "jerry chapman" <jerryc314@sbcglobal.net> said: > I have a file named a which contains x'610a'. When I do sum a, I get: "107 1 > a". I don't see how to get that answer. Could someone help? According to the man page, sum(1) prints a "checksum and block count for a file". The two supported checksum algorithms are described in the source code - look...

AIX command line
After a user successful logs in to the AIX system, he/she would be automatically directed to the application software/system. Thus, users are not allowed to go to the command lines (can't execute any commands). My question here is --> is it a function/command of a AIX operating systems that restraining user from access the command lines (if yes, where about to check from the AIX system) or is it the application software that controls it? Please help. Thank you. In article <da9f7573.0409131809.7bfbda9a@posting.google.com>, TC wrote: > After a user successful logs in to the ...

How to add to existing onclick?
I would like to use code like the following: this.onclick = function(e) { alert("I'm in the onclick handler"); } But I do not want to wipe out any existing onclick event code. I want to do this dynamically. I tried variations like this: var oc = this.onclick; this.onclick = function(e) { alert("I'm in the onclick handler"); if (oc != null) eval(oc.toString()); } but can't get it to work. Is this sort of thing possible? If so, how is it done? TIA. Peter wrote: > I would like to use code like the following: > > this.onclick =...

RPL programming environment?
Greetings, I have seen reference to system level programming aides. I do not have the need to do that. Is there a computer program environment for RPL? Thanks for any help. On Dec 7, 5:13=A0pm, Chad4...@gmail.com wrote: > Greetings, > I have seen reference to system level programming aides. > I do not have the need to do that. > Is there a computer program environment for RPL? > Thanks for any help. Try Debug4x: http://www.debug4x.com/ S.C. ...

find command 4495
I am trying use the command "find" to search for files that start with 2009 into all subdirectories. On Wed, 28 Jul 2010 09:34:48 -0700 (PDT), rvaede <rvaedex23@gmail.com> wrote: >I am trying use the command "find" to search for files that start with >2009 into all subdirectories. find . -type f -name '2009*' -- Web mail, POP3, and SMTP http://www.beewyz.com/freeaccounts.php On Jul 28, 12:45=A0pm, John Kelly <j...@isp2dial.com> wrote: > On Wed, 28 Jul 2010 09:34:48 -0700 (PDT), rvaede <rvaede...@gmail.com> > wrote: > >...

INSERT /*+ append */ hint
Hi, Oracle 10.2.0.4, Solaris We migrated to the database a code change where we decided to modify most inserts with an /*+ APPEND */ hint. We found the exercise to be fine on all our non-prod databases. In production, though we ended up with a ORA-12801 (error signaled in parallel query server P006) followed by a ORA-00018 maximum number of sessions exceeded. This was the only change. I do admit that for a 16 CPU box, the parallel_max_servers is 135 and the sessions is 170. I intend to take this up with the DBAs since the numbers were 285 and 335 respectively on the non-prod b...

cgps command question
Hello, I set up alix1d box running debian etch with a garmin 18x lvc receiver. I am using gpsd and ntp with the shared memory driver running both gps and pps signal. The data output provided by ntpq =96p looks good with excellent readings for the GPS and the PPS signal but my question concerns the output from cgps command. The status line blinks between 2D and 3D fix counting up only to 1 every second. It continually blinks/refreshes while it updates. The gps type reads generic nmea. There is no data showing on the right side of the screen. Is this the way it should look? We have anot...