/****************************************************************************** Here is an example of an "environnement file". All you have to do, siill it with : - use MUIBuilder+GenCodeE to generate the create_app() function - add the code for your application !!! ******************************************************************************/ OPT OSVERSION=37 /* Module definitions */ MODULE 'muimaster', 'libraries/mui' MODULE 'utility/tagitem', 'utility/hooks' MODULE 'intuition/classes', 'intuition/classusr' /* Error handling */ ENUM NO_LIBRARY, MUI_APPLICATION_FAILURE RAISE NO_LIBRARY IF OpenLibrary()=NIL, MUI_APPLICATION_FAILURE IF Mui_NewObjectA()=NIL /* Constant definitions */ CONST MUI_TRUE = 1 CONST NULL = 0 CONST ID_INADD = 10 CONST ID_OUTADD = 11 CONST ID_ADD = 12 CONST ID_EDIN = 13 CONST ID_EDOUT = 14 CONST ID_DELIN = 15 CONST ID_DELOUT = 16 CONST ID_GO = 17 CONST ID_NEWFILE = 18 CONST ID_NEWFORM = 19 CONST ID_DETECT = 20 CONST ID_INUP = 21 CONST ID_INDOWN = 22 CONST ID_INTOP = 23 CONST ID_INBOTTOM = 24 CONST ID_OUTUP = 25 CONST ID_OUTDOWN = 26 CONST ID_OUTTOP = 27 CONST ID_OUTBOTTOM= 28 CONST INPUT = 1 CONST OUTPUT = 2 CONST EDINPUT = 3 CONST EDOUTPUT = 4 CONST NEW = 0 CONST CHECK = 0 CONST FORCE = 1 /* Global variables */ /*MUIB*/ DEF app, mainWindow, inputList, inputAdd, outputList, outputAdd /*MUIB*/ DEF goButt, quitButt, addWindow, titel, cmdLine, optList, optAddButt /*MUIB*/ DEF optEdButt, ok, cancel DEF inputEdit, outputEdit, inputDel, outputDel, mext, tmpfile DEF chcpin, chext, detect, detectButt DEF pop1, pop2, pop3 DEF inup, indown, intop, inbottom DEF outup, outdown, outtop, outbottom OBJECT entry titel file cmdline magicext ENDOBJECT DEF entries:PTR TO entry, filehandle DEF magicstart:PTR TO CHAR, magicstr:PTR TO LONG, magicnr DEF active,i,line[100]:STRING,list,line2[100]:STRING, pos, var, j, a DEF temp[4]:STRING DEF file1:PTR TO CHAR, file2:PTR TO CHAR DEF name:PTR TO CHAR DEF what, data:PTR TO entry /* Main procedure */ PROC main() HANDLE DEF signal, result_DoMethod, running = TRUE muimasterbase := OpenLibrary('muimaster.library', 0) magicstart:=NIL magicstr:=NIL magicnr:=NIL create_app() /*set the keyboard tab Cycle*/ doMethod(mainWindow, [MUIM_Window_SetCycleChain, pop1,inputList, inputAdd, inputEdit, inputDel, inup, indown, intop, inbottom, pop2,outputList, outputAdd, outputEdit, outputDel, outup, outdown, outtop, outbottom, tmpfile, chcpin, chext, detect, goButt, detectButt, quitButt, NULL ]) doMethod(addWindow, [MUIM_Window_SetCycleChain, pop3, cmdLine, titel, mext, optList, optAddButt, optEdButt, ok, cancel, NULL ]) /* Notify : close gadget => end of application */ doMethod( mainWindow, [ MUIM_Notify, MUIA_Window_CloseRequest, MUI_TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit ] ) /* Notify: quit button => end of application */ doMethod(quitButt, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit ] ) /*Notify: Add button => open add window*/ doMethod(inputAdd, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_INADD ]) doMethod(outputAdd, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_OUTADD ]) /*Notify: addWindow close gadget => close window*/ doMethod( addWindow, [ MUIM_Notify, MUIA_Window_CloseRequest, MUI_TRUE, addWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE ] ) /*Notify: addWindow cancel => close window*/ doMethod( cancel, [ MUIM_Notify, MUIA_Pressed, FALSE, addWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE ] ) /*Notify: addWindow ok => return OK*/ doMethod( ok, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_ADD ]) /*Notify: input ed button & doubleclick => edit entry*/ doMethod( inputList, [ MUIM_Notify, MUIA_Listview_DoubleClick, MUI_TRUE, app, 2, MUIM_Application_ReturnID, ID_EDIN ]) doMethod( inputEdit, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_EDIN ]) /*Notify: output ed button & doubleclick => edit entry*/ doMethod( outputList, [ MUIM_Notify, MUIA_Listview_DoubleClick, MUI_TRUE, app, 2, MUIM_Application_ReturnID, ID_EDOUT ]) doMethod( outputEdit, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_EDOUT ]) /*Notify: input del => delete format*/ doMethod( inputDel, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_DELIN ]) /*Notify: output del => delete format*/ doMethod( outputDel, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_DELOUT ]) /*Notify: Go button => CONVERT*/ doMethod( goButt, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_GO ]) /*Notify: change input file => change output file*/ doMethod( pop1, [ MUIM_Notify, MUIA_String_Contents, MUIV_EveryTime, app, 2, MUIM_Application_ReturnID, ID_NEWFILE ]) /*Notify: detect format => detect format*/ doMethod( detectButt, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_DETECT ]) /*Notify: change output format => change output file*/ doMethod( outputList, [ MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, app, 2, MUIM_Application_ReturnID, ID_NEWFORM ]) /*Notify: input up => input up*/ doMethod( inup, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_INUP ]) /*Notify: input down => input down*/ doMethod( indown, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_INDOWN ]) /*Notify: input top => input top*/ doMethod( intop, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_INTOP ]) /*Notify: input bottom => input bottom*/ doMethod( inbottom, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_INBOTTOM ]) /*Notify: output up => movemenat*/ doMethod( outup, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_OUTUP ]) /*Notify: output down => movemenat*/ doMethod( outdown, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_OUTDOWN ]) /*Notify: output top => movemenat*/ doMethod( outtop, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_OUTTOP ]) /*Notify: output bottom => movemenat*/ doMethod( outbottom, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_OUTBOTTOM ]) /* Read the config */ filehandle := Open ('env:mui/PBM-Tool.config', OLDFILE) IF filehandle <> NIL list:=inputList WHILE i <> -1 i:=ReadStr(filehandle, line) IF (StrCmp(line,'#IN',ALL)) THEN list:=inputList IF (StrCmp(line,'#OUT',ALL)) THEN list:=outputList IF (StrCmp(line,'#TMPFILE',ALL)) i:=ReadStr(filehandle, line) set(tmpfile, MUIA_String_Contents, line) ENDIF IF (StrCmp(line,'#NOCPIN',ALL)) THEN set(chcpin, MUIA_Selected, FALSE) IF (StrCmp(line,'#NOCHEXT',ALL)) THEN set(chext, MUIA_Selected, FALSE) IF (StrCmp(line,'#NODETECT',ALL)) THEN set(detect, MUIA_Selected, FALSE) IF (StrCmp(line,'#',ALL)) entries:=New( SIZEOF entry ) i:=ReadStr(filehandle, line) entries.file:=String(StrLen(line)) StrCopy(entries.file, line, ALL) i:=ReadStr(filehandle, line) entries.cmdline:=String(StrLen(line)) StrCopy(entries.cmdline, line, ALL) i:=ReadStr(filehandle, line) entries.titel:=String(StrLen(line)) StrCopy(entries.titel, line, ALL) i:=ReadStr(filehandle, line) entries.magicext:=String(StrLen(line)) StrCopy(entries.magicext, line, ALL) doMethod(list, [MUIM_List_InsertSingle, entries,MUIV_List_Insert_Bottom ]) ENDIF ENDWHILE Close (filehandle) ENDIF create_magic() /* Open the window */ set( mainWindow, MUIA_Window_Open , MUI_TRUE ) WHILE running result_DoMethod := doMethod( app, [ MUIM_Application_Input, {signal} ] ) SELECT result_DoMethod CASE MUIV_Application_ReturnID_Quit get(pop1,MUIA_Popasl_Active,{active}); IF (active) ELSE get(pop2,MUIA_Popasl_Active,{active}); ENDIF IF (active) ELSE get(pop3,MUIA_Popasl_Active,{active}); ENDIF IF (active) ELSE running := FALSE; ENDIF CASE ID_INADD addwin(INPUT, NEW) CASE ID_OUTADD addwin(OUTPUT, NEW) CASE ID_EDIN doMethod(inputList, [MUIM_List_GetEntry, MUIV_List_GetEntry_Active, {entries} ]) IF (entries = 0) EasyRequestArgs(0,[20,0,0,'No input format selected', 'Ok'],0,[arg]) ELSE addwin(EDINPUT, entries) ENDIF CASE ID_EDOUT doMethod(outputList, [MUIM_List_GetEntry, MUIV_List_GetEntry_Active, {entries} ]) IF (entries = 0) EasyRequestArgs(0,[20,0,0,'No output format selected', 'Ok'],0,[arg]) ELSE addwin(EDOUTPUT, entries) ENDIF CASE ID_ADD set(addWindow, MUIA_Window_Open, FALSE) IF (what = INPUT) entries:=New( SIZEOF entry ) getentry (entries) doMethod(inputList, [MUIM_List_InsertSingle, entries,MUIV_List_Insert_Bottom ]) ELSEIF (what = OUTPUT) entries:=New( SIZEOF entry ) getentry (entries) doMethod(outputList, [MUIM_List_InsertSingle, entries,MUIV_List_Insert_Bottom ]) ELSEIF (what = EDINPUT) getentry(data) doMethod(inputList, [MUIM_List_Redraw, MUIV_List_Redraw_All]) ELSEIF (what = EDOUTPUT) getentry(data) doMethod(outputList, [MUIM_List_Redraw, MUIV_List_Redraw_All]) ELSE WriteF ('What am I to do?\n') ENDIF CASE ID_DELIN get(inputList,MUIA_List_Active,{active}); IF (active = MUIV_List_Active_Off) EasyRequestArgs(0,[20,0,0,'No input format selected', 'Ok'],0,[arg]) ELSE doMethod(inputList, [MUIM_List_Remove, active]) ENDIF CASE ID_DELOUT get(outputList,MUIA_List_Active,{active}); IF (active = MUIV_List_Active_Off) EasyRequestArgs(0,[20,0,0,'No output format selected', 'Ok'],0,[arg]) ELSE doMethod(outputList, [MUIM_List_Remove, active]) ENDIF CASE ID_GO set(mainWindow, MUIA_Window_Sleep, MUI_TRUE) doMethod(inputList, [MUIM_List_GetEntry, MUIV_List_GetEntry_Active, {entries} ]) IF (entries = 0) EasyRequestArgs(0,[20,0,0,'No input format selected', 'Ok'],0,[arg]) ELSE StrCopy(line, entries.file, ALL) StrAdd(line, ' ', ALL) StrAdd(line, entries.cmdline, ALL) doMethod(outputList, [MUIM_List_GetEntry, MUIV_List_GetEntry_Active, {entries} ]) IF (entries = 0) EasyRequestArgs(0,[20,0,0,'No output format selected', 'Ok'],0,[arg]) ELSE StrCopy(line2, entries.file, ALL) StrAdd(line2, ' ', ALL) StrAdd(line2, entries.cmdline, ALL) get(pop1, MUIA_String_Contents, {file1}) IF (StrLen(file1) = 0) EasyRequestArgs(0,[20,0,0, 'No input file name specifyed', 'Ok'],0,[arg]) ELSE get(pop2, MUIA_String_Contents, {file2}) IF (StrLen(file2) = 0) EasyRequestArgs(0,[20,0,0, 'No output file name specifyed', 'Ok'],0,[arg]) ELSE get(tmpfile, MUIA_String_Contents, {name}) IF (StrLen(name)<1) EasyRequestArgs(0,[20,0,0, 'No temp file specifyed', 'Ok'],0,[arg]) ELSE filehandle:=stdout stdout := Open ('ram:script', NEWFILE) IF (stdout = NIL) EasyRequestArgs(0,[20,0,0, 'Take it easy! I am not ready with your last operation', 'Ok'],0,[arg]) stdout:=filehandle ELSE conv(line, file1, name) conv(line2, name, file2) WriteF('delete \s\n',name) WriteF('endcli\n') Close (stdout) stdout := filehandle Execute('newcli from ram:script',0,stdout) ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF set(mainWindow, MUIA_Window_Sleep, FALSE) CASE ID_NEWFILE get(chcpin, MUIA_Selected, {active}) IF (active) get(pop1, MUIA_String_Contents, {name}) doMethod(pop2, [MUIM_Set, MUIA_String_Contents, name ]) ENDIF fixext (pop2, outputList) detect_format(CHECK) CASE ID_NEWFORM fixext (pop2, outputList) CASE ID_DETECT detect_format(FORCE) CASE ID_INUP get(inputList,MUIA_List_Active,{i}) doMethod(inputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) doMethod(inputList, [MUIM_List_Remove, i]) doMethod(inputList, [MUIM_List_InsertSingle, entries, i-1]) set(inputList,MUIA_List_Active,i-1) ENDIF CASE ID_INDOWN get(inputList,MUIA_List_Active,{i}) doMethod(inputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) doMethod(inputList, [MUIM_List_Remove, i]) doMethod(inputList, [MUIM_List_InsertSingle, entries, i+1]) set(inputList,MUIA_List_Active,i+1) ENDIF CASE ID_INTOP get(inputList,MUIA_List_Active,{i}) doMethod(inputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) doMethod(inputList, [MUIM_List_Remove, i]) doMethod(inputList, [MUIM_List_InsertSingle, entries, MUIV_List_Insert_Top]) set(inputList,MUIA_List_Active,MUIV_List_Active_Top) ENDIF CASE ID_INBOTTOM get(inputList,MUIA_List_Active,{i}) doMethod(inputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) doMethod(inputList, [MUIM_List_Remove, i]) doMethod(inputList, [MUIM_List_InsertSingle, entries, MUIV_List_Insert_Bottom]) set(inputList,MUIA_List_Active,MUIV_List_Active_Bottom) ENDIF CASE ID_OUTUP get(outputList,MUIA_List_Active,{i}) doMethod(outputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) doMethod(outputList, [MUIM_List_Remove, i]) doMethod(outputList, [MUIM_List_InsertSingle, entries, i-1]) set(outputList,MUIA_List_Active,i-1) ENDIF CASE ID_OUTDOWN get(outputList,MUIA_List_Active,{i}) doMethod(outputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) doMethod(outputList, [MUIM_List_Remove, i]) doMethod(outputList, [MUIM_List_InsertSingle, entries, i+1]) set(outputList,MUIA_List_Active,i+1) ENDIF CASE ID_OUTTOP get(outputList,MUIA_List_Active,{i}) doMethod(outputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) doMethod(outputList, [MUIM_List_Remove, i]) doMethod(outputList, [MUIM_List_InsertSingle, entries, MUIV_List_Insert_Top]) set(outputList,MUIA_List_Active,MUIV_List_Active_Top) ENDIF CASE ID_OUTBOTTOM get(outputList,MUIA_List_Active,{i}) doMethod(outputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) doMethod(outputList, [MUIM_List_Remove, i]) doMethod(outputList, [MUIM_List_InsertSingle, entries, MUIV_List_Insert_Bottom]) set(outputList,MUIA_List_Active,MUIV_List_Active_Bottom) ENDIF ENDSELECT IF (running AND signal) THEN Wait( signal ) ENDWHILE /*saving config*/ filehandle := stdout stdout := Open ('env:mui/PBM-Tool.config', NEWFILE) IF stdout = NIL stdout := filehandle WriteF('Can not create config file (env:mui/PBM-Tool.config)\n') ELSE get(tmpfile, MUIA_String_Contents, {name}) WriteF('#TMPFILE\n\s\n',name) get(chcpin, MUIA_Selected, {active}) IF (active = FALSE) THEN WriteF('#NOCPIN\n') get(chext, MUIA_Selected, {active}) IF (active = FALSE) THEN WriteF('#NOCHEXT\n') get(detect, MUIA_Selected, {active}) IF (active = FALSE) THEN WriteF('#NODETECT\n') get(inputList, MUIA_List_Entries, {active}) WriteF('#IN\n\d\n',active) FOR i:=0 TO active-1 STEP 1 doMethod(inputList, [MUIM_List_GetEntry, i, {entries} ]) WriteF('#\n') WriteF('\s\n',entries.file) WriteF('\s\n',entries.cmdline) WriteF('\s\n',entries.titel) WriteF('\s\n',entries.magicext) ENDFOR get(outputList, MUIA_List_Entries, {active}) WriteF('#OUT\n\d\n',active) FOR i:=0 TO active-1 STEP 1 doMethod(outputList, [MUIM_List_GetEntry, i, {entries} ]) WriteF('#\n') WriteF('\s\n',entries.file) WriteF('\s\n',entries.cmdline) WriteF('\s\n',entries.titel) WriteF('\s\n',entries.magicext) ENDFOR Close (stdout) stdout := filehandle ENDIF Mui_DisposeObject( app ) CloseLibrary( muimasterbase ) CleanUp(0) EXCEPT SELECT exception CASE NO_LIBRARY CASE MUI_APPLICATION_FAILURE ENDSELECT ENDPROC /*detects the formats of the input file*/ PROC detect_format(how) get(detect, MUIA_Selected, {active}) IF (active OR (how = FORCE)) filehandle := Open(name, OLDFILE) IF (filehandle <> NIL) set(mainWindow, MUIA_Window_Sleep, MUI_TRUE) Read(filehandle, line, 50) Close(filehandle) FOR i:=0 TO magicnr-1 STEP 1 IF (StrLen(magicstr[i]) > 0) IF (StrCmp(line+magicstart[i], magicstr[i], StrLen(magicstr[i]))) doMethod(inputList, [MUIM_Set, MUIA_List_Active, i]) ENDIF ENDIF ENDFOR set(mainWindow, MUIA_Window_Sleep, FALSE) ENDIF ENDIF ENDPROC /*creates the list of magic numbers*/ PROC create_magic() IF (magicnr <> NIL) FOR i:=0 TO magicnr-1 STEP 1 Dispose(magicstr[i]) ENDFOR ENDIF IF (magicstart <> NIL) THEN Dispose(magicstart) IF (magicstr <> NIL) THEN Dispose(magicstr) magicstart:=NIL magicstr:=NIL get(inputList, MUIA_List_Entries, {magicnr}) IF (magicnr > 0) magicstart:=List(magicnr+1) magicstr:=List(magicnr+1) FOR i:=0 TO magicnr STEP 1 doMethod(inputList, [MUIM_List_GetEntry, i, {entries} ]) IF (entries <> 0) pos:=InStr(entries.magicext, ',', ALL) IF (pos <> -1) StrCopy(line2, entries.magicext, pos) var:=Val(line2, NIL) StrCopy(line2, '', ALL) a:=0 FOR j:=pos+1 TO StrLen(entries.magicext)-1 STEP 3 StrCopy(temp, entries.magicext+j, 3) pos:=Val(temp, NIL) line2[a]:=pos a:=a+1 ENDFOR line2[a]:=0 a:=a+1 magicstart[i]:=var magicstr[i]:=String(a+1) StrCopy(magicstr[i], line2, a) ENDIF ENDIF ENDFOR ELSE magicnr:=NIL ENDIF ENDPROC /* fixes the string gadget str to have the extention of the selected iteam of list */ PROC fixext(str, list) DEF strn[80]:STRING, strp:PTR TO CHAR, ent:PTR TO entry DEF pos, oldpos get(chext, MUIA_Selected, {active}) IF (active) get(str, MUIA_String_Contents, {strp}) IF (StrLen(strp) > 0) StrCopy(strn, strp, ALL) doMethod(list, [MUIM_List_GetEntry, MUIV_List_GetEntry_Active, {ent} ]) pos:=0 oldpos:=0 WHILE pos <> -1 pos:=InStr(strn,'.',oldpos) IF (pos <> -1) THEN oldpos:=pos+1 ENDWHILE IF (oldpos <> 0) StrCopy(strn, strn, oldpos) ELSE StrAdd(strn, '.', ALL) ENDIF IF (ent = 0) StrAdd(strn, 'out', ALL) ELSE StrAdd(strn, ent.magicext, ALL) ENDIF set(str, MUIA_String_Contents, strn) ENDIF ENDIF ENDPROC /* creates the convertions strings */ PROC conv(cmd:PTR TO CHAR, infile:PTR TO CHAR, outfile:PTR TO CHAR) DEF str[100]:STRING, pos, oldpos, tmp[100]:STRING oldpos:=0 pos:=0 StrCopy(str, '', ALL) WHILE pos <> -1 pos := InStr(cmd, '$', oldpos) IF pos <> -1 MidStr(tmp, cmd, oldpos, pos-oldpos) StrAdd(str, tmp, ALL) MidStr(tmp, cmd, pos, ALL) IF (StrCmp(tmp, '$in', 3)) StrAdd(str, infile, ALL) oldpos:=pos+3 ELSEIF (StrCmp(tmp, '$out', 4)) StrAdd(str, outfile, ALL) oldpos:=pos+4 ELSE StrAdd(str, '$', ALL) oldpos:=pos+1 ENDIF ELSE StrAdd(str, cmd+oldpos, ALL) ENDIF ENDWHILE IF(StrCmp(str, ' ', ALL)) WriteF('copy \s \s\n', infile, outfile) ELSE WriteF('\s\n',str) ENDIF ENDPROC /* Procedure to move data from the add window to the obj entry*/ PROC getentry(obj:PTR TO entry) get(titel, MUIA_String_Contents, {name}) obj.titel:=String(StrLen(name)) StrCopy(obj.titel, name, ALL) get(pop3, MUIA_String_Contents, {name}) obj.file:=String(StrLen(name)) StrCopy(obj.file, name, ALL) get(cmdLine, MUIA_String_Contents, {name}) obj.cmdline:=String(StrLen(name)) StrCopy(obj.cmdline, name, ALL) get(mext, MUIA_String_Contents, {name}) obj.magicext:=String(StrLen(name)) StrCopy(obj.magicext, name, ALL) ENDPROC /* Procedure to open the addWindow with the right data */ PROC addwin(type, obj:PTR TO entry) get(addWindow,MUIA_Window_Open,{active}); IF (active) ELSE IF (type = OUTPUT) set(addWindow, MUIA_Window_Title, 'Add output format...') ELSEIF (type = INPUT) set(addWindow, MUIA_Window_Title, 'Add input format...') ELSEIF (type = EDINPUT) set(addWindow, MUIA_Window_Title, 'Edit input format...') ELSEIF (type = EDOUTPUT) set(addWindow, MUIA_Window_Title, 'Edit output format...') ELSE set(addWindow, MUIA_Window_Title, 'Format...') ENDIF what:=type data:=obj IF (obj=NEW) doMethod(pop3, [MUIM_Set, MUIA_String_Contents, '' ]) doMethod(cmdLine, [MUIM_Set, MUIA_String_Contents, '$in >$out' ]) doMethod(titel, [MUIM_Set, MUIA_String_Contents, '' ]) doMethod(mext, [MUIM_Set, MUIA_String_Contents, '' ]) ELSE doMethod(pop3, [MUIM_Set, MUIA_String_Contents, obj.file ]) doMethod(cmdLine, [MUIM_Set, MUIA_String_Contents, obj.cmdline ]) doMethod(titel, [MUIM_Set, MUIA_String_Contents, obj.titel ]) doMethod(mext, [MUIM_Set, MUIA_String_Contents, obj.magicext ]) ENDIF set(addWindow, MUIA_Window_Open, MUI_TRUE) ENDIF ENDPROC PROC display_pd_prog() DEF pd_prog: PTR TO entry DEF string_array : PTR TO LONG DEF the_hook : PTR TO hook /* be careful : your procedure code must begin by the 3 following assembly lines ! */ MOVE.L A0 , the_hook /* pointer on the hook object itself */ MOVE.L A1 , pd_prog /* pointer on one object of the list to display */ MOVE.L A2 , string_array /*pointer to the string array to fill*/ /* now you can really begin your code */ ^string_array := pd_prog.titel ENDPROC PROC sort_order() DEF a,i DEF tstr1:PTR TO entry, tstr2:PTR TO entry DEF str1:PTR TO CHAR, str2:PTR TO CHAR MOVE.L A1, tstr1 MOVE.L A2, tstr2 str1:=String(StrLen(tstr1.titel)) StrCopy(str1, tstr1.titel, ALL) LowerStr(str1) str2:=String(StrLen(tstr2.titel)) StrCopy(str2, tstr2.titel, ALL) LowerStr(str2) i:=0 a:=0 WHILE (a=0 AND i str2[i]) THEN a:=1 IF (str1[i] < str2[i]) THEN a:=-1 i:=i+1 ENDWHILE ENDPROC a /* Procedure generated by GenCodeE which creates your application */ PROC create_app() DEF hook_display_pd_prog : PTR TO hook hook_display_pd_prog := New( SIZEOF hook ) hook_display_pd_prog.entry := {display_pd_prog} app := ApplicationObject, MUIA_Application_Author, 'hakan@hera.dit.lth.se', MUIA_Application_Base, 'PBM', MUIA_Application_Title, 'PBM Tool', MUIA_Application_Version, '$VER PBM Tool 0.1', MUIA_Application_Copyright, 'Standard GNU copyright', MUIA_Application_Description, 'Intutition tool for converting pictures', MUIA_HelpFile, 'help:english/PBM-Tool.guide', SubWindow, mainWindow := WindowObject, MUIA_Window_Title, 'PBM Tool', MUIA_Window_ID, MAKE_ID( "0", "W", "I", "N" ), MUIA_HelpNode, 'Main window', WindowContents, GroupObject, Child, GroupObject, MUIA_Group_Horiz, MUI_TRUE, Child, GroupObject, GroupFrameT( 'Input' ), Child, pop1 := PopaslObject, MUIA_Popstring_String, KeyString(0,256,'f'), MUIA_Popstring_Button, PopButton(MUII_PopFile), MUIA_HelpNode, 'Input filename', End, Child, inputList := ListviewObject, MUIA_Listview_List, ListObject, InputListFrame, MUIA_List_DisplayHook, hook_display_pd_prog, End, MUIA_HelpNode, 'Input Formatlist', End, Child, GroupObject, MUIA_Group_Horiz, MUI_TRUE, Child, HVSpace, Child, inputAdd := TextObject, ButtonFrame, MUIA_Text_Contents, 'Add...', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Add button', End, Child, HVSpace, Child, inputEdit := TextObject, ButtonFrame, MUIA_Text_Contents, 'Edit...', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Edit button', End, Child, HVSpace, Child, inputDel := TextObject, ButtonFrame, MUIA_Text_Contents, 'Del', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Del button', End, Child, HVSpace, End, Child, GroupObject, MUIA_Group_Horiz, MUI_TRUE, Child, HVSpace, Child, inup := TextObject, ButtonFrame, MUIA_Text_Contents, 'Up', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Move buttons', End, Child, HVSpace, Child, indown := TextObject, ButtonFrame, MUIA_Text_Contents, 'Down', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Move buttons', End, Child, HVSpace, Child, intop := TextObject, ButtonFrame, MUIA_Text_Contents, 'Top', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Move buttons', End, Child, HVSpace, Child, inbottom := TextObject, ButtonFrame, MUIA_Text_Contents, 'Bottom', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Move buttons', End, Child, HVSpace, End, End, Child, GroupObject, GroupFrameT( 'Output' ), Child, pop2 := PopaslObject, MUIA_Popstring_String, KeyString(0,256,'f'), MUIA_Popstring_Button, PopButton(MUII_PopFile), MUIA_HelpNode, 'Output filename', End, Child, outputList := ListviewObject, MUIA_Listview_List, ListObject, InputListFrame, MUIA_List_DisplayHook, hook_display_pd_prog, End, MUIA_HelpNode, 'Output Formatlist', End, Child, GroupObject, MUIA_Group_Horiz, MUI_TRUE, Child, HVSpace, Child, outputAdd := TextObject, ButtonFrame, MUIA_Text_Contents, 'Add...', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Add button', End, Child, HVSpace, Child, outputEdit := TextObject, ButtonFrame, MUIA_Text_Contents, 'Edit...', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Edit button', End, Child, HVSpace, Child, outputDel := TextObject, ButtonFrame, MUIA_Text_Contents, 'Del', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Del button', End, Child, HVSpace, End, Child, GroupObject, MUIA_Group_Horiz, MUI_TRUE, Child, HVSpace, Child, outup := TextObject, ButtonFrame, MUIA_Text_Contents, 'Up', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Move buttons', End, Child, HVSpace, Child, outdown := TextObject, ButtonFrame, MUIA_Text_Contents, 'Down', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Move buttons', End, Child, HVSpace, Child, outtop := TextObject, ButtonFrame, MUIA_Text_Contents, 'Top', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Move buttons', End, Child, HVSpace, Child, outbottom := TextObject, ButtonFrame, MUIA_Text_Contents, 'Bottom', MUIA_Text_PreParse, '\ec', MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Move buttons', End, Child, HVSpace, End, End, End, Child, GroupObject, MUIA_Group_Columns, 2, Child, Label( 'Temp File' ), Child, tmpfile := StringObject, StringFrame, MUIA_String_MaxLen, 80, MUIA_String_Format, 0, MUIA_String_Contents, 'ram:temp.ppm', MUIA_HelpNode, 'Temp File', End, End, Child, ColGroup( 2 ), Child, chcpin := CheckMark( TRUE ), Child, Label2( 'Copy Input filename to output filename' ), Child, HVSpace, MUIA_HelpNode, 'Copy Input filename', End, Child, ColGroup( 2 ), Child, chext := CheckMark( TRUE ), Child, Label2( 'Change output extention' ), Child, HVSpace, MUIA_HelpNode, 'Change output extention', End, Child, ColGroup( 2 ), Child, detect := CheckMark( TRUE ), Child, Label2( 'Detect input format automatically' ), Child, HVSpace, MUIA_HelpNode, 'Detece input format automatically', End, Child, GroupObject, MUIA_Group_Horiz, MUI_TRUE, Child, goButt := TextObject, ButtonFrame, MUIA_Text_Contents, 'Go...', MUIA_Text_PreParse, '\ec', MUIA_Text_HiChar, "g", MUIA_ControlChar, "g", MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, MUIA_HelpNode, 'Go button', End, Child, detectButt := TextObject, ButtonFrame, MUIA_Text_Contents, 'Detect format', MUIA_Text_PreParse, '\ec', MUIA_Text_HiChar, "d", MUIA_ControlChar, "d", MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 1, MUIA_HelpNode, 'Detect button', End, Child, HVSpace, Child, quitButt := TextObject, ButtonFrame, MUIA_Text_Contents, 'Quit', MUIA_Text_PreParse, '\ec', MUIA_Text_HiChar, "q", MUIA_ControlChar, "q", MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 1, MUIA_HelpNode, 'Quit button', End, End, End, End, SubWindow, addWindow := WindowObject, MUIA_Window_Title, 'Add format...', MUIA_Window_ID, MAKE_ID( "1", "W", "I", "N" ), MUIA_HelpNode, 'Add window', WindowContents, GroupObject, Child, GroupObject, MUIA_Group_Columns, 2, Child, Label( 'File' ), Child, pop3 := PopaslObject, MUIA_Popstring_String, KeyString(0,256,'f'), MUIA_Popstring_Button, PopButton(MUII_PopFile), MUIA_HelpNode, 'Add window File', End, Child, Label( 'Format' ), Child, cmdLine := StringObject, StringFrame, MUIA_String_MaxLen, 80, MUIA_String_Format, 0, MUIA_HelpNode, 'Add window Format', End, Child, Label( 'Title' ), Child, titel := StringObject, StringFrame, MUIA_String_MaxLen, 80, MUIA_String_Format, 0, MUIA_HelpNode, 'Add window Title', End, Child, Label( 'Magic/Ext' ), Child, mext := StringObject, StringFrame, MUIA_String_MaxLen, 80, MUIA_String_Format, 0, MUIA_HelpNode, 'Add window Magic-Ext', End, End, Child, GroupObject, MUIA_Group_Horiz, MUI_TRUE, Child, GroupObject, MUIA_HelpNode, 'Add window Options', GroupFrameT( 'Options' ), Child, optList := ListviewObject, MUIA_Listview_List, ListObject, InputListFrame, MUIA_Listview_DoubleClick, MUI_TRUE, End, End, Child, optAddButt := TextObject, ButtonFrame, MUIA_Text_Contents, 'Add...', MUIA_Text_PreParse, '\ec', MUIA_Text_HiChar, "a", MUIA_ControlChar, "a", MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 0, End, Child, optEdButt := KeyButton( 'Edit...', "e" ), End, End, Child, GroupObject, MUIA_Group_Horiz, MUI_TRUE, Child, ok := TextObject, ButtonFrame, MUIA_Text_Contents, 'Ok', MUIA_Text_PreParse, '\ec', MUIA_Text_HiChar, "o", MUIA_ControlChar, "o", MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 30, MUIA_HelpNode, 'Add window Ok', End, Child, HVSpace, Child, cancel := TextObject, ButtonFrame, MUIA_Text_Contents, 'Cancel', MUIA_Text_PreParse, '\ec', MUIA_Text_HiChar, "c", MUIA_ControlChar, "c", MUIA_InputMode, 1, MUIA_Background, 2, MUIA_Weight, 30, MUIA_HelpNode, 'Add window Cancel', End, End, End, End, End ENDPROC /* DoMethod() function */ PROC doMethod( obj:PTR TO object, msg:PTR TO msg ) DEF h:PTR TO hook, o:PTR TO object, dispatcher IF obj o := obj-SIZEOF object /* instance data is to negative offset */ h := o.class dispatcher := h.entry /* get dispatcher from hook in iclass */ MOVEA.L h,A0 MOVEA.L msg,A1 MOVEA.L obj,A2 /* probably should use CallHookPkt, but the */ MOVEA.L dispatcher,A3 /* original code (DoMethodA()) doesn't. */ JSR (A3) /* call classDispatcher() */ MOVE.L D0,o RETURN o ENDIF ENDPROC NIL