home *** CD-ROM | disk | FTP | other *** search
- /* Personal Paint Amiga Rexx script - Copyright © 1997 LazaruZ */
-
- /* $VER: SaveNewIcon v1.0alfabetatheta :-) */
-
- /** ENG
- Saves two selected brushes as NewIcon.
-
- An existing or new .info file is selected using
- the file requester. New icons are created by
- entering a non existing filename (with or without
- ".info") in the file entry.
-
- If the entered .info filename does not
- exist SaveNewIcon will create a new
- .info file using:
-
- PPaint:PPaint_Icons/def_NewNI.info
-
- Make sure this file is available. This
- script also needs the 'injectbrush' utility
- in a known path. This utility is available
- from the NewIconv3 archive (aminet).
-
- Script created by: Eric van Velthooven.
-
- eric@stack.nl
-
- 'LazaruZ' efnet #amiga
-
- http://www.stack.nl/~eric/prowb.html
- */
-
- IF ARG(1, EXISTS) THEN
- PARSE ARG PPPORT
- ELSE
- PPPORT = 'PPAINT'
-
- IF ~SHOW('P', PPPORT) THEN DO
- IF EXISTS('PPaint:PPaint') THEN DO
- ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
- DO 30 WHILE ~SHOW('P',PPPORT)
- ADDRESS COMMAND 'Wait >NIL: 1 SEC'
- END
- END
- ELSE DO
- SAY "Personal Paint could not be loaded."
- EXIT 10
- END
- END
-
- IF ~SHOW('P', PPPORT) THEN DO
- SAY 'Personal Paint Rexx port could not be opened'
- EXIT 10
- END
-
- ADDRESS VALUE PPPORT
- OPTIONS RESULTS
- OPTIONS FAILAT 10000
-
- txt_title_req = 'NewIcon Saver'
- txt_file_req = 'Select a .info file'
- txt_oldclient = 'This script requires a newer version of Personal Paint'
- txt_notsize = 'Brushes not the same size:'
- txt_gad_1 = '_First brush:'
- txt_gad_2 = '_Second brush:'
- txt_gad_f = '_Enable FORCE option'
- txt_nodef = 'Template .info file not present in PPaint:PPaint_Icons/'
- txt_toobig = 'Maximum icon size is 93x93'
- txt_injf = 'Injectbrush failed, are you sure it is in a known path?'
- txt_injff = 'Injectbrush failed for some reason, try using FORCE'
-
- def_NI = "Ppaint:PPaint_Icons/def_NewNI.info"
-
- Version 'REXX'
- IF RESULT < 7 THEN DO
- RequestNotify 'PROMPT "'txt_oldclient'"'
- EXIT 10
- END
-
- Request '"'txt_title_req'" ' ||,
- '"CYCLE = ""'txt_gad_1'"", 9, 0, 1,2,3,4,5,6,7,8,9 ' ||,
- ' CYCLE = ""'txt_gad_2'"", 9, 1, 1,2,3,4,5,6,7,8,9 ' ||,
- ' CHECK = ""'txt_gad_f'"", 1 " '
-
- IF RC ~= 0 THEN
- EXIT 0
- br1 = RESULT.1 + 1
- br2 = RESULT.2 + 1
- force = RESULT.3
-
- LockGui
-
- SetCurrentBrush 'BRUSH' br1
- GetBrushAttributes 'WIDTH'
- wid1 = RESULT
- GetBrushAttributes 'HEIGHT'
- hei1 = RESULT
-
- SetCurrentBrush 'BRUSH' br2
- GetBrushAttributes 'WIDTH'
- wid2 = RESULT
- GetBrushAttributes 'HEIGHT'
- hei2 = RESULT
-
- IF ''wid1~=wid2|hei1~=hei2'' THEN DO
- RequestNotify 'PROMPT "'txt_notsize' brush1='wid1'x'hei1', brush2='wid2'x'hei2'"'
- UnlockGUI
- EXIT 0
- END
-
- IF ''hei1>93|wid1>93'' THEN DO
- RequestNotify 'PROMPT "'txt_toobig'"'
- UnlockGUI
- EXIT 0
- END
-
- SetCurrentBrush br1
- SaveBrush FILE "T:pp2ni_1" FORMAT 'ilbm'
- SetCurrentBrush br2
- SaveBrush FILE "T:pp2ni_2" FORMAT 'ilbm'
-
- IF ''EXISTS("ENV:pp2ni_pad")''=1 THEN DO
- padname = LoadSet('pad')
- END
- ELSE DO
- Get 'SETTING "PATHPIC"'
- padname = RESULT
- END
-
- Get 'SETTING "FILREQ"'
- filreqset = RESULT
- Set 'FORCE "FILREQ=0x3B"'
-
- RequestFile '"'txt_file_req'" PATH='padname
- IF RC ~= 0 THEN DO
- ADDRESS COMMAND
- ''delete '>nil: T:pp2ni#?'
- ADDRESS VALUE PPPORT
- Set 'FORCE "FILREQ='filreqset'"'
- UnlockGui
- EXIT 0
- END
- iconname = RESULT
-
- IF RIGHT(''iconname'',6) ~= '.info"' THEN DO
- iconname = LEFT(''iconname'',LENGTH(''iconname'')-1)
- iconname = iconname'.info"'
- END
-
- IF ''INDEX(''iconname'',"/")'' = 0 THEN DO
- padname = LEFT(''iconname'',INDEX(''iconname'',":"))'"'
- END
- ELSE DO
- padname = LEFT(''iconname'',LASTPOS('/',''iconname''))'"'
- END
-
- ADDRESS COMMAND
-
- IF ~EXISTS(CENTER(iconname,LENGTH(iconname)-2)) THEN DO
- IF ''EXISTS(''def_NI'')'' = 1 THEN DO
- ''copy def_NI iconname
- END
- ELSE DO
- ''delete '>nil: T:pp2ni#?'
-
- ADDRESS VALUE PPPORT
- Set 'FORCE "FILREQ='filreqset'"'
- UnlockGui
- RequestNotify 'PROMPT "'txt_nodef'"'
- EXIT 0
- END
- END
-
- IF force = 1 THEN DO
- ''injectbrush '>T:pp2ni_out' iconname 'T:pp2ni_1 T:pp2ni_2 FORCE'
- END
- ELSE DO
- ''injectbrush '>T:pp2ni_out' iconname 'T:pp2ni_1 T:pp2ni_2'
- END
- IF RC ~= 0 THEN DO
- ADDRESS COMMAND
- ''delete '>nil: T:pp2ni#?'
- ADDRESS VALUE PPPORT
- Set 'FORCE "FILREQ='filreqset'"'
-
- IF force =1 THEN DO
- RequestNotify 'PROMPT "'txt_injf'"'
- END
- ELSE DO
- RequestNotify 'PROMPT "'txt_injff'"'
- END
- UnlockGui
- EXIT 0
- END
-
- ''delete '>nil: T:pp2ni#?'
-
- ADDRESS VALUE PPPORT
-
- CALL SaveSet('pad', padname)
- Set 'FORCE "FILREQ='filreqset'"'
- UnlockGui
- EXIT 0
-
-
- SaveSet: PROCEDURE
- sname = ARG(1)
- val = ARG(2)
-
- IF OPEN('settingfile', 'ENV:pp2ni_'sname, 'W') THEN DO
- CALL WRITECH('settingfile', val)
- CALL CLOSE('settingfile')
- END
-
- RETURN
-
-
- LoadSet: PROCEDURE
- sname = ARG(1)
- set_fname = 'ENV:pp2ni_'sname
-
- IF OPEN('settingfile', set_fname, 'R') THEN DO
- val = READLN('settingfile')
- CALL CLOSE('settingfile')
- END
-
- RETURN val
-