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

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

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

\lll=-1
\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 37824 articles. 1 followers.

3 Replies
128 Views

Similar Articles

[PageSpeed] 1
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
>
>
> \lll=3D-1
> \ifnum\lll=3D0 ZZZ \else PPP \fi
>
> \lll=3D-1
> \showthe\lll
> \ifnum\lll=3D0 ZZZ \else PPP \fi
>
> \lll=3D-1
> \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 =
:


 0
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
>
>
> \lll=-1
> \ifnum\lll=0 ZZZ \else PPP \fi
>
> \lll=-1
> \showthe\lll
> \ifnum\lll=0 ZZZ \else PPP \fi
>
> \lll=-1
> \showthe\lll
> \ifnum\lll=0 ZZZ \else PPP \fi
>
> \bye
>
> I expected "ZZZ  ZZZ  ZZZ" but I get  "PPP PPP ZZZ"
> Why??

\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

or

(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

working word counter
After getting some help working through my bugs, I have what seems to be a robust, working word counter script. I post it here to benefit others that might want this in the future and so that if I ever lose my copy I can come back here to find it :) Some other scripts that I used for inspiration failed when confronted with whitespace before the string or miscalculated when encountering linefeeds and other non-space spaces, so I made mine better. Definition of words for this exercise is contiguous groups of characters separated by whitespace. Maybe it will even be useful to somebody besides...

Re: Help with SAS macro #2
If I understood that right, there should be a start-date, a end-date and a interval of months to advance the start date until the end-date is reached. So passing variable names don't make any sense. Passing date-constants however lead to syntax errors, because the parameter (!) in deed is used as variable name! That cannot be done like that. So the best way is to define a interims-variable (in my programs always DUMMY...) to keep the dates for the loop. That variable is initialized by the parameter. Something like: fromdate = &fromdate; (on left side is a (new) variable, on right s...

Re: Sql Counts into Macro
Don't do this at all. Data does not belong in macro variables. put it a data set and/or make an informat so you can read TRT and return the N. Or some other "look up" device. You don't want to be tied to the macro variables. If you free your programs from all these macro variables they will become more dynamic and generalizable, without involving a lot of macro code and macro variables. On Nov 30, 2007 9:52 AM, SAS_learner <proccontents@gmail.com> wrote: > Hello guys > > I am using following code to capture counts of different treatments and > total of...

Gentlemans: First of all, sorry for my poor English - I'm from Russia. We develop personal organizer Info Angel about three years. You may found it at this url: http://www.angelicsoftware.com Unfortunately, our sales is very low - about 10 copies at month. So it will be very useful for us to know your opinion about that deal. We hope release new version at next week, so I hope anyone can gave me a piece of good advance. Kind of "What is wrong with my software" and "How to improve our sales". -- Best regards, Sergey Gotsulyak Angelic Software E-...

Macros vs quoted arguments?
Suppose there were a way for a function to take its argument list as a literal parameter (and perhaps also the caller's environment), so that given the call (F A B C) the variable ARGS would be bound to (A B C) and ENV to the caller's environment. It seems to me this would be an alternative way of doing what macros do - am I missing anything? -- "Sore wa himitsu desu." To reply by email, remove the small snack from address. http://www.esatclear.ie/~rwallace In article <4094ecc7.252592790@news.eircom.net>, wallacethinmintr@eircom.net (Russell Wallace) wrote: > Su...

Re: 'Local' datasets in Macro? #17
Peter , Here is we will disagree. I hate data set names liek Data1 ....DataN. Why they provide absolutely no meaning to the code in fact I would go further and say they do a great deal to confuse the reader of said code. The fact that one allows for the SAS to put a numeric suffix onto a standard body of a Data set name is actually worse than adding 2 underscores as a prefix to a very readable data set name which conveys some meaning as to what the data contains. Hell macros are hard enough for most programers adding the fact that it will now use some unknown data step names which have to...

Macro quoting #6
I am using DDE commands to pass info from SAS to Excel. How do I resolve the following macro put '[paste("r4c1:r&ac8")]'; to read put '[paste("r4c1:r2223c8")]'; FIA. ...

Visitor counter is stuck
I apologize in advance in case this is not the best place to post this. I have a visitor counter on my web page. It seems to be stuck on the same number of visitors. This only happens when i open the page in my Mac at home (OS 8.6, IE 5.0). I asked and a non-Mac person suggested that i get rid of the cache. I don't want to trash the wrong file. I did find something called "Download cache" under Explorer, under Preferences. Is this the file in question? Thanks!!! -- WHAT?!?! You haven't heard about BookCrossing.com yet? Go immediately to: http://bookcrossing.c...

CALL FOR PAPERS-The International Conference on Advances in Social Network Analysis and Mining (July 25-27 2011, Taiwan)
CALL FOR PAPERS The International Conference on Advances in Social Network Analysis and Mining (ASONAM 2011) July 25-27, 2011 - Kaohsiung City, Taiwan The study of social networks originated in social and business communities. In recent years, social network research has advanced significantly; the development of sophisticated techniques for Social Network Analysis and Mining (SNAM) has been highly influenced by the online social Web sites, email logs, phone logs and instant messaging systems, which are widely analyzed using graph theory and machine learning techniques. People ...

"Missing" macro values, was: Re: Macro Variable Problem #2
Hi Ron, Without splitting hairs I would say that a macro variable defined as: %LET MacroVar = ; has no value at all, thus is empty, with %length 0. While another macro variable, defined as: %LET MacroVar = %STR( ); contains a blank (space), with %length 1. SAS character variables, which have no value, at least contain a single space = blank. BTW, what colour does a space have? Is it transparent? Or is it white on white, or black on black, blank on blank? Maybe camouflaged like a chameleon ;-) Regards - Jim. P.S. What is the meaning of a blank space? Space? Nothing? Undetermined? Missing? Z...

[News] New Sites Strives to Advance Free/Libre Software, New Linux Gazette Released
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Announcing The-Source.com! ,----[ Quote ] | The basic idea is to promote and discuss FLOSS, with a bit more emphasis on | the Free aspect. There’s been a downright anti-Free / anti-ideals trending in | the FLOSS world for quite sometime, and some of us think the Freedom aspect | of FLOSS could use a little positive promotion. I especially welcome feedback | on topics you’d like to hear about, and suggestions on how to improve the | site quality! I’ve also enjoyed writing a lot, and The Source represents a | welcome chance for me to expand m...

Re: Macro Question #61
Thanks, I made a new catalog file that have the modifications I wanted to do. Have a nice day, Guido. ----- Original Message ----- From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM> To: <SAS-L@LISTSERV.UGA.EDU> Sent: Wednesday, September 26, 2007 8:46 PM Subject: Re: Macro Question > On Wed, 26 Sep 2007 10:23:14 -0300, Guido Sagasti > <guidosagasti@YAHOO.COM.AR> wrote: > >>Hello! >> >>Working with a SAS prg at a point I have a sas7bcat file and I want to > modify it (and see what's inside of it). How can I do...

FileMaker Server 7 Advanced will be available on Augut 9th, 2004. It might be available few days earlier. bogdan ...

Unique field and counter increment
Hello. I have been looking around in the documentation for the solution to my problem, but I have found nothing. I have a table lik this: test=# \d foo; Table "public.foo" Column | Type | Modifiers --------+------------------------+-------------------------------------------------- id | integer | not null default nextval('foo_id_seq'::regclass) val | character varying(255) | not null cnt | integer | default 1 Indexes: &...

Data Alignment Macros?
Can any of you gentlemen tell me what exactly are data alignment macros? I remember checking out the UPX source a while ago, reading about it in books, and have wondered every since. RagnarDanneskj�ld wrote: > > Can any of you gentlemen tell me what > exactly are data alignment macros? The only code I've seen for alignment, is the use of a union to align an array of char, with a more restrictive data type, as in K&R2, 8.7 -- pete "pete" <pfiland@mindspring.com> wrote in message news:4030C18F.33B8@mindspring.com... > RagnarDanneskj�ld wrote: > >...

Re: Macro will execute ,if value is not null,other wise end #5
Hi, All looks fine except for the concatenation characters. The string concatenation is two vertical bars (||), not the exclamation characters (!!). Change !! to || Hope this is helpful. Mark Terjeson Senior Programmer Analyst, IM&R Russell Investment Group Russell Global Leaders in Multi-Manager Investing -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Kuladeep Mittapalli Sent: Monday, October 02, 2006 1:07 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Macro will execute ,if value is not null,other wise end Hi, I have following co...

[PR] Custom publish without FM Server Advanced!
Is your wallet in DENIAL and you don't even live in Egypt? Pull up a chair at CAFEphp and RELAX! Now you can publish your custom site to the web without FileMaker Server Advanced http://www.cafephp.com/index.php Daytona Beach, Fl. - February 22, 2005- When you need information immediately, where do you turn? If you said the web, you get a cookie. FMWebschool believes that "custom" FileMaker web publishing should be available to everyone, just like your local Cafe. That is why we have spent the last 6 months developing CAFEphp. CAFEphp is a server that enables you to connect ...

Re: Compute macro variables #5
mahesh.tamboli@GMAIL.COM wrote back: > >David L Cassell wrote: > > mahesh.tamboli@GMAIL.COM wrote: > > > > > >Hi there, > > > > > >The code below does the following. Based on the current month computes > > >the year and month for the last 12 months and pulls the relevant data . > > >The code works, but the issue is the way it is coded. Since 2 new macro > > >variables need to be computed based on the current month date, a data > > >_NULL_ step is used. Here, I am trying to explore any other > > >altern...

Hi, Are you a solid programmer looking for a leadership opportunity? Stormfront Studios provides experienced and supportive management, a healthy team environment and a place where high standards are respected and contributions are recognized. Our new IP titles on Xbox360, PS3, Wii and PC need your talent! I work onsite for Stormfront and would be happy to talk with you further. Or, if you have anyone to refer you can ask me about our Friends of Stormfront Referral Bonus Program. Best, Marta Daglow mdaglow@stormfront.com Stormfront Studios 1600 Los Gamos Drive, Suite ...

Re: Idea for a collaborative talk
Peter I recommend the following papers for your review: 1. Hands-On Workshop List Processing Basics: Creating and Using Lists of Macro Variables * Ronald J. Fehd * Art Carpenter Tiny Url: http://tinyurl.com/5p3j2z for this page http://www.sascommunity.org/wiki/List_Processing_Basics_Creating_and_Usi ng_Lists_of_Macro_Variables http://tinyurl.com/6mmqpj for paper http://www2.sas.com/proceedings/forum2007/113-2007.pdf SGF 2007, paper 113, section: Hands On Workshops 2. SmryEachVar: A Data Review Suite For Each Variable in All Data Sets in a Libref paper http://www2.sas.com/proceedings/for...