ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to use a variable in a macro agrument
@ 2021-12-18  9:52 skyhorse--- via ntg-context
  2021-12-18 10:55 ` Willi Egger via ntg-context
  2021-12-18 11:42 ` Wolfgang Schuster via ntg-context
  0 siblings, 2 replies; 3+ messages in thread
From: skyhorse--- via ntg-context @ 2021-12-18  9:52 UTC (permalink / raw)
  To: ntg-context; +Cc: skyhorse



I have a need to use a logo graphics file several times in a document.
I somethings need to update to a newer graphics file.
I only want to make one change to the original variable value definition.

I've tried using \define.. but it's not working for me.
Here is my MWE:

%%%%%%%%

\define[]\logofile{an_image_file.png}	% Here defining the variable with the filename to use.

\definelayer[stillimage]
\setlayer[stillimage]{\externalfigure[\logofile]}  % Here trying to use the \logofile macro.
\setupbackgrounds[page][background=stillimage]

\starttext
    \input knuth
\stoptext




What's the accepted way to do this or are macro arguments not allowable?


Thanks
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to use a variable in a macro agrument
  2021-12-18  9:52 How to use a variable in a macro agrument skyhorse--- via ntg-context
@ 2021-12-18 10:55 ` Willi Egger via ntg-context
  2021-12-18 11:42 ` Wolfgang Schuster via ntg-context
  1 sibling, 0 replies; 3+ messages in thread
From: Willi Egger via ntg-context @ 2021-12-18 10:55 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Willi Egger

May be \useexternalfigure is your friend instead of your \define[]\logofile{}, which allows you to give a symbolic name of the logo-file. This symbolic name you can use then in the setlayer construct.

Willi

> On 18 Dec 2021, at 10:52, skyhorse--- via ntg-context <ntg-context@ntg.nl> wrote:
> 
> 
> 
> I have a need to use a logo graphics file several times in a document.
> I somethings need to update to a newer graphics file.
> I only want to make one change to the original variable value definition.
> 
> I've tried using \define.. but it's not working for me.
> Here is my MWE:
> 
> %%%%%%%%
> 
> \define[]\logofile{an_image_file.png}	% Here defining the variable with the filename to use.
> 
> \definelayer[stillimage]
> \setlayer[stillimage]{\externalfigure[\logofile]}  % Here trying to use the \logofile macro.
> \setupbackgrounds[page][background=stillimage]
> 
> \starttext
>   \input knuth
> \stoptext
> 
> 
> 
> 
> What's the accepted way to do this or are macro arguments not allowable?
> 
> 
> Thanks
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to use a variable in a macro agrument
  2021-12-18  9:52 How to use a variable in a macro agrument skyhorse--- via ntg-context
  2021-12-18 10:55 ` Willi Egger via ntg-context
@ 2021-12-18 11:42 ` Wolfgang Schuster via ntg-context
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2021-12-18 11:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users, skyhorse--- via ntg-context
  Cc: Wolfgang Schuster

skyhorse--- via ntg-context schrieb am 18.12.2021 um 10:52:
>
> I have a need to use a logo graphics file several times in a document.
> I somethings need to update to a newer graphics file.
> I only want to make one change to the original variable value definition.
>
> I've tried using \define.. but it's not working for me.
> Here is my MWE:
>
> %%%%%%%%
>
> \define[]\logofile{an_image_file.png}	% Here defining the variable with the filename to use.
>
> \definelayer[stillimage]
> \setlayer[stillimage]{\externalfigure[\logofile]}  % Here trying to use the \logofile macro.
> \setupbackgrounds[page][background=stillimage]
>
> \starttext
>      \input knuth
> \stoptext
>
> What's the accepted way to do this or are macro arguments not allowable?

To fix your example you have to use the \defineexpandable command to 
create the command.

Another method which was already suggested by Willi is to use the 
\useexternalfigure command to create a reference to your graphic.

A alternative to \defineexpandable is the \setvariables command.


\setupexternalfigures [location=default]

\defineexpandable\MillFigure{mill.png}
\useexternalfigure[CowFigure][cow.pdf]
\setvariables[figures][hacker=hacker.jpg]

\starttext

\externalfigure[\MillFigure]

\externalfigure[CowFigure]

\externalfigure[\getvariable{figures}{hacker}]

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-18 11:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18  9:52 How to use a variable in a macro agrument skyhorse--- via ntg-context
2021-12-18 10:55 ` Willi Egger via ntg-context
2021-12-18 11:42 ` Wolfgang Schuster via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).