/* Suffer 1.0 (c) by Marcel Doering (DonDoringo@XOX.commo.mcnet.de)
   Supplemental-Arexx-Script for HippoPlayer (c) by K-P Koljonen

   This script requests the name of the playing module from HiP and
   then switches the suffix. For example if the name is
   Modules:test.mod the module`s new name will be modules:mod.test.
   This also works vice versa.

   Greets to Kari Pekka Koljonen for sending me this idea.

   REQUiREMENtS:
   -------------

   Amiga, 1 Meg of free RAM, HiPPOPlAYER by K-P Koljonen,
   RexxTricks.library 38.4 and better, RexxReqTools.library,
   RexxSupport.library, some Soundmodules, little bit of brain.
   Steer it all togehter and mix really hard, there you go,
   this is 'Suffer'. ;)

   CREDiTS:
   --------

   'Suffer' was written on an AMIGA 1200/030/50MHz, OS 3.1
   with 18 MByte RAM. It was tested on an AMIGA 4000,
   OS 3.1, Cyberstorm 060` and Cybergraphics, together with
   34 Meg of RAM.

   CoPYRiGHt:
   ----------
   This script should be shipped with the HiPPOPLAYER
   distribution package by K-P Koljonen, it must not be
   sold for any profit ! It`s allowed to put it on Aminet
   and Aminet-CD`s as long it`s in unchanged condition.
   It`s absolutely FD, that means you can use it however
   you want, you might change it for private use only,
   you MUST NOT put changed versions without my permission
   into the public domain !

   BuGS:
   -----
   If you find an bug (very unpropable), write me via E-Mail
   with an short description of it and I`ll fix it.

*/

IF ~SHOW('LIBRARIES','rexxreqtools.library') THEN DO
   IF ~ADDLIB('rexxreqtools.library',0,-30,0) THEN DO
         SAY 'No tritonrexx.library found !'
         SAY 'Available on Aminet !'
   EXIT(10)
   END
END


IF ~SHOW('LIBRARIES','rexxtricks.library') THEN DO
   IF ~ADDLIB('rexxtricks.library',2,-30,0) THEN DO
      SAY 'No Rexxtricks.library found !'
      Say 'Available on Aminet !'
      EXIT(10)
    END
END

IF ~SHOW('LIBRARIES','rexxsupport.library') THEN DO
   IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN DO
      SAY 'No Rexxsupport.library available '
      EXIT(10)
    END
END


OPTIONS RESULTS

gplay:
ADDRESS 'HIPPOPLAYER'
GET PLAY
playing=result

if playing=0 then do
nop=rtezrequest('HiP must be playing an Module, try again ?','_Yes|_No','Error !','rtez_flags=ezreqf_centertext','rtez_defaultresponse = 0',)
if nop=1 then
call gplay
if nop=0 then
exit(5)
end

gcnam:
options results

address 'HIPPOPLAYER'

GET CNAM
filename=result
address

oldfile=filename

if filename='' then do
cgf=rtezrequest('Error getting filename from HiP, try again ?','_Yes|_No','Error !','rtez_flags=ezreqf_centertext','rtez_defaultresponse = 0',)
if cgf=1 then
call gcnam
if cfg=0 then
exit(5)
end

suffix=SUFFIXPART(filename)
direct=PATHPART(filename)
dname=FILEPART(filename)

differencer=''

IF RIGHT(direct,Length(direct)-Length(direct)+1)~=':' then
differencer='/'

if suffix='' then do
nsuf=rtezrequest('Error getting Suffix from file, maybe it`s name is already mod.#? ?','_Could be','Error !','rtez_flags=ezreqf_centertext','rtez_defaultresponse = 0',)
exit(5)
end

PARSE VAR filename filename '.' (suffix)
filename=FILEPART(filename)

newfile=direct''differencer''suffix'.'filename

address command 'C:Rename 'oldfile' 'newfile''

ADDRESS 'HIPPOPLAYER'
DEL
exit

ADD newfile

exit
