home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / eainfo.zip / eaInfo.CMD next >
OS/2 REXX Batch file  |  1994-10-15  |  4KB  |  151 lines

  1. /* eaInfo.CMD v0.2                                         */
  2. /* Displays Subject, Keywords and Comments for the dropped */
  3. /* object.                                                 */
  4. /* dAc 10/94                                               */
  5. ObjectTitle = "eaINFO"
  6. wpsID = "<eaInformation>"
  7.  
  8. /* Load REXXUTIL */
  9.    call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  10.    call sysloadfuncs
  11.  
  12. /* Get drop validation code and Target file */
  13.    parse arg code TARGET
  14.  
  15. /* Get program's Name and location(home) */
  16.    parse source junk1 junk2 ProgramName
  17.    Home=SubStr(ProgramName,1,LastPos('\', ProgramName))
  18.    CMDname=SubStr(ProgramName,LastPos('\', ProgramName)+1)
  19.  
  20. /* if Object started without drop, display usage */
  21.    if (TARGET="") & (code='1') then do
  22.       call Instructions
  23.       exit
  24.       end 
  25.  
  26. /* Run for the first time. Create the Object with */
  27. /* validation flag (1) */
  28.    if code<>"1" then do
  29.       call Create 1
  30.       call SysSetObjectData wpsID, "OPEN=DEFAULT;"
  31.       exit
  32.       end
  33.  
  34. /* Get Information from TARGET's EAs */
  35. /* -- Subject -- */
  36.    Subject=Read(".subject")
  37.    if Subject="" then
  38.       Subject="No Subject"
  39.    else
  40.       Subject=CleanUp(Subject," ")
  41.  
  42. /* -- Key Phrases -- */
  43.    KeyPhrases=Read(".keyphrases")
  44.    if KeyPhrases="" then
  45.       KeyPhrases=" none"
  46.    else
  47.       KeyPhrases=CleanUp(KeyPhrases,",")
  48.  
  49. /* -- Comments -- */
  50.    Comments=Read(".comments")
  51.    if Comments="" then
  52.       Comments="...No Comments found"
  53.    else
  54.       Comments=CleanUp(Comments," ")
  55.  
  56.    Body="Keys: "KeyPhrases||'0a'x'0d'x||,
  57.    "Comments:"||'0a'x||,
  58.    "──────────────────────────────────"||'0a'x||Comments
  59.  
  60.    Subject="════════════════════ "Subject||,
  61.           " ════════════════════"
  62.  
  63. /* Display Message box */
  64.    call rxMessageBox Body, Subject, OK, INFORMATION
  65. exit
  66.  
  67. /*---------------------- SUBROUTINES ----------------------*/
  68. /*-------- Get EA field -----------------------------------*/
  69. READ:
  70.    parse arg field
  71.    if SysGetEA(TARGET,field,"rawEA") = 0 then
  72.    /* parse past binary info */
  73.    if field=".comments" | field=".keyphrases" then
  74.       parse var rawEA 11 EAstring
  75.    if field=".subject" then
  76.       parse var rawEA 5 EAstring
  77.    return EAstring
  78.  
  79. /* EA stuff 
  80.    .type needs 11
  81.    .subject needs 5
  82.    .comments needs 11
  83.    .keyphrases 11 first
  84. */
  85.  
  86. /*-------- Remove extra spaces and bad characters ---------*/
  87. CleanUp:
  88.    parse arg DirtyString,Separator
  89.    Index=0
  90.    DirtyString=ASCIIstrip(DirtyString)
  91.    WordNumber=WORDS(DirtyString)
  92.    do while Index < WordNumber
  93.       Index=Index+1
  94.       goodWord=STRIP(WORD(DirtyString,Index))
  95.       if Index=1 then
  96.          Clean = goodWord
  97.       else
  98.          Clean = Clean||Separator||goodWord
  99.       end
  100.    return Clean
  101.  
  102. /*-------- Remove unrecognizable characters ---------------*/
  103. ASCIIstrip:
  104.    parse arg BadString
  105.    GoodString=""
  106.    Position=0
  107.    do length(BadString)
  108.       Position=Position+1
  109.       char=C2D(SUBSTR(BadString,Position,1))
  110.       if char>31 & char<126 then
  111.          GoodString=GoodString||D2C(char)
  112.       else
  113.          GoodString=GoodString" "
  114.    end
  115.    return GoodString
  116.  
  117. /*-------- Create/Recreate program object -----------------*/
  118. Create:
  119.    parse arg Mode
  120.    rc=SysCreateObject("WPProgram",ObjectTitle,"<WP_DESKTOP>",,
  121.       "OBJECTID="wpsID";"||,
  122.       "ICONFILE="Home"eaInfo.ICO;"||,
  123.       "EXENAME=PMREXX.EXE;"||,
  124.       "PARAMETERS="CMDname Mode";"||,
  125.       "STARTUPDIR="Home";"||,
  126.       '', R);
  127.    If rc<>1 Then Say "Object could not be created/updated !"
  128.    return rc
  129.  
  130. /*-------- Display Instruction dialog/View ReadMe ---------*/
  131. Instructions:
  132.    Heading="█████████████ Instructions █████████████"
  133.    Message='Please Drag and Drop the file you'||,
  134.    ' wish to examine on the "'ASCIIstrip(ObjectTitle)'" object.'||,
  135.    '0a'x'0d'x'Would you like to view the "'ObjectTitle'" Read me?'
  136.  
  137.    rc = rxMessageBox(Message,Heading,YESNO,QUESTION)
  138.    if rc=6 then do
  139.       rc=SysCreateObject("WPProgram","Temp eaREADME","<WP_NOWHERE>",,
  140.       "OBJECTID=<TEMPeaREADME>;"||,
  141.       "EXENAME=cmd.exe;"||,
  142.       "PROGTYPE=WINDOWABLEVIO;"||,
  143.       "MAXIMIZED=YES;"||,
  144.       "NOAUTOCLOSE=NO;"||,
  145.       "PARAMETERS=/c more < "Home"eaReadMe.TXT;"||,
  146.       "STARTUPDIR="Home";", U)
  147.       call SysSetObjectData "<TEMPeaREADME>", "OPEN=DEFAULT;"
  148.       call SysSetObjectData "<TEMPeaREADME>", "OPEN=DEFAULT;"
  149.       end
  150.    return
  151.