home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
software
/
grafica
/
svconvert15
/
svconvert.dopus5
< prev
next >
Wrap
Text File
|
2000-01-23
|
25KB
|
804 lines
/*
$VER: SVConvert.dopus5 1.5 (23.01.2000)
Written by Wayne Newark <wayne@zahadum.u-net.com>, using GoldEd/Pro.
This is an ARexx script for DOpus Magellan that allows you to use Andreas
Kleinert's excellent SViewNG/SViewII/SViewIV to convert picture files from one
format to another. It processes all files selected in one or more source
listers, ignoring those it does not recognise.
It will only work with a registered version of SViewNG/SViewII/SViewIV.
This script can handle both multiple source and destination listers. All the
selected source files, from all the source listers, will be converted into
all the destination listers. As part of the conversion process the files are
renamed. It does this by stripping off all text after the last '.' and
appending an appropriate suffix.
Example: Converting to PNG - Pic1.iff becomes Pic1.PNG
Converting to GIF - Pic2.pcx becomes Pic2.GIF
---------------------------------------------------------------------------
Usage: ARexx DOpus5:ARexx/SVConvert.dopus5 {Qp}
format - At present this is limited to: JPEG, BMP, PNG, DEEP, PCX,
ILBM, PBM, RGFX, TIFF and SVG.
Read the Superview-library.guide for further details on supported graphic
formats.
---------------------------------------------------------------------------
History:
Read document SVConvert.history for details of changes.
*/
signal on Syntax /* intercept syntax errors */
options results /* need results */
options failat 11 /* external commands are allowed return code 10 */
lf='a'x /* ascii code for linefeed */
SV_path = 'Serious:Graphics/Superview/SViewIV' /* Location and name of SuperView program */
SV_port = 'SViewII.rx' /* Name of SuperView ARexx Port */
appname = 'SVConvert'
applongname = 'SVConvert.dopus5 - ©2000 by Wayne Newark'
appinfo = 'Script for SViewIV & DOpus 5.8+'
appversion = '1.5'
apprelease = '?'
appdate = '23.01.2000'
parse arg DOpus_port ' ' format
if DOpus_port='' then
DOpus_port='DOPUS.1'
address value DOpus_port
call Initialise
lister query source stem sl
if sl.count=0 then
do
dopus request '"'txt_nosrc'"' txt_okay
exit
end
lister query dest stem dl
if dl.count=0 then
do
dopus request '"'txt_nodest'"' txt_okay
exit
end
if format='' then
do
call Get_SaveType /* Get required destination file(s) format */
if savetype='' then
exit
end
else
do
do i=0 to sv.count-1
parse var sv.i sv_format '|' sv_suffix '|' sv_compression '|' sv_savetype1 '|' sv_savetype2
if sv_format=format then
do
suffix=sv_suffix
savetype=sv_savetype1
if sv_compression='Y' then
do
dopus request '"'txt_compress'"' txt_yesno
if rc=1 then
savetype=sv_savetype2
end
leave
end
end
if savetype='' then
do
dopus request '"'txt_format_1'"' txt_okay
exit
end
end
/* Start Superview if not already running */
if ~show('p',SV_port) then
do
address command 'run >NIL: 'SV_path' -INSTALL_APPMENU=FALSE -INSTALL_APPICON=FALSE -INSTALL_APPWINDOW=FALSE'
address command 'WaitForPort 'SV_port
if ~show('p',SV_port) then /* If SuperView fails to start, an error is reported. */
do
dopus request '"'txt_sv_notfnd'"' txt_okay
exit
end
SV_Started=1
end
address value SV_port
"PUT_ICONS=NO"
"ERROR_REPORT=NO"
address value DOpus_port
/* lock the listers here!!! */
do s=0 to sl.count-1
lister set sl.s busy on
end
do d=0 to dl.count-1
lister set dl.d busy on
end
/* process source lister(s) */
do s=0 to sl.count-1
lister query sl.s path /* get path of current source lister */
src_path=strip(result,"B",'"')
lister query sl.s numselfiles /* get number of selected files */
number_files=result
lister query sl.s numselentries /* get total number of selected items */
total_selected=result
if number_files>0 then
do
complete=(1+dl.count)*number_files
sofar=0
lister clear sl.s abort
lister set sl.s newprogress abort bar name title
lister set sl.s newprogress title txt_title
lister set sl.s newprogress bar complete sofar
do t=1 to total_selected
sofar=sofar+1 /* increase progress position */
lister query sl.s firstsel /* obtain selected item */
src_name=strip(result,"B",'"')
lister query sl.s entry "'"src_name"'" stem fileinfo /* check for directories */
if fileinfo.type<0 then
do
/* check for icons (those with .info suffix) and ignore them */
if right(src_name,5)~='.info' then
do
lister set sl.s newprogress name txt_loading src_name
lister set sl.s newprogress bar complete sofar
call Load_File
if SV_status~='No file loaded' then
do
lister query sl.s abort
if result then
do
lister set sl.s newprogress off
dopus request '"'txt_aborted'"' txt_okay
call The_End
exit
end
call Convert_File
do d=0 to dl.count-1 /* now save file to all destinations */
sofar=sofar+1 /* increase progress position */
if dl.count>1 then
lister set sl.s newprogress name txt_saving dest_name||" "||d+1
else
lister set sl.s newprogress name txt_saving dest_name
lister set sl.s newprogress bar complete sofar
call Save_File
lister query sl.s abort
if result then
do
lister set sl.s newprogress off
dopus request '"'txt_aborted'"' txt_okay
call The_End
exit
end
end /* end of do */
call Delete_File
end
else
do
sofar=sofar+dl.count
lister select sl.s '"'src_name'"' off /* deselect current file (invalid format) */
end
end
else
do
sofar=sofar+dl.count
lister select sl.s '"'src_name'"' off /* deselect current file (#?.info) */
end
end
else
do
lister select sl.s '"'src_name'"' off /* deselect current directory */
end
lister refresh sl.s /* refresh current source lister */
end /* end of do */
lister set sl.s newprogress off
end
end
call The_End
exit
Syntax:
call The_End
address value DOpus_port
dopus request '"'txt_error_fnd'"' txt_okay
exit
/*** Called subroutines or functions follow ***/
/*
** Tidies up listers etc.
*/
The_End:
/* Reread all destination listers */
/* Unlock any locked listers */
do s=0 to sl.count-1
lister set sl.s busy off
end
do d=0 to dl.count-1
lister query dl.d path /* obtain path of destination lister */
dest_path=strip(result,"B",'"')
lister set dl.d busy off
lister read dl.d dest_path
end
/* Quit Superview if started by this script */
if SV_Started then
if show('p',SV_port) then
do
address value SV_port
"QUIT"
end
else
do
address value SV_port
"ERROR_REPORT=YES"
end
return
/*
** Sets Output File Format and creates new destination file name
*/
Convert_File:
lang=length(src_name)
posn=lastpos('.',src_name)
po=lang-posn
/* rename destination filename */
if posn=0 then
dest_name=src_name || '.' || suffix
else
do
suffix_old=right(src_name,po)
dest_name=left(src_name,posn) || suffix
end
if DATATYPE(suffix_old,'N') = 1 then
dest_name = dest_name || '.' || suffix_old
dest_info.name=dest_name
address value SV_port
if suffix='GIF' then
do
parse var SV_status st ' ' width 'x' height 'x' depth
if depth>8 then
do
"SVOPERATOR=Dither24Bit" /* reduces picture to 8 bit */
"ACTION"
end
end
interpret '"SAVE_TYPE='savetype'"' /* Sets SuperView Savetype */
return
/*
** Causes Superview to save file to destination lister
*/
Save_File:
address value DOpus_port
lister query dl.d path /* obtain path of destination lister */
dest_path=strip(result,"B",'"')
dest_file=dest_path||dest_name /* set up complete file name */
if (exists(dest_file) & Overwrite_ind=0) then
do
dopus request '"'||dest_file||txt_replace_1'"' txt_replace_2
if rc=0 then
return
if rc=2 then
Overwrite_ind=1
end
address value SV_port
interpret '"SAVE='||dest_file||'"'
address value DOpus_port
lister addstem dl.d dest_info /* update destination lister */
lister refresh dl.d
return
/*
** Loads current picture into Superview
*/
Load_File:
src_file=src_path||src_name
address value SV_port
interpret '"LOAD='||src_file||'"'
'STATUS=T:SV.status'
if open(ifile,'T:SV.status','R') then
do
SV_status=readln(ifile)
call close ifile
end
else
SV_status='No file loaded'
address value DOpus_port
return
/*
** Deletes source file.
**
** We need to load a dummy file into SViewII so that it frees up the current file
** for deletion.
*/
Delete_File:
address value SV_port
"LOAD=T:SV.status"
address value DOpus_port
if (exists(src_file) & Delete_ind=0) then
do
dopus request '"'||src_name||txt_delete_1'"' txt_delete_2
select
when rc=1 then
keep=0
when rc=2 then
do
Delete_ind=1
keep=0
end
when rc=3 then
do
Delete_ind=2
keep=2
end
otherwise
keep=1
end
end
lister select sl.s '"'src_name'"' off /* deselect current file */
if (Delete_ind=1 | keep=0) then
do
pragma('D', src_path)
address command 'c:delete ' || '"'src_name'"' || ' QUIET FORCE'
if rc=0 then
lister remove sl.s '"'src_name'"'
end
/* lister refresh sl.s refresh current source lister */
return
/*
** Asks User to select destination savetype
** Used when triton libraries are installed
*/
Get_SaveType:
fmtlist.0=sv.count
do i=0 to sv.count-1
j=i+1
parse var sv.i dummy '|' fmtlist.j
end
/* Set up the Triton Window objects */
Windowtags=WindowID(1),
WindowPosition('TRWP_MOUSEPOINTER'),
PubScreenName('DOPUS.1'),
WindowBackfillFB,
WindowTitle('SVConvert'),
'HorizGroupA',
'Space',
'VertGroupA',
'Space',
NamedFrameBox(txt_format_2),
'HorizGroupA',
'Space',
'VertGroupA',
'Space',
ListSS(fmtlist,50,0,0),
'Space',
'Space',
'HorizGroupA',
Button(txt_use,61),
'Space',
Button(txt_quit,62),
'EndGroup',
'Space',
'EndGroup',
'SpaceS',
'EndGroup',
'Space',
'EndGroup',
'Space',
'EndGroup',
'EndProject'
app = TR_CREATEAPP('TRCA_Name' '"'appname'"',
'TRCA_LongName' '"'applongname'"',
'TRCA_Info' '"'appinfo'"',
'TRCA_Version' '"'appversion'"',
'TRCA_Release' '"'apprelease'"',
'TRCA_Date' '"'appdate'"',
'TAG_END')
if app~='00000000'x then
do
fmtwin=TR_OPENPROJECT(app,Windowtags)
if fmtwin~='00000000'x then
do
lquit=0
do while lquit=0
call TR_WAIT(app,'')
do while TR_HANDLEMSG(app,'event')
if event.trm_class='TRMS_CLOSEWINDOW' then
lquit=1
if event.trm_class='TRMS_NEWVALUE' then
if event.trm_id=50 then
if bitand(d2x(event.trm_qualifier),'0200'x)='0200'x then /* double-click */
lquit=1
if event.trm_class='TRMS_ACTION' then
do
if event.trm_id=61 then /* Use button */
lquit=1
if event.trm_id=62 then /* Quit Button */
lquit=2
end
end
end
if lquit=1 then
do
number=TR_GETATTRIBUTE(fmtwin,50,'TRAT_Value')
parse var sv.number suffix '|' savetype
end
else
savetype=''
call TR_CLOSEPROJECT(fmtwin)
end
else
do
dopus request '"'txt_error_fnd'"' txt_okay
exit
end
call TR_DELETEAPP(app)
end
else
do
dopus request '"'txt_error_fnd'"' txt_okay
exit
end
return
/*
** Initialises variables etc.
*/
Initialise:
SV_Started = 0
Overwrite_ind = 0
Delete_ind = 0
Use_locale = 1
/* Open locale.library */
call Open_Catalog
/* Set up catalog details */
MSG_USE_GAD = 0
MSG_QUIT_GAD = 1
MSG_SELECT_SVOBJECT = 2
MSG_USE_COMPRESSION = 3
MSG_OKAY_GAD = 4
MSG_YES_GAD = 5
MSG_NO_GAD = 6
MSG_ALL_GAD = 7
MSG_NONE_GAD = 8
MSG_TITLE = 9
MSG_SAVING = 10
MSG_LOADING = 11
MSG_USER_ABORTED = 12
MSG_REPLACE_FILE_1 = 13
MSG_REPLACE_FILE_2 = 14
MSG_DELETE_FILE_1 = 15
MSG_DELETE_FILE_2 = 16
WARN_NO_SOURCE = 17
WARN_NO_DESTINATION = 18
UNKNOWN_ERROR_FOUND = 19
ERROR_UNKNOWN_FORMAT = 20
ERROR_SVIEW_NOT_FOUND_1 = 21
ERROR_SVIEW_NOT_FOUND_2 = 22
ERROR_TRITON_LIB_NOT_FOUND = 23
ERROR_TRITONREXX_LIB_NOT_FOUND = 24
ERROR_CANNOT_OPEN_TRITONREXX = 25
/* Default catalog values (English) */
String.0 = '_Use'
String.1 = '_Quit'
String.2 = 'Select SV Object:'
String.3 = 'Shall I use compression?'
String.4 = 'Ok'
String.5 = 'Yes'
String.6 = 'No'
String.7 = 'All'
String.8 = 'None'
String.9 = 'Converting file(s)...'
String.10 = 'Saving'
String.11 = 'Loading'
String.12 = 'User Aborted'
String.13 = ' exists.'
String.14 = 'Shall I overwrite it?'
String.15 = ' processed.'
String.16 = 'Shall I delete it?'
String.17 = 'No source(s) selected.'
String.18 = 'No destination(s) selected.'
String.19 = 'An error has occurred'
String.20 = 'Unknown Format Specified.'
String.21 = 'SViewIV can not be started,'
String.22 = 'check the path!'
String.23 = 'The triton.library could not be found!'
String.24 = 'The tritonrexx.library could not be found!'
String.25 = 'Could not open the tritonrexx.library!'
/* End of catalog details */
/* Set text strings according to users prefered language */
txt_use = Locale_String(MSG_USE_GAD)
txt_quit = Locale_String(MSG_QUIT_GAD)
txt_format_1 = Locale_String(ERROR_UNKNOWN_FORMAT)
txt_format_2 = Locale_String(MSG_SELECT_SVOBJECT)
txt_nosrc = Locale_String(WARN_NO_SOURCE)
txt_nodest = Locale_String(WARN_NO_DESTINATION)
txt_compress = Locale_String(MSG_USE_COMPRESSION)
txt_okay = Locale_String(MSG_OKAY_GAD)
txt_yesno = Locale_String(MSG_YES_GAD)'|'Locale_String(MSG_NO_GAD)
txt_sv_notfnd = Locale_String(ERROR_SVIEW_NOT_FOUND_1)'lf'Locale_String(ERROR_SVIEW_NOT_FOUND_2)
txt_title = Locale_String(MSG_TITLE)
txt_loading = Locale_String(MSG_LOADING)
txt_saving = Locale_String(MSG_SAVING)
txt_aborted = Locale_String(MSG_USER_ABORTED)
txt_error_fnd = Locale_String(UNKNOWN_ERROR_FOUND)
txt_replace_1 = Locale_String(MSG_REPLACE_FILE_1)||lf||Locale_String(MSG_REPLACE_FILE_2)
txt_replace_2 = Locale_String(MSG_YES_GAD)'|'Locale_String(MSG_ALL_GAD)'|'Locale_String(MSG_NO_GAD)
txt_delete_1 = Locale_String(MSG_DELETE_FILE_1)||lf||Locale_String(MSG_DELETE_FILE_2)
txt_delete_2 = Locale_String(MSG_YES_GAD)'|'Locale_String(MSG_ALL_GAD)'|'Locale_String(MSG_NONE_GAD)'|'Locale_String(MSG_NO_GAD)
/* Check to see if the Triton libraries are installed */
if format='' then
do
if ~exists('Libs:triton.library') then
do
dopus request '"'Locale_String(ERROR_TRITON_LIB_NOT_FOUND)'"' Locale_String(MSG_OKAY_GAD)
call Close_Catalog
exit
end
if ~exists('Libs:tritonrexx.library') then
do
dopus request '"'Locale_String(ERROR_TRITONREXX_LIB_NOT_FOUND)'"' Locale_String(MSG_OKAY_GAD)
call Close_Catalog
exit
end
end
/* Open Triton Arexx Library */
if (format='' & ~show('L','tritonrexx.library')) then
if ~addlib('tritonrexx.library',10,-30,0) then
do
dopus request '"'Locale_String(ERROR_CANNOT_OPEN_TRITONREXX)'"' Locale_String(MSG_OKAY_GAD)
call Close_Catalog
exit
end
if format='' then
do
/*
sv.x - <suffix>|<savetype>
*/
i = 0
sv.i = 'iff|ACBM uncompressed'
i = i+1
sv.i = 'bmp|BMP (Win,OS/2)'
i = i+1
sv.i = 'eps|EPS (Header/PS)'
i = i+1
sv.i = 'iff|DEEP'
if exists('Libs:svobjects/GIF.svobject') then
do
i = i+1
sv.i = 'gif|GIF 87a'
i = i+1
sv.i = 'gif|GIF 89a'
end
i = i+1
sv.i = 'iff|ILBM CmpByteRun1'
i = i+1
sv.i = 'iff|ILBM uncompressed'
i = i+1
sv.i = 'jpg|JPEG (IJG-JFIF)'
i = i+1
sv.i = 'pbm|PBM CmpByteRun1'
i = i+1
sv.i = 'pbm|PBM uncompressed'
i = i+1
sv.i = 'pcx|PCX V2.5-3.0'
i = i+1
sv.i = 'png|PNG (PiNG)'
i = i+1
sv.i = 'pgm|PNM PGM (P5)'
i = i+1
sv.i = 'ppm|PNM PPM (P6)'
i = i+1
sv.i = 'iff|RGFX uncompressed'
i = i+1
sv.i = 'iff|RGFX XPK-compressed'
i = i+1
sv.i = 'qrt|QRT/POV RayTracer'
i = i+1
sv.i = 'sgi|SGI'
i = i+1
sv.i = 'i|Sourcecode Asm'
i = i+1
sv.i = 'c|Sourcecode C'
i = i+1
sv.i = 'ras|SunRaster (RAS)'
i = i+1
sv.i = 'svg|SVG Graphics File'
i = i+1
sv.i = 'tiff|TIFF V5.0'
i = i+1
sv.i = 'tga|Targa (TGA)'
i = i+1
sv.i = 'iff|YUVN (411)'
sv.count = i+1
end
else
do
/*
sv.x - <image format>|<suffix>|<compression available?>|<uncompressed savetype>|<compressed savetype>
*/
sv.0 = 'JPEG|jpg|N|JPEG (IJG-JFIF)|x'
sv.1 = 'BMP|bmp|N|BMP (Win,OS/2)|x'
sv.2 = 'PNG|png|N|PNG (PiNG)|x'
sv.3 = 'PCX|pcx|N|PCX V2.5-3.0|x'
sv.4 = 'DEEP|iff|N|DEEP|x'
sv.5 = 'ILBM|iff|Y|ILBM uncompressed|ILBM CmpByteRun1'
sv.6 = 'PBM|pbm|Y|PBM uncompressed|PBM CmpByteRun1'
sv.7 = 'RGFX|iff|Y|RGFX uncompressed|RGFX XPK-compressed'
sv.8 = 'SVG|svg|N|SVG Graphics File|x'
sv.9 = 'TIFF|tiff|N|TIFF V5.0|x'
sv.10 = 'TGA|tga|N|Targa (TGA)|x'
sv.11 = 'PGM|pgm|N|PNM PGM (P5)|x'
sv.12 = 'PPM|ppm|N|PNM PPM (P6)|x'
sv.13 = 'SGI|sgi|N|SGI|x'
sv.14 = 'YUVN|iff|N|YUVN (411)|x'
sv.15 = 'RAS|ras|N|SunRaster (RAS)|x'
sv.16 = 'ACBM|iff|N|ACBM uncompressed|x'
if exists('Libs:svobjects/GIF.svobject') then
do
sv.17 = 'GIF|gif|N|GIF 89a|x'
sv.count = 18
end
else
sv.count = 17
end
savetype = ''
suffix = ''
call Close_Catalog
return
/*
** Returns the appropriate string value
*/
Locale_String:
parse arg stringnumber
if Use_locale then
return(GetCatalogStr(catalog,stringnumber,string.stringnumber))
else
return(string.stringnumber)
/*
** Opens Locale catalog, if present
*/
Open_Catalog:
if ~show('L','locale.library') then
if ~addlib('locale.library',-10,-30,0) then
uselocale = 0
if open(language,'ENV:Language','R') then
do
lang=READLN(language)
close(language)
end
else
lang=''
lang=lang || '/'
if Use_locale then
do
catalog = OpenCatalog('DOPUS5:catalogs/'lang'SVConvert.catalog','english',0)
if catalog=0 then
catalog=OpenCatalog('SVConvert.catalog','english',0)
if catalog=0 then
Use_locale=0
end
return
/*
** Closes Locale catalog, if used
*/
Close_Catalog:
if Use_locale then
CloseCatalog(catalog)
return