f



advance a counter from a macro

This is so basic I'm ashamed to ask, but I know people
here can answer in no time, so I'll shut up my ego and ask.
Consider

\def\ADV{\global\advance\lll by 1}

\lll=-1
\ADV
\ifnum\lll=0 ZZZ \else PPP \fi

\lll=-1
\showthe\lll
\ADV
\ifnum\lll=0 ZZZ \else PPP \fi

\lll=-1
\ADV
\showthe\lll
\ifnum\lll=0 ZZZ \else PPP \fi

\bye

I expected "ZZZ  ZZZ  ZZZ" but I get  "PPP PPP ZZZ"
Why??

Piero
0
9/24/2008 7:52:04 PM
comp.text.tex 38742 articles. 1 followers. Post Follow

3 Replies
223 Views

Similar Articles

[PageSpeed] 10

pierodancona@gmail.com a =E9crit :
> This is so basic I'm ashamed to ask, but I know people
> here can answer in no time, so I'll shut up my ego and ask.
> Consider
>
> \def\ADV{\global\advance\lll by 1}
>
> \lll=3D-1
> \ADV
> \ifnum\lll=3D0 ZZZ \else PPP \fi
>
> \lll=3D-1
> \showthe\lll
> \ADV
> \ifnum\lll=3D0 ZZZ \else PPP \fi
>
> \lll=3D-1
> \ADV
> \showthe\lll
> \ifnum\lll=3D0 ZZZ \else PPP \fi
>
> \bye
>
> I expected "ZZZ  ZZZ  ZZZ" but I get  "PPP PPP ZZZ"
> Why??
>  =20

A \relax is wiser after a number to avoid unexpected expansion of \ifnum =
:

\def\ADV{\global\advance\lll by 1\relax}

0
admin_c (13)
9/24/2008 8:05:56 PM
> > Why??
>
> A \relax is wiser after a number to avoid unexpected expansion of \ifnum :
>

Yes!
Thank you. I can go to sleep now

Piero

0
9/24/2008 9:08:25 PM
<pierodancona@gmail.com> wrote:

> This is so basic I'm ashamed to ask, but I know people
> here can answer in no time, so I'll shut up my ego and ask.
> Consider
> 
> \def\ADV{\global\advance\lll by 1}
> 
> \lll=-1
> \ADV
> \ifnum\lll=0 ZZZ \else PPP \fi
> 
> \lll=-1
> \showthe\lll
> \ADV
> \ifnum\lll=0 ZZZ \else PPP \fi
> 
> \lll=-1
> \ADV
> \showthe\lll
> \ifnum\lll=0 ZZZ \else PPP \fi
> 
> \bye
> 
> I expected "ZZZ  ZZZ  ZZZ" but I get  "PPP PPP ZZZ"
> Why??

Read closely your input. It's equivalent to

\lll=-1 \ADV\ifnum\lll=0 ZZZ \else PPP \fi

and, after the initial assignment, it expands to

\global\advance\lll by 1\ifnum\lll=0 ZZZ \else PPP \fi

Now TeX expands tokens after the 1, as explained in the TeXbook;
therefore the conditional is evaluated when the value of \lll is
still -1.

A proper way to define \ADV is

\def\ADV{\global\advance\lll by 1 }

or

\def\ADV{\global\advance\lll by \@ne}

(in a context where @ has category code 11). In the first case
the space will be ignored, in the second case the number specification
ends at the token \@ne which is not expandable (Plain TeX and LaTeX
define it by "\chardef\@ne=1").

In the second case the "\showthe\lll" is irrelevant, but in the third
one it stops the search for a number specification, since \showthe does 
not expand to a <number>; therefore the assignment \lll=0 is performed
and the conditional is evaluated with the intended value.

Ciao
Enrico
0
gregorio (1367)
9/24/2008 9:19:18 PM
Reply:

Similar Artilces:

Convert TeX to normal text (stripping macros)
Hi all, Does anyone know a good way to strip a TeX file from its macros in order to run grammar checking from LangauageTool on it? Please also see this bug report for Language Tool: https://sourceforge.net/tracker/index.php?func=detail&aid=2880449&group_id=110216&atid=655717 A Java implementation would be preferred since Language Tool is in Java so it runs platform independently. Thanks, Pander On Mon, 26 Sep 2011 03:39:01 -0700 (PDT), Pander wrote: > Does anyone know a good way to strip a TeX file from its macros I suggest you use one of the tools that convert from dvi/postscript/pdf to text: dvi2tty pstotext pdftotext That is, analyze the output, not the input to (La)TeX. Bob T. ...

Plain TeX macros for text-flowing-around-figures
Are there any public domain macros to do the title task? More specifically: texttexttexttexttexttexttexttexttexttexttext texttexttexttexttexttexttexttexttexttexttext texttexttexttexttexttexttexttexttexttexttext texttexttexttexttexttexttexttexttexttexttext texttexttexttext ----------------------- texttexttexttext | | texttexttexttext | Figure box | texttexttexttext | inserted by | texttexttexttext | \BoxedEPSF{ ...} | texttexttexttext | | texttexttexttext ----------------------- texttexttexttext ...

Plain TeX macro: figflow -- flow text around a figure
recently, in response to a post on comp.text.tex, Ian Hutchinson posted a short piece of code to do this job. the abstract i've written for the catalogue says Provides a Plain TeX macro \figflow that allows one to insert a figure into an area inset into a paragraph. Command arguments are width and height of the figure, and the figure (and its caption) itself. (Does not work with LaTeX.) i asked (and was given) permission to put the file on ctan, and have installed it on ctan in directory macros/plain/contrib/figflow Robin Fairbairns For the CTAN team ...

Re: Macros: how to add one macro's value into the text of a second macro?
> data _null_; > set nonzeroskew; > call symput ('skewd',skewness); your mistake is that mvar Skewd does not exist -- or does not have the value you want -- until the next step: i.e., after the 'run' statement. unless you want to use this value elsewhere the fix below does not require this mvar allocation, so you can remove/delete the above. > call symput ('nonzeroskew' > ,"The skewness of the non-zero observations is &skewd"); > run; *mvars have values here/now; concatenate your value of skewness in symput: call symput ('nonzero...

text-text
Wondering how what I input to my UTF-8 terminal gets passed along through my patched [1] trn ... Cyrillic: А Б В Г Д Е Ж З И Й К Л М Н О П а б в г д е ж з и й к л м н о п IPA: ᴀ ᴁ ᴂ ᴃ ᴄ ᴅ ᴆ ᴇ ᴈ ᴉ ᴊ ᴋ ᴌ ᴍ ᴎ ᴏ ɀ Ɂ ɂ Ƀ Ʉ Ʌ Ɇ ɇ Ɉ ɉ Ɋ ɋ Ɍ ɍ Ɏ ɏ [1] https://groups.google.com/d/msg/comp.sys.raspberry-pi/7Z37Hdrm0DM/6aqD-reXFzAJ ...

text + text
What is "text + text" supposed to do right now? It doesn't seem very useful to me. What about making "text + text" as an equivalent for "text || text"? Most strongly-typed programming languages do this. And MS SQL Server too, I think (CMIIW). -- dave ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org Am Freitag, 8. Oktober 2004 12:57 schrieb David Garamond: > What is "text + text" supposed to do right now? Nothing. > What about making "text + text" as an equivalent for "text > || text"? Most strongly-typed programming languages do this. And MS SQL > Server too, I think (CMIIW). What would this gain except for bloat? It's not like SQL is utterly compatible with any programming language; users will still have to learn all the operators anyway. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match Peter Eisentraut wrote: >>What is "text + text" supposed to do right now? > > Nothing. Then are these bugs? (7.4.5 and 8.0.0beta1 give same results). Frankly, the current behaviour is quite strange to me. ------------------ =...

The TeX Counter
Check out the The TEX Counter at <http://oimelc.ucc.ie/tex/counter/> At least this was new for me... Hans -- The UK (La)TeX FAQ - http://www.tex.ac.uk/faq The Not So Short ... - http://people.ee.ethz.ch/~oetiker/lshort/lshort.pdf TeX at ODP - http://dmoz.org/Computers/Software/Typesetting/TeX/ Ugh, the "certificate" that you get contains type-3 bitmap fonts.. Hans Fredrik Nordhaug <hansfn@gmail.com> writes: > Check out the The TEX Counter at > <http://oimelc.ucc.ie/tex/counter/> > At least this was new for me... How is this related to TUG? I t...

Re: Problem with macro logical condition : passing a counter in the macro
Paul explains well the issues, and these are things one must understand in order to use the macro facility with confidence. However, you might find yourself moving in the direction of a quick fix by simply removing the percent signs in your Condition 1 and Condition 2 blocks. On Thu, 8 Jul 2004 01:33:20 -0400, Paul M. Dorfman <sashole@BELLSOUTH.NET> wrote: >Dominic, > >You are trying to use a macro assembling Data step code based on the value >of a Data step variable before the Data step has run. Note that the entire >activity of your macro compilation ends before the SAS Supervisor starts >even compiling the Data step, let alone running it. Besides, it would be >extremely contrived to base macro compilation on different values through >which a Data step variable goes as the step runs, and that would require the >step running *before* the macro compilation time. Your COUNT in the %IF >macro statement is nothing else but pure text, not depending in the least on >the value of the variable COUNT in the Data step executing SAS code the >macro had assembled before the step started running. The actual code you >macro assembles (together with the rest of the Data step code), as you can >judge from MPRINT listing, is > >data test ; > > set random ; > > count = _n_ ; > > check = count ; > > lagx1 = lag1(x) ; > > lagx2 = lag2(x) ; > > lagx3 = lag3(x) ; > > lagx4 = lag4(x) ...

igrafx flowcharter VBA macro to copy all text from text objects
I need a VBA macro to copy all text from text objects in the igrafx flowcharter Diagram to clipboard or to save it to a text file (in order to count the text I translated). I tried the following: z = Diagram1.DiagramObjects.Count For a = 1 To z If Diagram1.DiagramObjects(a).Type = ixObjectTextGraphic Then Diagram1.DiagramObjects(a).TextGraphicObject.TextRange.Copy End If Next a But it does not seem to work. I will appreciate your help. Thanks --- Piotr ...

Problem with macro logical condition : passing a counter in the macro from the data step
Hi, I have that little piece of code as an example (see below). In the macro 'ma_create' I want to use the variable count that is created in the data step 'test'. Basically count in that exemple is set to _n_. I know that count is seen correctly in the macro because I generate the variable check is has the right value. Still logical operation that requires the value of count fail. In execution of the macro, count is always seen as greater than the macro variable days which is set in that example to 5. Why does the code only excute condition 1 (count is always se...

Macros: how to add one macro's value into the text of a second ma cro?
Hi all - In an effort to consolidate some output, I'm creating a few macros. For instance if the minimum value on a data set is < 0, it will create a macro saying "Dataset contains negative values, not appropriate for this analysis" et cetera. The thought being that, at the end, I could read these macro variables into a file and print that file. One of the things I want to produce is the (numerical) skewness of the nonzero observations. I can get that number read into a macro. Then I want to create a macro with text saying "The skewness of the nonzero observations is 1...

Create Macro to import fixed width text from clipboard or text file and update table
Hi, I have a MS access database table for which I regularly need to import fixed width text data. At present I have to to cut and paste the text data from its source to a text file, save the file, import the text file as fixed width text [it is not naturally delimited], and then run an update query to copy the appropriate info into fields of a different table. Is it possible to write a macro to do all these steps? Also, is it possible to import directly from the clipboard (to skip the step of making a text file)? Any help provided would be greatly appreciated. Best wishes, George Hadley g...

Re: Macros: how to add one macro's value into the text of a second ma cro?
On Fri, 9 Jan 2004 16:35:08 -0500, DePuy, Venita <depuy001@DCRI.DUKE.EDU> wrote: >Hi all - > >In an effort to consolidate some output, I'm creating a few macros. > >For instance if the minimum value on a data set is < 0, it will create a >macro saying "Dataset contains negative values, not appropriate for this >analysis" et cetera. >The thought being that, at the end, I could read these macro variables into >a file and print that file. > >One of the things I want to produce is the (numerical) skewness of the >nonzero observations. >...

setting TeX text variable depending on keyval-generated param? (low-level TeX question)
I am using keyval to set a "scaled" parameter and am having trouble getting the right behavior, which is: If I \usepackage{package} with no [scaled] option, I want to set a variable to a compile-time-specified default, say "s*[a.b]". If I \usepackage[scaled]{package}, same thing. And if I \usepackage[scaled=x.y], I want to set the variable to "s*[x.y]". (This is for font scaling, and I've used as my model the Helvetica scaled parameter.) The variable name (for the purposes of this conversation) is pnm@scaled. What I have that's not working correctly is: \expandafter\ifx\csname pmn@scaled\endcsname\relax \let\pmn@scaled\@empty \else \edef\pmn@scaled{s*[1.2]}% \fi I think what this says is "if pnm@scaled is not defined (case 1), leave it empty, otherwise set it to "s[1.2]". But the else clause is not working correctly, and I don't know how to differentiate between "defined by keyval but with no value" and "defined by keyval but with a value". Also I'm pretty sure I don't really know the difference between \let and \edef. Any help gratefully appreciated. Thanks. JDO john_owens@yahoo.com schrieb: > I am using keyval to set a "scaled" parameter and am having trouble > getting the right behavior, which is: > > If I \usepackage{package} with no [scaled] option, I want to set a > variable to a compile-time-specified default, say "s*[a.b]". > ...

Re: Macros: how to add one macro's value into the text of a secon d ma cro?
Venita - I'm no macro maven :-), but I think you may want the "resolve" function: http://v8doc.sas.com/bin/ixcgisol/sashtml/macro/z0210258.htm Paul Choate DDS Data Extraction (916) 654-2160 -----Original Message----- From: DePuy, Venita [mailto:depuy001@DCRI.DUKE.EDU] Sent: Friday, January 09, 2004 1:35 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Macros: how to add one macro's value into the text of a second ma cro? Hi all - In an effort to consolidate some output, I'm creating a few macros. For instance if the minimum value on a data set is < 0, it will create a mac...

How does TeX expand macros?
Hi, In <<the TeXbook>>, there is a macro at appendix D, p376: \def\\{\let\stoken= } \\ % which defines the \stoken to be a space token. But why? How does TeX expand the macro \\ ? When i typed \ let\stoken= % however, this does not work. Another question is about the macros \obeylines and \obeyspaces. In plain TeX they are defined as: {\catcode`\^^M=\active % these lines must end with % \gdef\obeylines{\catcode`\^^M\active \let^^M\par}% \global\let^^M\par} % this is in case ^^M appears in a \write \def\obeyspaces{\ca...

Advanced Macro Class
You have been complaining about this class even before you took it. Lets work on these awful examples, so the "Ivory Billed Woodpeckers" can see them and improve this course. We can start with the example you refer to. What macro technique was being demonstrated? What would be a better example? When we beat this one to death we can move on to other irritating examples. On 9/5/08, Toby Dunn <tobydunn@hotmail.com> wrote: > Cherish, > > This is one of those examples I saw and hated in the Advanced Macro class > I attend last week. No macro is needed at all. Idea...

advanced text formatting?
Are their any plugins/scripts etc. that allow mixed fonts/sizes/styles within the same paragraph? ...

More advanced forms of macros?
Have there ever been any experiments with something like: a. "semi-colon eating" macros #define foo(a, b;) case ((a)+(b)): foo(a, b); becomes case ((a)+(b)): b. "block taking" macros: #define foo(a, b, {c}) switch (a) \ { case (b): { c } break; default: blah; } foo(a, b) { outer1; { inner; } outer2; } becomes: switch (a) { case (b): { outer1; { inner; } outer2; } break; default: blah; } Maybe somebody thought of something like this before but they decided against it because it might interact poorly with nested macros or be fragile in some way? --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ] ...

Transfer Text Macro
I have designed a macro to transfer data from tables to .txt files, however the output lines are kept between quotation marks for example. "xxxxxxxxx". Is there a method of not having the " " surrounding the text when output to the .txt file. I have tried to create a specification name but do not fully know how to do this. Any help would be welcomed. thanks. Michael "Michael Curtis" <michael.3.curtis@bt.com> wrote in news:bejcl5$11h$1@pheidippides.axion.bt.co.uk: > I have designed a macro to transfer data from tables to .txt files, > howeve...

tex column counter
Hi there When creating a multicolumn document (book with twocolumn option or using the multicols package) can anyone suggest a way to test the current column number for the page being prepared i.e. is this column one, column two etc.? I'm imagining a \thecolumn counter sort of similar to \thepage. I'd like to be able to set the behaviour of certain environments based on this (e.g. set raggedright or raggedleft so that the flush edge is symmetrical). It occurred to me that something in the latex \marginpar command must be able to figure this out to enable it to place marginal ...

TeX Macro and dimen
Hi there, If a tex macro expands to a dimen (\radius -> .5cm), it seems to me that -\radius works in places where a dimen is required but 0.2\radius does not. Could someone explain why? This is very common in tikz so I want to know exactly what's going on. Many thanks in advance. Leo Leo <sdl.web@gmail.com> writes: > Hi there, > > If a tex macro expands to a dimen (\radius -> .5cm), it seems to me > that -\radius works in places where a dimen is required Results in -.5cm obviously > but 0.2\radius does not. Results in 0.2.5cm obviously. ...

Accumulate text macro
Hi! I want to write such macros which get 1 parameter and accumulate. For example: \AddWord{Hello} \AddWord{World!} \ReadPhrase % Here I get "Hello World!" Any ideas ? Best regards, Vladimir Tichonjuk Vladimir Tikhonjuk wrote: > Hi! > > I want to write such macros which get 1 parameter and accumulate. For > example: > > \AddWord{Hello} > \AddWord{World!} > > \ReadPhrase % Here I get "Hello World!" > > Any ideas ? > Try \makeatletter \g@addto@macro\ReadPhrase{Hello} \g@addto@macro\ReadPhrase{ World!} \makeatother...

Macro text to file
Hi, Is there any foolproof way to output the text generated by any macro to a file (using data _null_ and put may be)? The reason I ask: Where I work, it is a mainframe system. I can put JCL and SAS commands to a special file, to create a new job. I would like to have some macro which can create new jobs. Example, I would want to have a macro %Fork which can create a new job, taking the argument as a macro which generates SAS code: %Macro Process(parameter); ....whatever the job should do... %Mend; %Fork(%Process(a)) %Fork(%Process(b)) %Fork(%Process(c)) On 16 Jun, 09:51, abose <hira....

Web resources about - advance a counter from a macro - comp.text.tex

Association to Advance Collegiate Schools of Business - Wikipedia, the free encyclopedia
During the International Conference and Annual Meeting (ICAM) in 2013, AACSB members unanimously approved the 2013 business and accounting Accreditation ...

3Q Digital Examines Mobile Advertising Results In Advance Of Facebook’s 1Q Earnings Call
With Facebook’s first-quarter earnings call set for Wednesday after the close of trading, digital marketing agency 3Q Digital offered a preview ...

With 90 minutes' advance notice, Plain... - SaveThePlainDealer - Facebook
With 90 minutes' advance notice, Plain Dealer management announced late this afternoon that tonight it will lay off an unspecified number of ...

Oregon and Ohio State advance in the inaugural College Football Playoff semifinals
Football fans rang in the new year with the inaugural College Football Playoff ( @CFBPlayoff ) semifinals on @ESPN and Twitter. And now Ohio ...

Visalia Times-Delta and Tulare Advance-Register - Visalia news, community, entertainment, yellow pages ...
VisaliaTimesDelta.com and TulareAdvanceRegister.com is the home page of Tulare County newspapers with updated news and information for Visalia, ...

Advance Digital - LinkedIn
... you discover inside connections to recommended job candidates, industry experts and business partners. Local Reach, Active Consumers Advance ...

Advance Live Tv for iPhone, iPod touch, and iPad on the iTunes App Store
Get Advance Live Tv on the App Store. See screenshots and ratings, and read customer reviews.

Global equities, metals, oil rally; $A advances
Momentum in global financial markets continued entering the weekend and investor appetite for risk assets jumped.

Eric Schmidt: Advances in AI will make every human better
... artificial intelligence (AI) will make every human on the planet better in some way. Speaking in South Korea on Tuesday, Schmidt said: "Advances ...

Exelon Supports Climate Leadership Conference to Advance Discussion on Low-Carbon Future
Exelon is a lead sponsor of the fifth-annual Climate Leadership Conference in Seattle this week, which brings together a global audience of climate, ...

Resources last updated: 3/11/2016 6:15:02 AM