home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 20
/
AACD20.BIN
/
AACD
/
Utilities
/
MultiRen
/
Developers
/
SwapName-Plugin.mrp.e
< prev
next >
Wrap
Text File
|
2000-07-03
|
4KB
|
144 lines
/* Swapname-plugin v1.1 rev.#2 by Deniil 715! for MultiRen
Made 2000-07-04
E-mail to me, Daniel Westerberg: deniil@algonet.se
*/
CONST NUMSTRINGS_FOR_THIS_PLUGIN=1, FILE_NAME_LENGTH=512,
COM_ASK=1, COM_EXTRACT=2, COM_CONFIGURE=3, COM_ABOUT=4, COM_QUIT=5,
ERR_OK=0,
ERR_NOMEM=1,
ERR_NOFILE=2,
ERR_NOSIG=3,
ERR_NOTIMPL=4,
ERR_UNKNOWN=5,
ERR_OTHER=6,
ERR_WRONGFORMAT=7,
ERR_NOINFO=8,
ERR_FATAL=20
OBJECT multiren_plugin
id:LONG
task:LONG
sig:LONG
return:INT
command:CHAR
numstrings:CHAR
stringlist[256]:ARRAY OF LONG
name:PTR TO CHAR
newname:CHAR
ENDOBJECT
DEF mrp:PTR TO multiren_plugin, -> The communication object
s[FILE_NAME_LENGTH]:STRING, -> The string we will use and return to MultiRen
fh, inclext=1 -> The configuration..
PROC main()
DEF sel, sigbit, sig, mtask, msig
'$VER: SwapName v1.1 rev.#2 by Deniil 715! (2000-07-04)'
IF arg
IF mrp:=Val(arg)
IF mrp.id="MRPO"
IF (sigbit:=AllocSignal(-1))>=0
sig:=Shl(1,sigbit)
LOOP
sel:=mrp.command
SELECT sel
CASE COM_ASK
mtask:=mrp.task
msig:=mrp.sig
mrp.return:=ask()
SetProgramName(mrp.name)
mrp.task:=FindTask(NIL)
mrp.sig:=sig
CASE COM_EXTRACT ; mrp.return:=extract()
CASE COM_CONFIGURE ; mrp.return:=config()
CASE COM_ABOUT ; mrp.return:=about()
CASE COM_QUIT
FreeSignal(sigbit)
mrp.return:=cleanup()
Signal(mtask,msig)
RETURN
DEFAULT ; mrp.return:=ERR_UNKNOWN
ENDSELECT
Signal(mtask,msig)
Wait(sig)
ENDLOOP
ELSE
Signal(mrp.task,mrp.sig)
mrp.return:=ERR_NOSIG
RETURN
ENDIF
ENDIF
ENDIF
ENDIF
WriteF('This is a plugin for MultiRen!\n' +
'It is not supposed to be executed manually!\n' +
'Use it through the Renplacer tool in MultiRen instead!\n')
ENDPROC ERR_FATAL
PROC ask()
mrp.numstrings:=NUMSTRINGS_FOR_THIS_PLUGIN -> I will return one string
mrp.stringlist[0]:='Filename turn backwards' -> Setting information-strings
mrp.name:='SwapName' -> This plugins name
mrp.newname:=1 -> As this plugin is doing stuff with the filename
-> and not the file it is wise to request New name.
-> NOTE: Do NOT enter TRUE here as that is -1!
IF fh:=Open('PROGDIR:Plugins/SwapName-plugin.cfg',OLDFILE) -> Open configfile
inclext:=Inp(fh) -> The prefs telling if we should include extension
-> in the swap or not..
Close(fh)
ENDIF
ENDPROC
PROC extract() -> Do my stuff..
DEF x, y, z, st
st:=FilePart(mrp.name) -> Note that we get the complete path in name
-> and must separate it to get the filename.
x:=StrLen(st)-1
IF x<FILE_NAME_LENGTH
IF inclext
FOR y:=0 TO x DO s[y]:=st[x-y]
SetStr(s,x+1)
ELSE
FOR z:=x TO 0 STEP -1 DO EXIT st[z]="."
IF z>0 THEN DEC z ELSE z:=x
FOR y:=0 TO z DO s[y]:=st[z-y]
SetStr(s,z+1)
IF z<x THEN StrAdd(s,st+z+1)
ENDIF
mrp.stringlist[0]:=s -> Setting the string-list position 0 to point to our string
RETURN ERR_OK
ELSE
RETURN ERR_OTHER -> Filename was longer than the set max-length for MultiRen v1.3
ENDIF
ENDPROC
PROC config()
inclext:=req('Do you want the extension to be\n' +
'part of the filename swapping??',
'Yes|No|Cancel')
IF inclext
IF fh:=Open('PROGDIR:Plugins/SwapName-plugin.cfg',NEWFILE)
Out(fh,inclext AND 1)
Close(fh)
ELSE
req('Could not save the settings!','OK')
ENDIF
ENDIF
ENDPROC ERR_OK -> Will always return ERR_OK here so that MultiRen will not
-> put up another requester telling this operation failed.
PROC about()
IF req('SwapName Plugin v1.1 rev.#2 by Deniil 715! for MultiRen\n\n' +
'It was made 2000-07-04 in Amiga-E\n\n' +
'E-mail: deniil@algonet.se','More|OK')
req('This plugin will swap the filename backwards.\n' +
'It features a setting to include the file-\n' +
'extension in the swapping or not.','OK')
ENDIF
ENDPROC ERR_OK
PROC cleanup() IS ERR_OK
PROC req(body,gads) IS EasyRequestArgs(NIL,[20,0,'SwapName Plugin',body,gads],NIL,NIL)