home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-01 | 11.2 KB | 5 lines | [TEXT/MPS ] |
- Front end features of MacPerl Matthias Neeracher 03Dec94
-
- This file describes features only present in the MacPerl application, which
- are not directly related to the language itself.
-
- 1. USER INTERFACE
-
- This area is notoriously underdocumented. I can't give more than hints at the moment
- (I have a standing offer to write decent manuals if anybody researches and writes my
- PhD thesis for me :-):
-
- a) Online Help
-
- Selecting any perl operator and choosing Help from the Help menu (That's the question
- mark icon on the right side of the menubar) will give you chapter and verse from the
- Perl manual page.
-
- If you turn on Balloon Help and point at a Perl operator, a balloon will give you
- a summary of parameters to the operator.
-
- a) Menus
-
- MacPerl for the most part tries to behave like a typical primitive text editor.
- "Format" in the Edit menu presents a choice of text fonts and sizes. "Preferences"
- controls many settings, the most important of which is a list of library folders.
-
- "Jump to…" in the Edit menu allows to pop up files and lines based on the current
- selection. The following formats are supported:
-
- Format Example
- /File\s+["']([^"']+)["']\D*(\d+)/i File "om:mani:padme:hum", Line 23
- /["']([^"']+)["']\D*(\d+)/ "om:mani:padme:hum", Line 23
- /["']([^"']+)["']/ "om:mani:padme:hum"
- /.+/ om:mani:padme:hum
-
- 2. PACKAGES
-
- A MacPerl file can be saved in various forms, depending on what you choose
- from the popup menu in the "Save As..." dialog:
-
- - A plain text file. These can be opened from any text editor or word processor.
- - A droplet. This combines the script and some glue code into a "Mini-application".
- These will automatically run when double-clicked from the finder, and all files
- you drop on them in the Finder will appear in the @ARV array.
- - A runtime. While they in some respects behave like droplets, they are much more
- heavyweight and will set you back several 100K every time you save one. The
- advantage of runtimes is that they run without the MacPerl application.
- - Any other packaging you could think of. A MacHTTP package will appear in a few
- days. The release verson of MacPerl 4.1.4 will describe how to add packaging
- options to MacPerl.
-
- 3. APPLEEVENTS/APPLESCRIPT
-
- MacPerl has been scriptable and recordable since version 4.1.0. Most AppleEvents
- supported are the fairly conventional text events you'll find in the Scriptable
- Text Editor. In fact, MacPerl should support pretty much the same text manipulations
- as STE, except that STE generates somewhat prettier scripts when being recorded. If
- you find something working in STE and not in MacPerl, talk to me about it!
-
- The only two events that are somewhat special to MacPerl are Save and Do Script.
-
- Event: Save [core/save]
- Direct parameter: A window object reference [obj ], a file [fss ], or text [TEXT]
- "in" [dest] (opt): A file [fss ] to save in.
- "as" [fltp] (opt): A save type [svas] (standard types are Text [TEXT], Droplet [SCPT]
- and System 7 runtime [MrP7] or an enumeration cast to [svas]).
-
- This event does the same as the core save event, but it can also save files not open
- at the time and even on-the-fly text, and it can save in any package available. This
- is useful to e.g. save a file as a MacPerl droplet from another application.
-
- Event: "Do Script" [misc/dosc]
- Direct parameter: A file [fss ], text [TEXT] or a list of files and text.
- Reply: Text results, depending on mode.
- "extract" [EXTR] (opt): A boolean [bool] which when false prevents searching for a #! line.
- "debug" [DEBG] (opt):A boolean which when true runs the Perl debugger
- "mode" [MODE] (opt): A mode [MODE], one of Local [LOCL], Batch [BATC],
- Remote [RCTL], or Duplex [DPLX].
- "environment" [ENVT] (opt): A list of text [TEXT] variable/value pairs to add to the
- environment.
- [SASE] (opt): A record used as a callback event for remote mode.
-
- As opposed to the standard "Do Script" event, MacPerl's "Do Script" accepts a list as
- the direct parameter and stuffs all further elements into @ARGV. The mode parameter
- has a major influence on the way the script is executed:
-
- - Local mode is the default. The script just runs and only returns text if you call
- &MacPerl'Reply().
- - Batch mode redirects standard output and error to the reply apple event. Standard
- output is put into the direct parameter of the reply, while standard error is
- put into element [diag] of parameter [OUTP].
- - Remote control mode returns immediately from the DoScript request. Clients are
- then expected to communicate with MacPerl with "Send Data" [McPL/DATA] events.
- These contain standard input in the direct parameter and output as explained
- above. Furthermore, the 'WANT' parameter of the reply contains enumeration codes
- for all input descriptors awaiting input. Sending a null descriptor with any
- code signals an end of file for that file. MacPerl sets a boolean DONE parameter
- in its reply to signal the last data being sent. If you did specify a SASE parameter
- in your Do Script or Send Data events, it will be sent back to you the next
- time MacPerl waits for input.
- - Duplex is an often faster variant of Remote Control mode. The difference is that
- in Duplex mode, MacPerl will initiate I/O itself by putting actual data in the
- SASE events it sends out. Please see below for examples of interaction in Remote
- Control and Duplex mode.
- - Both Batch and Remote control/Duplex mode support opening further input and output
- streams as "Dev:AEVT:[4 byte code]". Standard input/output is "Dev:AEVT", standard
- error is "Dev:AEVT:diag". Note that these names are case sensitive!
-
- Furthermore, you can specify environment settings which will show up in %ENV in the
- environment parameter. If you specify a value for "PERLLIB", the library folders
- specified in the "Preferences…" dialog are appended to the value you specify.
-
- 4. REMOTE CONTROL vs. DUPLEX MODE
-
- To illustrate the workings of Remote Control and Duplex mode and their differences,
- here are to AppleEvent logs from PCGI glue doing a Server push.
-
- First, the older glue using RCTL mode:
-
- -----------------------------------------------------------------------------------
- #
- # The PCGI glue receives a request from WebStar:
- #
- 'WWWΩ'\sdoc{'----':'TEXT'(), kfor:“animate”, user:'TEXT'(), pass:'TEXT'(),
- frmu:'TEXT'(), addr:“192.33.93.95”, svnm:“neeracher.slip.ethz.ch”,
- svpt:“80”, scnm:“/Nu.acgi”, ctyp:'TEXT'(),
- refr:“http://neeracher.slip.ethz.ch/Nu.acgi”,
- Agnt:“Mozilla/2.0b6a (Macintosh; I; PPC)”, Kact:“ACGI”,
- Kapt:“/Nu.acgi”, post:'TEXT'(), meth:“GET”, Kcip:“192.33.93.95”,
- Kfrq:“GET /Nu.acgi?animate HTTP/1.0
- Referer: http://neeracher.slip.ethz.ch/Nu.acgi
- Connection: Keep-Alive
- User-Agent: Mozilla/2.0b6a (Macintosh; I; PPC)
- Host: neeracher.slip.ethz.ch
- Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
-
- ”, Kcid:13, &inte:cans, &timo:2147483647}
- #
- # The glue starts the Perl script in RCTL mode. Note how the header fields are passed
- # as environment variables:
- #
- misc\dosc{'----':[alis(«0000000000D8000200000…»)],
- MODE:RCTL, SASE:{evcl:McPL, evid:SASE},
- ENVT:[“SERVER_SOFTWARE”, “MacHTTP/2.0”,
- “GATEWAY_INTERFACE”, “CGI/1.1”,
- “SERVER_PROTOCOL”, “HTTP/1.0”,
- “QUERY_STRING”, “animate”,
- “REMOTE_ADDR”, “192.33.93.95”,
- “REQUEST_METHOD”, “GET”,
- “SERVER_NAME”, “neeracher.slip.ethz.ch”,
- “SERVER_PORT”, “80”,
- “SCRIPT_NAME”, “/Nu.acgi”,
- “HTTP_REFERER”, “http://neeracher.slip.ethz.ch/Nu.acgi”,
- “HTTP_USER_AGENT”, “Mozilla/2.0b6a (Macintosh; I; PPC)”,
- “HTTP_CONNECTION”, “Keep-Alive”,
- “HTTP_HOST”, “neeracher.slip.ethz.ch”,
- “HTTP_ACCEPT”, “image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*”]}
- #
- # Perl immediately replies:
- #
- aevt\ansr{}
- #
- # Now Perl wants to push the header. It does this by sending the SASE event back to
- # the glue:
- #
- McPL\SASE{}
- #
- # The glue sends an almost empty data event to MacPerl to provoke an answer:
- #
- McPL\DATA{INPT:{'----':“--More--
- ”}}
- #
- # Perl replies with the data:
- #
- aevt\ansr{'----':“HTTP/1.0 200 OK
- Server: MacHTTP/2.0
- MIME-Version: 1.0
- Content-Type: multipart/x-mixed-replace;boundary=EOM
-
- --EOM
- Content-type: text/plain
-
- 1
- ”, WANT:['----'], DONE:bool(«00»)}
- #
- # The glue sends the data back to WebStar. First it replies to the original WebStar
- # request with an announcement that the answer is going to arrive in multiple parts:
- #
- aevt\ansr{'----':“<SEND_PARTIAL>”}
- #
- # Now it sends the real data
- #
- 'WWWΩ'\SPar{'----':“HTTP/1.0 200 OK
- Server: MacHTTP/2.0
- MIME-Version: 1.0
- Content-Type: multipart/x-mixed-replace;boundary=EOM
-
- --EOM
- Content-type: text/plain
-
- 1
- ”, Kmor:bool(«01»), Kcid:13}
- #
- # Again, Perl wants to send more data:
- #
- McPL\SASE{}
- #
- # The glue asks Perl for more data:
- #
- McPL\DATA{INPT:{'----':“--More--
- ”}}
- #
- # Perl sends the data:
- #
- aevt\ansr{'----':“--EOM
- Content-type: text/plain
-
- 2
- ”, WANT:['----'], DONE:bool(«00»)}
- #
- # And the glue sends the data to WebStar
- #
- 'WWWΩ'\SPar{'----':“--EOM
- Content-type: text/plain
-
- 2
- ”, Kmor:bool(«01»), Kcid:13}
-
- -----------------------------------------------------------------------------------
-
- Now the newer glue in DPLX mode. Note how only one AppleEvent per push is exchanged
- between the glue and MacPerl, instead of two:
-
- -----------------------------------------------------------------------------------
-
- #
- # The PCGI glue receives a request from WebStar:
- #
- 'WWWΩ'\sdoc{'----':'TEXT'(), kfor:“animate”, user:'TEXT'(), pass:'TEXT'(),
- frmu:'TEXT'(), addr:“192.33.93.95”, svnm:“neeracher.slip.ethz.ch”,
- ... identical to RCTL case ...
- Connection: Keep-Alive
- User-Agent: Mozilla/2.0b6a (Macintosh; I; PPC)
- Host: neeracher.slip.ethz.ch
- Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
-
- ”, Kcid:15, &inte:cans, &timo:2147483647}
- #
- # The glue starts the Perl script in DPLX mode.
- #
- misc\dosc{'----':[alis(«...»)], MODE:DPLX, SASE:{evcl:McPL, evid:SASE},
- ENVT:[... identical to RCTL case ...]}
- #
- # Perl immediately replies:
- #
- aevt\ansr{}
- #
- # Now Perl wants to push the header. Again, it does this by sending the SASE event
- # back to the glue, but this time, it already includes the data:
- #
- McPL\SASE{'----':“HTTP/1.0 200 OK
- Server: MacHTTP/2.0
- MIME-Version: 1.0
- Content-Type: multipart/x-mixed-replace;boundary=EOM
-
- --EOM
- Content-type: text/plain
-
- 1
- ”, WANT:['----'], DONE:bool(«00»), &inte:cans, &timo:3600}
- #
- # The glue sends the data back to WebStar. First it replies to the original WebStar
- # request with an announcement that the answer is going to arrive in multiple parts:
- #
- aevt\ansr{'----':“<SEND_PARTIAL>”}
- #
- # Now it sends the real data
- #
- 'WWWΩ'\SPar{'----':“HTTP/1.0 200 OK
- Server: MacHTTP/2.0
- MIME-Version: 1.0
- Content-Type: multipart/x-mixed-replace;boundary=EOM
-
- --EOM
- Content-type: text/plain
-
- 1
- ”, Kmor:bool(«01»), Kcid:15}
- #
- # Now the glue confirms the pushed data to Perl
- #
- aevt\ansr{INPT:{'----':“--More--
- ”}}
- #
- # Again, Perl wants to send more data:
- #
- McPL\SASE{'----':“--EOM
- Content-type: text/plain
-
- 2
- ”, WANT:['----'], DONE:bool(«00»), &inte:cans, &timo:3600}
- #
- # And the glue sends the data to WebStar
- #
- 'WWWΩ'\SPar{'----':“--EOM
- Content-type: text/plain
-
- 2
- ”, Kmor:bool(«01»), Kcid:15}
- #
- # ... and confirms the pushed data to Perl
- #
- aevt\ansr{INPT:{'----':“--More--
- ”}}
-
- -----------------------------------------------------------------------------------
-