/* ViewArc.rexx*/
/*REXX script for DLG BB/OS to allow viewing of most popular ARCHIVE formats*/
/*
Written by Dale Roman - SysOp of InterStellar OverDrive DLG - (209)/942-2966
  More utilities * games * support for DLG is available online for SysOps.

This script also requires a script file in the DLGconfig:batch/  dir.
Name it 'ViewArchive.Batch'. It should already be there, but you should
modify it to read as follows: (Or something similar, DLG is easy to
modify, remember?)


.key filename/a                     
                                    
failat 100                          
c:rx doors:viewarc.rexx <filename>  
dlg:writelog -c 131 -d "<filename>"


Some notes about this script:
I have the 'rx' program in the C: directory.
I keep all of my archiving programs in a directory called COMP: You should
 change all reference to COMP: to whereever you have your ARC, ZOO, LHARC, etc
 programs.
I have a directory called doors (assigned as DOORS:) where I keep external
 programs that aren't officially part of DLG. I recommend doing it this way
 instead of putting EVERYTHING in DLG: or DLGConfig:  That way when you upgrade
 the DLG software things won't be as confusing.

Delete the comments in this script if you want. It may speed up a little.

I didn't include the archive programs. Most everyone should have them by now
if they are operating a BBS. But for any you don't have, just remark that
part of the script. The 'filetype' program is possibly one you dont have.

I didn't include checking for BREAK_C in this script. For whatever reason,
AREXX doesn't see the Control-C that DLG sends to end the program. From
what I can tell, AREXX is converting Control characters to NOTHING.

try this:

parse pull key
say key
say C2X(key)

Run from DLG, then Tkill the port & see what you get. I get ZILCH myself.
HOWEVER, you CAN detect the ENDCLI that DLG eventually sends. better than
nothing!

It doesn't matter in THIS script because there is no inputs. It will exit
eventually no matter what.
*/

address COMMAND
options results

signal on syntax
signal on ioerr

arg fname

exten = RIGHT(fname,3)

/* Use the DLG viewer */
if exten = 'LZH' | exten = 'ZOO' | exten = 'ZIP' | exten = 'ARC' then do
  'DLG:viewarchive ' || fname 
  call endprog
end

/* View & test Disk-masher files */
if exten = 'DMS' then do
  say 'Viewing...'
  'comp:dms view ' || fname
  say 'Testing...'
  'comp:dms test ' || fname
  call endprog
end

/* View self-extracting archives
NOTE: I thought about just EXECUTING the archive and putting the files in
      a temporary dir. Then just do a dir to show the files. BUT....
      What if a hacker uploads a hard disk formatter or something?
      When the program is ran it does it's dirty work. So I kept it like
      this. Useless, but safe.
*/
if exten = 'EXE' | exten = 'SDA' | exten = 'SFX' | exten = 'PAK' then do
  say 'This seems to be a self-extracting archive. I cannot view it online.'
  say ''
  say 'It will not require a seperate program to uncompress as it has one built in.'
  say 'Just type its filename from the CLI or SHELL & it should uncompress the files'
  say 'into the current directory.'
  say
  call endprog
end

/* View LHWARP files */
if exten = 'LHW' then do
  say 'This seems to be a LHWARP file. Use the LHWARP program to uncompress'
  say 'it onto a blank 80 track disk.  I cannot view it online.'
  say
  say 'NOTE: Different versions of LHWARP do not seem to be downward compatible'
  say '      with each other. IE: A .LZH file compressed using LHWARP V1.20 cannot'
  say '      be uncompressed with LHWARP V1.30'
  call endprog
end

/* View WARP files */
if exten = 'WRP' then do
  say 'This seems to be a WARP file. Use the WARP program to uncompress'
  say 'it onto a blank 80 track disk.  I cannot view it online.'
  say
  call endprog
end

/* View PowerPacker files (text files)
You -probably- could view these using the 'decrunch' program, but it
sometimes crashes with DLG. Probably when it tries to flash the screen or
something.
*/
if exten = '.PP' then do
  say 'This seems to be a PowerPacker file. Use the PowerPacker program to'
  say 'uncompress it.  I cannot view it online.'
  say
  call endprog
end

/* Use the 'filetype' program as a last ditch effort. */
say 'I cannot seem to recognize that type of file. Let me see if I can figure'
say 'it out.'
say
'so:filetype ' || fname
say
call endprog

endprog:
exit

IOERR:                                                        
   SAY '*BOOM*  Got an IO error.  PLEASE notify the sysop.'   
   SAY 'Line:' SIGL                                           
   'dlg:writelog -c 132 -d "ViewArc.rexx > Line:' || SIGL || '"'
exit                                                          
                                                              
SYNTAX:                                                       
   SAY '*BOOM*  Got a syntax error.  PLEASE notify the sysop.'
   SAY 'Line:' SIGL '   Error Code:' RC                       
   'dlg:writelog -c 132 -d "ViewArc.rexx > Line:' || SIGL || '"'
   'dlg:writelog -c 132 -d "ViewArc.rexx > Err:' || RC || '"'
exit
