Original_To:  BITNET%"I-AMIGA@UBVM.BITNET"
Newsgroups: bit.listserv.i-amiga
Date:         Mon, 7 Sep 1992 22:13:00 EDT
From:         BARNETTJ@SNYSYRV1.BITNET
Subject:      Re: Beginners Guide To AREXX

Thanks to Ernest Crvich for helping update and correct the errors I
Listed in my attempted at starting an AREXX teaching series of
messages (I realize that confusion often occurs whether someones
message is sarcastic or not.  Trust me...this is not sarcasm.  I
really do appreciate his help).

To continue the teaching....below is a script that I wrote in
retrospect very stupidly for ProWrite, intended to allow the
user to print out labels on the Avery Laser Label sheets such
that the user can specifcy where on the sheet any given label
should be printed.  In otherwords, if the first set of labels
on a sheet has been removed, rather than scraping the sheet,
you can say that you want a label to be printed at "position 4.":

OK...the stupidity in what I did in writting this script is
forget that you can set the number of columns that ProWrite
will divide a page into.  Thus, I took the very very complicated
approach, I set up an array as follows:  The avery laser sheets
have three rows across, and you can fit 5 10 point lines of
print for each label.  THus, to print at label position 2 across
and no other labels, data is entered into lines 2,5,8,11, and 14.
Now do to my poor thought in writting this, I probably lost some
people already.  Consider the following:

Line.1                Line.2                  line.3
Line.4                Line.5                  Line.6
Line.7                Line.8                  Line.9
Line.10               Line.11                 Line.12
Line.13               Line.14                 Line.15

If you would want data entered for the third label, data would
have to enter line.3,.6,.9.12, and .15.  Get it?

Now there is an easier way to set up an array that what I did,
as was pointed out in the previous post.  I, at this time, don't
know how to do it.  Perhaps someone can fill me in for future
scripts.  Remember, I am new at this too...and am attempting
to start this teaching series of postings on AREXX out of the
same despiration so many of us feel!

Anyway, you will note in the attached script that i have a
whole series of lines where I have data lines such as
Line.1=' ';Line.2=' ';

What I am attmpting to do here is set the default values
to something...a space...prior to entering the array.


Anyway...here is the script.  Remember that I am only uploading
this for teaching purposes and this script can be written
much much better than it is right now.  I have explained above
that I made my life more difficult by forgetting about the
column feature in ProWrite!

Here we go....


/* Labels */
/* the next line will open a prowrite template file set with the margins at the
max */
open "dh1:documents/miscellaneous/"label format""
/* Something I didn't tell you guys about */
/* Trace all will open a window so you can follow the execution of a script
and find errors */
Trace all
/* Roughly, Options results tells arexx to expect the status of particular
variables to be expected....remind me to explain fruther later */
options results
/* address 'ProWrite' is to tell arexx a port for Prowrite is being opened */
/* Unknown commands therefore should be checked through prowrite */
address 'ProWrite'
/* requesttext is a prowrite specific arexx command.  It will open a window*/
/* requesting the given information.   Program specific arexx commands */
/* are usually listed in the manuals */
requesttext "Please enter the number of labels:"
/* the next line is again specific for prowrite.  Prowrite sets rc to 0 if */
/* the OK button has been selected.  If it doesn't equal zero, then */
/* logically, cancel has been selected.  If that is the case, exit */
if rc~=0 then exit
/* same story with the next line.  Oh, arexx knows to use these commands */
/* should have data fed through because of the Options REsults command above */
number=result
requesttext "Enter the starting label number:"
if rc~=0 then exit
start = result
/* This is the beginning of my idiotic means of assigning */
/* each of the lines where data will  be entered to a blank */
/* there is a better way...I just don't know how to do it */
/* sorry............... */
/* also....semicolons allow more than one statement to be on a line */
/* it is equivalent to the use of the colon in basic for the same */
label.1=' ';label.2=' ';label.3=' ';label.4=' ';label.5=' '
label.6=' ';label.7=' ';label.8=' ';label.9=' ';label.10=' '
label.11=' ';label.12=' ';label.13=' ';label.14=' '
label.15=' ';label.16=' ';label.17=' ';label.18=' '
label.19=' ';label.20=' ';label.21=' ';label.22=' '
label.23=' ';label.24=' ';label.25=' ';label.26=' '
label.27=' ';label.28=' ';label.29=' ';label.30=' '
label.31=' ';label.32=' ';label.33=' ';label.34=' '
label.35=' ';label.36=' ';label.37=' ';label.38=' '
label.39=' ';label.40=' ';label.41=' ';label.42=' '
label.43=' ';label.44=' ';label.45=' ';label.46=' '
label.47=' ';label.48=' ';label.49=' ';label.50=' '
label.51=' ';label.52=' ';label.53=' ';label.54=' '
label.55=' ';label.56=' ';label.57=' ';label.58=' '
label.59=' ';label.60=' ';label.61=' ';label.62=' '
label.63=' ';label.64=' ';label.65=' ';label.66=' '
label.67=' ';label.68=' ';label.69=' ';label.70=' '
label.71=' ';label.72=' ';label.73=' ';label.74=' '
label.75=' ';label.76=' ';label.77=' ';label.78=' '
label.79=' ';label.80=' ';label.81=' ';label.82=' '
label.83=' ';label.84=' ';label.85=' ';label.86=' '
label.87=' ';label.88=' ';label.89=' ';label.90=' '
label.91=' ';label.92=' ';label.93=' ';label.94=' '
label.95=' ';label.96=' ';label.97=' ';label.98=' '
label.99=' ';label.100=' ';label.101=' ';label.102=' '
label.103=' ';label.104=' ';label.105=' ';label.106=' '
label.107=' ';label.108=' ';label.109=' ';label.110=' '
label.111=' ';label.112=' ';label.113=' ';label.114=' '
label.115=' ';label.116=' ';label.117=' ';label.118=' '
label.119=' ';label.120=' ';label.121=' ';label.122=' '
label.123=' ';label.124=' ';label.125=' ';label.126=' '
label.127=' ';label.128=' ';label.129=' ';label.130=' '
label.131=' ';label.132=' ';label.133=' ';label.134=' '
label.135=' ';label.136=' ';label.137=' ';label.138=' '
label.139=' ';label.140=' ';label.141=' ';label.142=' '
label.143=' ';label.144=' ';label.145=' ';label.146=' '
label.147=' ';label.148=' ';label.149=' ';label.150=' '
/* Select is neat.  It is sort of self explanatory by looking below */
/* the computer will look and see what statement is true of those */
/* listed below and proceed by setting the variable SLINE to
/* whatever the starting line position should be */
select
   when start<3 then sline=0
   when start<=6 then sline=15
   when start<=9 then sline=30
   when start<=12 then sline=45
   when start<=15 then sline=60
   when start<=18 then sline=75
   when start<=21 then sline=90
   when start<=24 then sline=105
   when start<=27 then sline=120
   when start<=30 then sline=135
/* otherwise tells arexx if the selects above don't apply do the following */
/* The select...when....otherwise must be ended with an 'end' as below to */
/* tell arexx that nothing else should be encluded in the select */
 otherwise
        say "sorry, invalid value for starting position!"
  end
/* // is a special form of division.  The division only reports the remainder */
/* thus 7//2 equals 1 */
begin=sline+(start//3)
/* The do loop I told you about in the previous message.  Think of the
for next loop of basic */
do z= 1 to number
    k=0
    do i= begin to (begin + 12) by 3
              k=k+1
              requesttext "Enter line "||K||" of address "||z
              if rc~=0 then exit
              label.i = result
              if label.i='' then label.i='  '
                        end
     Select
                When begin=1 then operator=2
                When begin=2 then operator=3
                When begin=3 then operator=16
                When begin=16 then operator=17
                When begin=17 then operator=18
                when begin=18 then operator=31
                When begin=31 then operator=32
                When begin=32 then operator=33
                When begin=33 then operator=46
                When begin=46 then operator=47
                When begin=47 then operator=48
                When begin=48 then operator=61
                When begin=61 then operator=62
                When begin=62 then operator=63
                When begin=63 then operator=76
                When begin=76 then operator=77
                When begin=77 then operator=78
                When begin=78 then operator=91
                When begin=91 then operator=92
                When begin=92 then operator=93
                When begin=93 then operator=106
                When begin=106 then operator=107
                When begin=107 then operator=108
                When begin=108 then operator=121
                When begin=121 then operator=122
                When begin=122 then operator=123
                When begin=123 then operator = 136
                when begin=136 then operator=137
                When begin=137 then operator=138
            otherwise
                     say "Macro Execution Failed!"

end
begin=operator
end

n=0
x=0
do r = 1 to 150
x=x+1
n=n+1
if n=16 then do
/* More ProWrite specific commands */
        newparagraph
        newparagraph
    n=0
    end
/* ascii 9 is ProWrite specific, telling Prowrite to do a tab */
ascii 9
type label.x
end
/* This I never got to work right, but illustrates a point.  Here I
/* am attempting to use a ProWrite specific command for the filled */
/* In template to be saved in a specialized directory.  Get the */
/* Idea of using arexx to automatic things? */
setpath "dh1:documents/labels/"
/* Finally, we print out the document! ProWrite Specific command again */
Print


Well that Is the illustration script.  It is complicated, I know.
But by looking at it, I hope it illustrates how to use
many arexx commands and using arexx to interface with a
free standing program.

If this helps people, I will do the same with other scripts that
I have written.  We can then divide up sections that people
do not understand, discuss them, and we can all learn from it.

Again, I realize that there is an AREXX list.  But in all
senses of the word....It is dead.  Very few people belong
because so little activity is present.

-Jordan
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU