home *** CD-ROM | disk | FTP | other *** search
/ Netscape Plug-Ins Developer's Kit / Netscape_Plug-Ins_Developers_Kit.iso / CGIPERL / MACPERL / MSRCE418.HQX / Perl Source ƒ / MacPerl / MacPerl.Specifics < prev    next >
Encoding:
Text File  |  1994-12-27  |  9.3 KB  |  259 lines

  1. Specific language features of MacPerl                Matthias Neeracher 27Dec94
  2.  
  3. This file describes differences between MacPerl and a typical Unix perl
  4. implementation. Much of this information can also be found at the end of
  5. PerlHelp. If you have 411, search for Perl╔Macintosh╔Extensions.
  6.  
  7. 1. VARIA
  8.  
  9. All time related functions measure time in seconds from 1904, not 1970 as in
  10. Unix.
  11.  
  12. "\n" on a Mac means ASCII 13, as opposed to Unix, where it means ASCII 10.
  13.  
  14. Pathnames are specified as:
  15.  
  16. volume:folder:file                for absolute pathnames
  17. :folder:file                        for relative pathnames
  18. :file                                    for relative pathnames
  19. file                                    for relative pathnames
  20.  
  21. MacPerl has a limited capability to handle constructs like `command` or
  22. open(F, "|command"), if you are the lucky owner of ToolServer. Additionally, whether
  23. you have toolserver or not, `pwd` and `Directory` (case is significant) always return
  24. the current directory, followed by a newline.
  25.  
  26. 2. SOCKETS
  27.  
  28. MacPerl has more Socket families than Unix Perl. Additionally, there is a call
  29. choose() to allow the user to interactively specify addresses or file names. As
  30. there are lots of rather complicated data types, there is a library header "GUSI.ph"
  31. which defines packing/unpacking procedures.
  32.  
  33. Choose() is called as follows:
  34.  
  35. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT,FLAGS,DEFAULT)
  36. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT,FLAGS)
  37. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT)
  38. &MacPerl'Choose(DOMAIN,TYPE,PROMPT)
  39.          Puts up a modal dialog prompting the user to choose an address. 
  40.          DOMAIN specifies the communication domain, like for socket().
  41.          TYPE may be used by future communication domains to further 
  42.          differentiate within a domain, but is ignored by current domains. 
  43.          PROMPT is a message that will appear in the dialog. CONSTRAINT may 
  44.          be set to a suitable packed value to restrict the types of acceptable
  45.          addresses.
  46.  
  47.          Examples:
  48.  
  49.          require "GUSI.ph";
  50.          
  51.          $file = 
  52.             &MacPerl'Choose(
  53.                &GUSI'AF_FILE, 0, "", 
  54.                &GUSI'pack_sa_constr_file("OBJ ", "TEXT"));
  55.                             
  56.                             Return the full pathname of an existing text
  57.                             or MPW object file.
  58.          
  59.          $dir = &MacPerl'Choose(&GUSI'AF_FILE, 0, "", "", &GUSI'CHOOSE_DIR);
  60.  
  61.                             Return the full pathname of an existing directory.
  62.                             
  63.          $file = 
  64.             &MacPerl'Choose(
  65.                &GUSI'AF_FILE, 0, "", "", 
  66.                &GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT, "yo");
  67.  
  68.                             Return the pathname of a new file to be created.
  69.                                      
  70. Socket families are:
  71.  
  72. Internet:
  73.  
  74. Packing addresses:    &GUSI'pack_sockaddr_in(family, address, port)
  75. Unpacking addresses:    (family, address, port) = &GUSI'unpack_sockaddr_in(addr)
  76. Choose:                    Not available.
  77.  
  78. Unix:
  79.  
  80. Packing addresses:    &GUSI'pack_sockaddr_un(family, path)
  81. Unpacking addresses:    (family, path) = &GUSI'unpack_sockaddr_un(addr)
  82. Choose:                    choose(&GUSI'AF_UNIX, 0, "", "", 0, "");
  83.                             looks up an existing address.
  84.                             choose(
  85.                                 &GUSI'AF_UNIX, 0, "Yes ?", "", 
  86.                                 &GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT, "yo");
  87.                             creates a new address.
  88.                             No constraints may be specified.
  89.  
  90. Appletalk (ADSP):
  91.  
  92. Packing addresses:    &GUSI'pack_sockaddr_atlk(family, net, node, socket)     (numerical)
  93.                             &GUSI'pack_sockaddr_atlk_sym(family, obj, type, zone)    (symbolic)
  94. Unpacking addresses:    (family, net, node, socket) = &GUSI'unpack_sockaddr_atlk(addr)
  95.                             (family, obj, type, zone) = &GUSI'unpack_sockaddr_atlk_sym(addr)
  96. Choose:                    choose(&GUSI'AF_APPLETALK, 0, "Eh ?", 
  97.                                 &GUSI'pack_sa_constr_atlk("LaserWriter", "GorillaWriter"),
  98.                                 0, "");
  99.                             looks up an existing address.
  100.                             New addresses may not currently be created with choose.
  101.  
  102. PPC Toolbox:
  103.  
  104. Packing addresses:    &GUSI'pack_sockaddr_ppc(family, type, name, porttype)
  105. Unpacking addresses:    Not available.
  106. Choose:                    choose(&GUSI'AF_PPC, 0, "Eh ?", 
  107.                                 &GUSI'pack_sa_constr_ppc("Gonkulator"),
  108.                                 0, "");
  109.                             looks up an existing address.
  110.                             New addresses may not currently be created with choose.
  111.  
  112.  
  113. 3. ADDITIONAL FUNCTIONS AVAILABLE IN MACPERL
  114.  
  115. &MacPerl'Answer(PROMPT)
  116. &MacPerl'Answer(PROMPT,BUTTON1)
  117. &MacPerl'Answer(PROMPT,BUTTON1,BUTTON2)
  118. &MacPerl'Answer(PROMPT,BUTTON1,BUTTON2,BUTTON3)
  119.           Presents to the user a dialog with 1, 2, or 3 buttons. 
  120.           
  121.           Examples:
  122.           
  123.           &MacPerl'Answer("Nunc et in hora mortis nostrae", "Amen");
  124.                               
  125.                             always returns 0.
  126.                             
  127.           &MacPerl'Answer("I refuse");
  128.           
  129.                               is equivalent to &MacPerl'Answer("I refuse", "OK");
  130.           
  131.           &MacPerl'Answer("Delete hard disk ?", "OK", "Cancel");
  132.                   
  133.                             returns 1 for OK, 0 for Cancel
  134.         
  135.           &MacPerl'Answer("Overwrite existig file", "Overwrite", "Skip", "Cancel");
  136.               
  137.                             returns 2 for Overwrite, 1 for Skip, 0 for Cancel
  138.                                      
  139. &MacPerl'Ask(PROMPT, DEFAULT)
  140. &MacPerl'Ask(PROMPT)
  141.           Asks the user for a string. A default value may be given. Returns
  142.           undef if the dialog is cancelled.
  143.           
  144.           Example:
  145.           
  146.           $phone = &&MacPerl'Ask("Enter your phone number:");
  147.           $name = &&MacPerl'Ask("Enter your first name", "Bruce");
  148.           
  149.                             Useful for Australian database applications
  150.                                      
  151. &MacPerl'Pick(PROMPT, VALUES)
  152.           Asks the user to pick a choice from a list. VALUES is a list of choices. 
  153.           Returns undef if the dialog is cancelled.
  154.           
  155.           Examples:
  156.           
  157.           $color = &MacPerl'Pick("What's your favorite color baby ?", "Red", "Green", "Gold");
  158.              
  159. &MacPerl'SetFileInfo(CREATOR,TYPE,FILE...)
  160.             Changes the file types and creators of the file(s).
  161.  
  162.             Examples:
  163.  
  164.             &MacPerl'SetFileInfo("MPS ", "TEXT", yin, yang);
  165.  
  166.                                     Turn yin and yang into MPW text files
  167.  
  168. &MacPerl'GetFileInfo(FILE)
  169.             In scalar context, returns the file type. In array context, returns
  170.             (creator,type).
  171.  
  172.             Examples:
  173.  
  174.             &MacPerl'GetFileInfo(yin);
  175.  
  176.                                     Returns "TEXT" or ("MPS ", "TEXT").
  177.  
  178. &MacPerl'DoAppleScript(SCRIPT)
  179.             Execute an AppleScript script.
  180.             
  181.             Example:
  182.             
  183.             &MacPerl'DoAppleScript(<<END_SCRIPT);
  184. tell application "MacPerl"
  185.     make new Window
  186.     copy "Inserting text the hard way." to character 1 of front Window
  187. end tell
  188. END_SCRIPT
  189.  
  190. &MacPerl'Reply(ANSWER)
  191.             Reply to current DoScript request. Useful if you are calling Perl 
  192.             scripts from other applications.
  193.             
  194. &MacPerl'Quit(LEVEL)
  195.             If LEVEL is 0, don't quit after ending the script. If 1, quit if 
  196.             running under a runtime version, if 2, always quit. If LEVEL is 3,
  197.             quit if this was the first script to be run since starting MacPerl.
  198.  
  199. &MacPerl'LoadExternals(LIBFILE)
  200.             Load XCMD and XFCN extensions contained in file LIBFILE, which is searched
  201.             along the same path as it would be for a require. The extensions are made
  202.             accessible in the current package, unless they conatin an explicit package
  203.             name.
  204.  
  205. &MacPerl'DebugExternals(DEBUGLEVEL)
  206.             If DEBUGLEVEL is 0, don't print any debug information for XCMDs and XFCNs. 
  207.             If 1, print information for unimplemented callbacks. If 2, print 
  208.             informations for all callbacks.
  209.  
  210. &MacPerl'FAccess(FILE, CMD, ARGS)
  211.             When called from the tool, manipulate various information of files. To 
  212.             get the command constants, it's convenient to require "FAccess.ph".
  213.  
  214.     $TAB = &MacPerl'FAccess(FILE, &F_GTABINFO)
  215.     &MacPerl'FAccess(FILE, &F_STABINFO, TAB)
  216.             Manipulate tabulator setting (in spaces per tab).
  217.             
  218.     ($FONTNAME, $FONTSIZE) = &MacPerl'FAccess(FILE, &F_GFONTINFO)
  219.     $FONTNUM = &MacPerl'FAccess(FILE, &F_GFONTINFO)
  220.     &MacPerl'FAccess(FILE, &F_SFONTINFO, FONT [, SIZE])
  221.             Manipulate font and size information. Both font names and font numbers
  222.             are accepted for F_SFONTINFO; F_GFONTINFO returns a font name in an
  223.             array context, a font number in a scalar context.
  224.             
  225.     ($STARTSEL, $ENDSEL, $DISPLAYTOP) = &MacPerl'FAccess(FILE, &F_GSELINFO)
  226.     $STARTSEL = &MacPerl'FAccess(FILE, &F_GSELINFO)
  227.     &MacPerl'FAccess(FILE, &F_SSELINFO, $STARTSEL, $ENDSEL [, $DISPLAYTOP])
  228.             Manipulate the MPW selection of a file.
  229.             
  230.     ($LEFT, $TOP, $RIGHT, $BOTTOM) = &MacPerl'FAccess(FILE, &F_GWININFO)
  231.     $TOP = &MacPerl'FAccess(FILE, &F_GWININFO)
  232.     &MacPerl'FAccess(FILE, &F_SWININFO, LEFT, TOP [, RIGHT, BOTTOM])
  233.             Manipulate the window position.
  234.  
  235. &MacPerl'MakeFSSpec(PATH)
  236.             This command encodes a path name into an encoding (volume #, directory #,
  237.             File name) which is guaranteed to be unique for every file. Don't store
  238.             this encoding between runs of MacPerl!
  239.  
  240. &MacPerl'MakePath(FSSPEC)
  241.             The inverse of &MacPerl'MakeFSSpec(): turn an encoding into a path name.
  242.  
  243. &MacPerl'Volumes()
  244.             In scalar context, return the FSSPEC of the startup volume. In list
  245.             context, return FSSPECs of all volumes.
  246.  
  247. 4. MACPERL SPECIFIC LIBRARIES
  248.  
  249. StandardFile.pl   Calls for standard file dialogs. A very convenient front end
  250.                   for &MacPerl'Choose()
  251.                         
  252. FindFolder.pl     Returns the path names of special folders (System, Preferences).
  253.  
  254. CommConnect.pl    Library for accessing the serial port.
  255.  
  256. GUSI.ph           Definitions for socket related calls.
  257.  
  258. FAccess.ph        Definitions for &MacPerl'FAccess() (MPW tool only).
  259.