home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / asc2app.zoo / asc2app.txt
Text File  |  1990-02-03  |  3KB  |  115 lines

  1. =============================app2asc===============================
  2.  
  3. #include <Types.h>
  4. #include <Memory.h>
  5. #include <HyperXCmd.h>
  6.  
  7. /* This program converts Apple Macintosh strings to ASCII format */
  8.  
  9. pascal void app2asc(paramPtr)
  10.     XCmdBlockPtr    paramPtr;
  11. {
  12.     unsigned char    c;
  13.     Ptr                str;
  14.     Handle            inHandle,outHandle;
  15.  
  16.     inHandle=paramPtr->params[0];
  17.     outHandle=NewHandle(strlen(*inHandle)+1);
  18.     
  19.     /* copy the contents of inHandle to outHandle with conversion */
  20.     for (str=*outHandle; (c=**inHandle)!=NULL; *(str++)=c, (*inHandle)++ )
  21.         switch (c) {
  22.             case '\237': c='~'; break;
  23.             case '\206': c='^'; break;
  24.             case '\214': c='}'; break;
  25.             case '\201': c=']'; break;
  26.             case '\212': c='{'; break;
  27.             case '\200': c='['; break;
  28.             case '\232': c='|'; break;
  29.             case '\205': c='\\'; break;
  30.             default: ;
  31.         };
  32.         
  33.     *str=NULL;
  34.     
  35.     paramPtr->returnValue=outHandle;
  36. }
  37.     
  38. /* C routines for HyperCard callbacks in the middle of execution */
  39. #include <XCmdGlue.inc.c>
  40.  
  41. ==============================asc2app==============================
  42.  
  43. #include <Types.h>
  44. #include <Memory.h>
  45. #include <HyperXCmd.h>
  46.  
  47. /* This program converts ASCII strings to Apple Macintosh format */
  48.  
  49. pascal void asc2app(paramPtr)
  50.     XCmdBlockPtr    paramPtr;
  51. {
  52.     unsigned char    c;
  53.     Ptr                str;
  54.     Handle            inHandle,outHandle;
  55.  
  56.     inHandle=paramPtr->params[0];
  57.     outHandle=NewHandle(strlen(*inHandle)+1);
  58.     
  59.     /* copy the contents of inHandle to outHandle with conversion */
  60.     for (str=*outHandle; (c=**inHandle)!=NULL; *(str++)=c, (*inHandle)++ )
  61.         switch (c) {
  62.             case '~': c='\237'; break;
  63.             case '^': c='\206'; break;
  64.             case '}': c='\214'; break;
  65.             case ']': c='\201'; break;
  66.             case '{': c='\212'; break;
  67.             case '[': c='\200'; break;
  68.             case '|': c='\232'; break;
  69.             case '\\': c='\205'; break;
  70.             default: ;
  71.         };
  72.         
  73.     *str=NULL;
  74.     
  75.     paramPtr->returnValue=outHandle;
  76. }
  77.     
  78. /* C routines for HyperCard callbacks in the middle of execution */
  79. #include <XCmdGlue.inc.c>
  80.  
  81. =======================sample make files===========================
  82.  
  83. app2asc.c.o D app2asc.make app2asc.c
  84.     C -q2 app2asc.c
  85.     
  86. app2asc DD app2asc.make app2asc.c.o
  87.     link -sn Main=app2asc -sn STDIO=app2asc -sn INTENV=app2asc 6
  88.         -m APP2ASC app2asc.c.o 6
  89.         "{CLibraries}"StdCLib.o 6
  90.         "{CLibraries}"CInterface.o 6
  91.         -rt XFCN=6 -o HyperCommands 
  92.  
  93.  
  94. asc2app.c.o D asc2app.make asc2app.c
  95.     C -q2 asc2app.c
  96.     
  97. asc2app DD asc2app.make asc2app.c.o
  98.     link -sn Main=asc2app -sn STDIO=asc2app -sn INTENV=asc2app 6
  99.         -m ASC2APP asc2app.c.o 6
  100.         "{CLibraries}"StdCLib.o 6
  101.         "{CLibraries}"CInterface.o 6
  102.         -rt XFCN=5 -o HyperCommands 
  103.  
  104.  
  105.  
  106.  
  107.  
  108. --
  109. :::: Arto Kojo :::::::::::::::::::::: Helsinki University of Technology ::::
  110. ::   TKK/TKO-lab/Y227                 ako@hutcs.hut.fi                    ::
  111. ::   02150 ESPOO FINLAND              s29808u@puukko.hut.fi               ::
  112. :::: tel: +358-0-4513236 :::::::::::: akojo@otax.tky.hut.fi ::::::::::::::::
  113.  
  114.  
  115.