[comp.sys.mac.hypercard] Query and Request of HyperCard Experts & Bill Atkinson

jlc@atux01.UUCP (J. Collymore) (11/16/88)

Please forgive this cross-posting, however, I hope that I will be able to
maximize my potential for getting a response to this query this way.

THE QUERY:

I need to know is there ANY way to, in essence, "pipe" (as UNIX does) one
command to another (i.e., use the output of one operation as the input to
another)?

For example, (for those of you not familiar with UNIX), say that you
wanted to look at a list of words (that was NOT in alphabetical order) that
someone had input, HOWEVER, you wanted to SEE the list in alphabetical order,
BUT you didn't want to change the person's file from the way it was.
Well, you could do the following:  cat wordfile | sort

Note:  "cat" is a UNIX command that prints out your the entire, specified file
       all at once.  "wordfile" is just the imaginary name of our imaginary file
       of words.  "|" is what is called a "pipe" in UNIX, which takes the
       output of the command on its left, and uses it as input to the command
       on its right.  And finally, the UNIX "sort" command which will (in this
       case) sort all the lines of words into alphabetical order.  "sort" is
       what's known as a "filter," (i.e., a program/command that can take its
       input from standard input, perform some operation on that input, and
       write the results to standard output).

The results of doing this would be that the output you'd see on your screen
would be an alphabetically sorted list, but the actual file would be unchanged.
If you had wanted a printout of this (momentarily) sorted list, you could have
typed in:  cat wordfile | sort | lp
(where "lp" is the UNIX command for your local "line printer").
This would simply have taken the output of your (temporarily) sorted list, and
"piped" its output to the local line printer (Note:  "lp" is another
filter-type command).

So ALL THIS leads me to my REAL question:  Are there filters and/or pipes
in HyperCard (HC)?

Specifically, I want to perform a sort on cards, and pass the sorted cards to
the "print" command.  My problem is, in part, that I have multiple backgrounds
in ONE stack.  For example, I may have 5 cards of one background (call it
"blue").  The problem is that after a sort is done, the 5 "blue" cards are no
longer in CONTIGUOUS order.  When I see my print, I see "blue," "blue," "red,"
"green," blue."  Five cards are printed, but I've discovered that a "sort"
command in HC will place the sorted cards back in the stack in a NON-CONTIGUOUS
order!  And since the current version of the HC "print" command DOES NOT allow
you to print by a specified background name, I can't seem to have sort AND print
(particularly "print with dialog") together in this format.  I can do a sorts
in my stack, OR a print (for a group of CONTIGUOUS cards) in my current
stack set-up BUT NOT BOTH!  This is a problem for me, because for my current
application, if I use a multiple stack set-up (which I did earlier) I will
use up ~102% more disk space!!

Does anyone know a way of scripting that will allow my print command to find
and print all the cards of ONE background, even if those cards are not in
contiguous order (so that I can perform sorts of a given background, and still
be able to print the sorted, NON-CONTIGUOUS cards later)?

If you do, please send me e-mail, or post your reply to the
comp.sys.mac.hypercard newsgroup.  Thanks.

THE REQUEST:

To Bill Atkinson, or anyone connected with Apple's HyperCard Development group:

In the next release of HyperCard, could you please:
1)  create a "pipe-like" function,
2)  could you make the "print" command and the "sort" command act as filters,
3)  could you make the "print cards or open printing" commands understand
    background names as acceptable arguments?

If any of you at Apple know a way that I can still accomplish my above task
with features currently available in version 1.2 of HyperCard, please send
me, or post, the solution or script.  I would GREATLY appreciate it.
Thank you for your help.


						Jim Collymore

c9c-ac@dorothy.Berkeley.EDU (Mike) (11/21/88)

I don't know if I completely understand, but I'll try to give a couple of
solutions.

First:
If you don't care what order the cards are in in the stack (ie it doesn't 
matter that it's blue, blue, green, red, blue) but only in the print-out,
you can open printing at the first card you want to print, save its ID, and 
just go to next card of this background and print it until you get back to 
the first card.  This will print all the cards in the background that you
opened the printing in.

Second:
Put another field in each background, and on newCard put the background
name in the field (it should probably be hidden).  Then when you sort,
sort first on what you actually want to sort, then sort on the field which
contains the name of the background.  This will essentially give you
a stack sorted in groups (all the blue cards together, and sorted with
respect to the field you wanted sorted, then the green, and then the red)
Then print it that way.

If this is not at all what you wanted, sorry, but I hope it helps.

Mike
(I have no employer)

jdevoto@well.UUCP (Jeanne DeVoto) (11/26/88)

The Mac OS doesn't include UNIX-like filters; however, you don't need them
for what you want to do. Use the "open printing" and "close printing" commands
to select the cards you want to print, as follows:

  on printThisBackground
    open printing  -- or use "open printing with dialog" if you want
                   -- the print stack dialog to come up
    repeat for the number of cards of this background
      print this card
      go to next card of this background
    end repeat
    close printing -- at this point the cards "marked" by the print commands
                   -- issued since "open printing" are sent to the printer
  end printThisBackground

jeanne a. e. devoto
well!jdevoto

dan@Apple.COM (Dan Allen) (11/28/88)

In article <799@atux01.UUCP> jlc@atux01.UUCP (J. Collymore) writes:
>I need to know is there ANY way to, in essence, "pipe" (as UNIX does) one
>command to another (i.e., use the output of one operation as the input to
>another)?

No.  MPW has pipes, HyperCard does not.

>Does anyone know a way of scripting that will allow my print command to find
>and print all the cards of ONE background, even if those cards are not in
>contiguous order (so that I can perform sorts of a given background, and still
>be able to print the sorted, NON-CONTIGUOUS cards later)?

Create a (perhaps hidden) background field, with the cards numbered 1 to
n.  Sort your stack, print it, and sort it back to the original order
with the numbering of the bg field.


>In the next release of HyperCard, could you please:
>1)  create a "pipe-like" function,
>2)  could you make the "print" command and the "sort" command act as filters,
>3)  could you make the "print cards or open printing" commands understand
>    background names as acceptable arguments?

Pipes are definitely a great feature, to be sure.  But the HyperCard
model of things currently doesn't support (internally) pipes in any
natural way.  We'll keep these suggestions in mind as we continue to
evolve and refine HyperCard.  Thanks for the input.

Dan Allen
Software Explorer
HyperCard Team
Apple Computer