NISUS Archives

May 2011

NISUS@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Philip Spaelti <[log in to unmask]>
Reply To:
Date:
Tue, 31 May 2011 09:51:13 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (56 lines)
Hello Žorvaršur,

Bob is essentially correct. NWP macro doesn't allow more than one operation on a line.
There are a few tricks that allow you to cheat this limit a little bit, but basically that is the limitation.

So in your line:
>> Type text $startNumber+1 & '.    '

You are trying to increase $startNumber and concatenate the result with the string '.    ', that's two operations. So no go.
Also as Bob said your variable $startNumber is not well named, but more to the point if you write 

>> Type text $startNumber+1

you are presumably trying to increase $startNumber, but by doing it that way you lose the increase. Next time you ask for $startNumber it will still be 1, not '+1'. The most "logical" way to increase variables in NWP syntax is to do it like this:

$variable += 1

So, adopting Bob's renaming suggestion, for you case you might write it like this:

> $rowNumber = 1 # this is the 'start number'

> $rowNumber += 1 # increase the row number by 1
> Type text $rowNumber & '.    ' # print out the row number followed by a period and 4 spaces


Another way to write the 'Type' line is this

> Type text "$rowNumber.    "

By using double quotes you can get interpolation. So NWP first 'figures out' what is in the quotes and then types it. In this case it figures out what $rowNumber is  then it types the value followed by '.    ' Interpolation is one of those place where you get to cheat the one operation limit a little bit, though here it isn't really necessary.

Just some ideas
Philip

On 31. May 2011, at 6:51 , Bob Stern wrote:

>> Žorvaršur Davķšsson wrote:
>> 
>> Type text $startNumber+1 & '.    '
>> 
>> then I get an error. Obviously & is not the sign to be used. What am I supposed to use then instead?
> 
> 
> I'm not a macro expert, but sometimes the NWP macro language does not accept compound statements.  Try something like:
> 
> $rowText = $startNumber & '.    '
> Type text $rowText
> 
> Incidentally, your variable name $startNumber is confusing because you are incrementing it so that it actually becomes the current row number, not the start number.  You might want to rename it as $rowNumber.
> -- 
> 
> Bob Stern

Philip Spaelti
[log in to unmask]

ATOM RSS1 RSS2