Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

88 Levels

Status
Not open for further replies.

sKrEwBaLL

Programmer
Aug 20, 2001
8
GB
Hello there.

I am very new to programming so I will apologise in advance if I am being completely thick here.

I am writing a program to generate a postscript file to be sent to a printer. The postscript co-ordinates live in working storage so that text can be added and written to the output file.

The problem is that theer can be 3 sizes of print (A3/A4/A5), and therefore the postscript co-ordinates for each of these differ.

I was hoping (rather optimistically) to do this:

WORKING-STORAGE SECTION.

01 W100-LARGEPRICE-X.
03 W100-X-FILLER-1 PIC (21).
88 SIZE-IS-A3 VALUE '0 30 30 Z 200 160 m ('.
88 SIZE-IS-A4 VALUE '0 25 25 Z 190 158 m ('.
88 SIZE-IS-A5 VALUE '0 20 20 Z 180 156 m ('.
03 W-100-PRICE PIC 9.
03 W100-X-FILLER-2 PIC (21).
88 SIZE-IS-A3 VALUE ') 19 19 Z 210 160 m (P)'.
88 SIZE-IS-A4 VALUE ') 17 17 Z 200 158 m (P)'.
88 SIZE-IS-A5 VALUE ') 16 16 Z 190 156 m (P)'.

01 W110-LARGEPRICE-XX.
03 W110-X-FILLER-1 PIC x(17).
88 SIZE-IS-A3 VALUE 'more postscript...'.
88 SIZE-IS-A4 VALUE 'more postscript...'.
88 SIZE-IS-A5 VALUE 'more postscript...'.
03 W110-PRICE PIC 99.
03 W110-X-FILLER-2 PIC (17).
88 SIZE-IS-A3 VALUE 'more postscript...'.
88 SIZE-IS-A4 VALUE 'more postscript...'.
88 SIZE-IS-A5 VALUE 'more postscript...'.

........ more of the same .......

PROCEDURE DIVISON.

EVALUATE W200-USERS-CHOICE
WHEN 1
SET SIZE-IS-A3 TO TRUE
WHEN 2
SET SIZE-IS-A4 TO TRUE
WHEN OTHER
SET SIZE-IS-A5 TO TRUE
END-EVALUATE


I was hoping I could do this so I could set up the correct co-ordinates in one go. The compiler did not object to the declarations, but it objected to the SET TO TRUE as the 88 levels are not uniquely defined data names.

Is there any way round this, or does anyone have any better ideas..... I want to avoid:

1. Hard coding the postscript stuff in MOVE statements
2. Giving each 88 level a unique name as there are lots of them.
3. Having 3 seperate areas of working storage, one for each size.

Any help would be greatly appreciated.

Regards
 
To my knowledge, your coding would only work if the 88 level data names are unique. It cannot tell which size-is-A3 should be set to true.

Try making similar but unique names such as 110-size-is-A3 or something.

Another way would be to create a separate value with three level 88's with the names A3,A4, and A5 with values of 1,2, and 3. Then set these to true as needed. You may be able to skip this step if W200-USERS-CHOICE is an array with the values of 1,2, or 3.

Then in the rest of your fields, have them as an array corresponding to the A3,A4,A5 format.
i.e. W110-largeprice-XX (3) has the value of ') 16 16 Z 190 156 m (P)'. like you want.
 
Hi,

use qualifications, so tell to what group your 88 belongs...

SET SIZE-IS-A5 in W100-X-FILLER-2 TO TRUE.

Regards,

Crox
 
I can't come up with a solution as neat as the one you'd like, but you might think about creating a table with three rows in it; each row containing entries W100-X-FILLER-1, W100-X-FILLER-2, etc., which redefines a chunk of W-S with all of the postscript for A3, followed by all of the postscript for A4, followed by A5.

Then you could say:

MOVE CORRESPONDING W100-LARGE-TABLE(PRINT-SIZE) TO W100-LARGEPRICE-X.

The compiler could then sort out all of the necessary moves. I haven't tried this so I can't guarantee it, and your values for one bit of ps will be scattered in three different places, but it would satisfy your first two criteria. Remember that all of the intermediate levels below the 01 level need to match up for CORRESPONDING to work.

Good luck.
 
Hi SB,

It looks like you have 2 variables here: # of digits in the price & the size#.

You get the size from the user. You didn't mention how the price size is determined. So my suggestion may be a little vague in spots.

My solution may be confusing since you're just starting out, but I really don’t see an easy solution.

I'd use the STRING stmt and a 2 dimensional table, something like this:

Code:
01 W100-POSTCRIPT-TBL-VALUES.
      05  W100-ONE-NINE-PRICE.
            10  SIZE-1-PRE    PIC X(21) VALUE '0*30*30*Z*200*160*m*('.
            10  SIZE-1-POST   PIC X(21) 
VALUE ')*19*19*Z*210*160*m*(P)'.
            10 SIZE-2-PRE     PIC X(21) VALUE '0*25*25*Z*190*158*m*('.
            10 SIZE-2-POST    PIC X(21) 
VALUE ')*17*17*Z*200*158*m*(P)'.
            10 SIZE-3-PRE     PIC X(21) VALUE '0*20*20*Z*180*156*m*('.
            10 SIZE-3-POST    PIC X(21) 
VALUE ') *6*16*Z*190*156*m*(P)'.

      05  W100-TWO-NINE-PRICE.
           10  SIZE-1-PRE    PIC X(21)   
VALUE ‘'more postscript...'.
           10  SIZE-1-POST   PIC X(21)    
VALUE ‘'more postscript...'.
      
               etc.





01 W100-POST-SCRIPT-TBL      REDEFINES 
   W100-POST-SCRIPT-TBL-VALUES.   
     05  PRICE-NINES-COUNT OCCURS 3 TIMES.
            10  WS-PRE-POST-SCRIPTS OCCURS 3 TIMES.
                   15   WS-PRE-SCRIPT                         PIC X(21).
                   15   WS-POST-SCRIPT                      PIC X(21).

Some notes on the table. You’ll notice I changed the length of the 2nd script from 17 to 21. Table elements must all be of equal length. You’ll also notice that I changed all the spaces to (*). I’ll explain:

I plan to use the STRING stmt to construct the output recs. The 17 byte scripts in the 21 byte fields will be padded with trailing blanks. These can be used to delimit the field to 17 positions when the STRING stmt is executed. If the spaces separating the fields were left in, I couldn’t do that. The (*) can be returned to spaces using an INSPECT stmt later.

So, now for the climax: <G>

move the size# to WS-SIZE
move the # of 9s in the price field to WS-NINES
compute price WS-OFFSET = LENGTH OF WS-PRICE - WS-SIZE

Code:
STRING WS-PRE-SCRIPT (WS-NINES  WS-SIZE)  DELIMITED BY SPACE
       WS-PRICE      (WS-OFFSET:WS-SIZE)  DELIMITED BY SIZE
       WS-POST-SCRIPT(WS-NINES  WS-SIZE)  DELIMITED BY SPACE
 INTO WS-OUT-REC
END-STRING

INSPECT OUT-REC REPLACING ALL ‘*’ BY SPACES


I used ’*’ as a temporary separator; you can use any char that you’re sure is not used as “data” by Postscript.
BTW, I counted the Chars in the 21 byte field and I came up w/23. I know spacing can be a prob.

HTH, Jack.



 
SB,

Iforgot 1 point. You only need 1 price field with a PIC containing the max # of 9s you will encounter. The compute will assure the move of the appropriate price to the O/P rec.

Jack
 
Thanks a million for the responses. I will try these solutions out today and let you know which works best!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top