I don't know if it is the right place for this topic, in case it is not right please move it in right location of the forum.
What I am trying to achieve is to execute an external program from a gui. When user click the button, it run the program. My work is based from this documentation that I found using Google. It is the amiga wiki page. Here is the link of the page:
http://wiki.amigaos.net/wiki/Executing_External_Programs
First i created this simple program to test if it works and indeed it works. When I place this little program inside the directory where the program is, it works without problems but when I insert this little piece of code inside my main project, it runs but the main window of the program trashes and then the system freezes. I suspect I need more code to add but I don't know where to look at..
Test program:
#include <stdio.h> #include <proto/exec.h> #include <proto/dos.h> #include <dos/dostags.h> CONST_STRPTR command = "mame rastan cgfx requester frameskip 1 rate 22050"; BPTR file; uint8 *autoconsole="CON:0/0/600/150/Mame/AUTO/CLOSE/WAIT"; int main(){ if(file = IDOS->Open(autoconsole,MODE_OLDFILE)){ return IDOS->SystemTags(command, SYS_Input, file, SYS_Asynch, TRUE, SYS_Output, NULL, SYS_UserShell, TRUE, TAG_END); } else return(RETURN_FAIL); }
Code inside main project:
// MAME GUI by Davide "Nubechecorre" Palombo // use "gcc -o mamegui mamegui.c" to compile // Include required libraries and gadgets classes #include <stdio.h> #include <proto/exec.h> #include <proto/dos.h> #include <proto/intuition.h> #include <proto/listbrowser.h> #include <proto/wb.h> #include <dos/dostags.h> #include <classes/window.h> #include <gadgets/button.h> #include <gadgets/layout.h> #include <gadgets/listbrowser.h> #include <gadgets/checkbox.h> #include <gadgets/slider.h> #include <gadgets/radiobutton.h> #include <gadgets/scroller.h> #include <gadgets/integer.h> #include <images/label.h> #include <images/bitmap.h> // Declare all the struct libraries and Intefaces struct ClassLibrary *WindowBase; Class *WindowClass; struct ClassLibrary *LayoutBase; Class *LayoutClass; struct ClassLibrary *ButtonBase; Class *ButtonClass; struct ClassLibrary *LabelBase; Class *LabelClass; struct ClassLibrary *BitMapBase; Class *BitMapClass; struct ClassLibrary *CheckBoxBase; Class *CheckBoxClass; struct ClassLibrary *SliderBase; Class *SliderClass; struct ClassLibrary *ScrollerBase; Class *ScrollerClass; struct ClassLibrary *IntegerBase; Class *IntegerClass; struct ClassLibrary *RadioButtonBase; Class *RadioButtonClass; struct Library *ListBrowserBase; Class *ListBrowserClass; struct ListBrowserIFace *IListBrowser; struct Library *IntuitionBase; struct IntuitionIFace *IIntuition; struct Library *WorkbenchBase; struct WorkbenchIFace *IWorkbench; // Struct Window for my Window App struct Window *window; // Struct Screen for the image to be displayed struct Screen *screen; // Struct List for listbrowser, ColumnInfo and Node struct List *listbrowser_list; struct Node *node; // Populate the listbrowser node CONST_STRPTR nodetexts[] = { "Double Dragon", "Rastan", "Street Fighter", "Operation Wolf", "Out Run", "Dragon Ninja", "Ninja Warriors", "Operation Thunderbolt", "Turbo Outrun", "Knights of the round", NULL }; // With C "Enum" and "Object *" I create/enumerate all the elements for my Gui enum{ OID_WINDOW, OID_WINDOW_LAYOUT, OID_BANNER, OID_BITMAP, OID_CONTAINER, OID_LISTBROWSER, OID_CONTAINER_TOP, OID_CHECKBOX_1, OID_CHECKBOX_2, OID_CHECKBOX_3, OID_CHECKBOX_4, OID_CHECKBOX_5, OID_HLAYOUT, OID_VLAYOUT_1, OID_VLAYOUT_2, OID_INTEGER, OID_SLIDER, OID_RADIOBUTTON, OID_LAYOUT_L, OID_LAYOUT_R, OID_LAYOUT_SOUND, OID_BSTART, OID_LAST }; Object *objects[OID_LAST]; // This is the minimun amount of stack for my program static const char USED minstack[]="$STACK:80000"; // This is the string used for the version command under CLI/SHELL to see the version of the program STATIC CONST_STRPTR version USED = "$VER: mamegui version 1.0 (06.05.2018)"; // This is the string used to run the program CONST_STRPTR command = "mame rastan cgfx requester frameskip 1 rate 22050"; // file to use as buffer for the console BPTR file; // console to use for command uint8 *autoconsole="CON:0/0/600/150/mame/AUTO/CLOSE/WAIT"; // This is the main loop of the program int main(){ // initialize variable for later use in the listbrowser int i; // Create radiobutton label list CONST_STRPTR radiolist[] = {"11025","22050",NULL}; // Here I open all the required libraries and classes IntuitionBase = IExec->OpenLibrary("intuition.library", 52); if(IntuitionBase == NULL){ IDOS->Printf("Unable to get IntuitionBase pointer, unable to open the library\n"); }else{ IDOS->Printf("Get IntuitionBase pointer, library opened \n"); } IIntuition = (struct IntuitionIFace *)IExec->GetInterface(IntuitionBase,"main",1,NULL); if(IIntuition == NULL){ IDOS->Printf("Unable to get Intuition Interface\n"); return(0); }else{ IDOS->Printf("Get Intuition Interface\n"); } WorkbenchBase = IExec->OpenLibrary("workbench.library", 52); if(WorkbenchBase == NULL){ IDOS->Printf("Unable to get WorkbenchBase pointer, unable to open the library\n"); }else{ IDOS->Printf("Get WorkbenchBase pointer, library opened \n"); } IWorkbench = (struct WorkbenchIFace *)IExec->GetInterface(WorkbenchBase,"main",1,NULL); if(IWorkbench == NULL){ IDOS->Printf("Unable to get Workbench Interface\n"); return(0); }else{ IDOS->Printf("Get Workbench Interface\n"); } WindowBase = IIntuition->OpenClass("window.class", 52, &WindowClass); if(WindowBase == NULL){ IDOS->Printf("Unable to get WindowBase, unable to get Window Class\n"); return(0); }else{ IDOS->Printf("Get WindowBase pointer, Window Class opened\n"); } LayoutBase = IIntuition->OpenClass("gadgets/layout.gadget", 52, &LayoutClass); if(LayoutBase == NULL){ IDOS->Printf("Unable to get LayoutBase, unable to open Layout Class\n"); return(0); }else{ IDOS->Printf("Get LayoutBase, Layout Class opened\n"); } ButtonBase = (struct ClassLibrary *)IIntuition->OpenClass("gadgets/button.gadget", 52, &ButtonClass); if(ButtonBase == NULL){ IDOS->Printf("Unable to GetButtonBase, unable to open Button Class\n"); return(0); }else{ IDOS->Printf("Get ButtonBase, Button Class opened\n"); } LabelBase = (struct ClassLibrary *)IIntuition->OpenClass("images/label.image", 52, &LabelClass); if(LabelBase == NULL){ IDOS->Printf("Unable to get LabelBase, unable to open Label Class\n"); return(0); }else{ IDOS->Printf("Get LabelBase, Label Class opened\n"); } BitMapBase = (struct ClassLibrary *)IIntuition->OpenClass("images/bitmap.image", 52, &BitMapClass); if(BitMapBase == NULL){ IDOS->Printf("Unable to get BitMapBase, unable to open BitMap Class\n"); return(0); }else{ IDOS->Printf("Get BitMapBase, BitMap Class opened\n"); } ListBrowserBase = (struct Library *)IIntuition->OpenClass("gadgets/listbrowser.gadget", 52, &ListBrowserClass); if(ListBrowserBase == NULL){ IDOS->Printf("Unable to get ListBrowserBase, unable to open ListBrowser Class\n"); return(0); }else{ IDOS->Printf("Get ListBrowserBase, ListBrowser Class opened\n"); } IListBrowser = (struct ListBrowserIFace *)IExec->GetInterface((struct Library *)ListBrowserBase,"main",1,NULL); if(IListBrowser == NULL){ IDOS->Printf("Unable to get ListBrowser Interface\n"); return(0); }else{ IDOS->Printf("Get ListBrowser Interface\n"); } CheckBoxBase = IIntuition->OpenClass("gadgets/checkbox.gadget", 52, &CheckBoxClass); if(CheckBoxBase == NULL){ IDOS->Printf("Unable to get CheckBoxBase, unable to open CheckBox Class\n"); return(0); }else{ IDOS->Printf("Get CheckBoxBase, CheckBox Class opened\n"); } SliderBase = IIntuition->OpenClass("gadgets/slider.gadget", 52, &SliderClass); if(SliderBase == NULL){ IDOS->Printf("Unable to get SliderBase, unable to open Slider Class\n"); return(0); }else{ IDOS->Printf("Get SliderBase, Slider Class opened\n"); } ScrollerBase = IIntuition->OpenClass("gadgets/scroller.gadget", 52, &ScrollerClass); if(ScrollerBase == NULL){ IDOS->Printf("Unable to get ScrollerBase, unable to open Scroller Class\n"); return(0); }else{ IDOS->Printf("Get ScrollerBase, Scroller Class opened\n"); } RadioButtonBase = IIntuition->OpenClass("gadgets/radiobutton.gadget", 52, &RadioButtonClass); if(RadioButtonBase == NULL){ IDOS->Printf("Unable to get RadioButtonBase, unable to open RadioButton Class\n"); return(0); }else{ IDOS->Printf("Get RadioButtonBase, RadioButton Class opened\n"); } IntegerBase = IIntuition->OpenClass("gadgets/integer.gadget", 52, &IntegerClass); if(IntegerBase == NULL){ IDOS->Printf("Unable to get IntegerBase, unable to open Integer Class\n"); return(0); }else{ IDOS->Printf("Get IntegerBase, Integer Class opened\n"); } // Allocate the listbrowser list. listbrowser_list = (struct List *) IExec->AllocSysObject(ASOT_LIST, NULL); if (listbrowser_list == NULL) { // Here you should free the resources allocated above // and report memory error; we'll just exit for now. return RETURN_FAIL; } // Loop to populate ListBrowser list and Node for (i=0; nodetexts<em>; i++) { node = IListBrowser->AllocListBrowserNode(1, //LBNA_Flags, LBFLG_CUSTOMPENS, LBNA_Column, 0, LBNCA_Text, nodetexts<em>, //LBNCA_FGPen, TEXTPEN, TAG_END); if (node) IExec->AddTail(listbrowser_list, node); } if(screen = IIntuition->LockPubScreen(NULL)){ objects[OID_WINDOW] = IIntuition->NewObject(WindowClass, NULL, WA_ScreenTitle, "MameGui - By Davide Palombo V. 1.0", WA_Title, "MameGui", WA_Width, 800, WA_Height, 600, WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SizeGadget, TRUE, WA_DepthGadget, TRUE, WA_Activate, TRUE, WINDOW_IconifyGadget, TRUE, WINDOW_Position, WPOS_CENTERSCREEN, WA_NewLookMenus, TRUE, WA_FadeTime, 800000, WA_AutoAdjust, TRUE, WA_PubScreen, screen, WINDOW_GadgetHelp, TRUE, WINDOW_Layout, objects[OID_WINDOW_LAYOUT] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_VERT, LAYOUT_SpaceOuter, TRUE, LAYOUT_AddChild, objects[OID_BANNER] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ, LAYOUT_SpaceOuter, TRUE, LAYOUT_VertAlignment, LALIGN_TOP, LAYOUT_AddImage, objects[OID_BITMAP] = IIntuition->NewObject(BitMapClass, NULL, BITMAP_Screen, screen, BITMAP_Masking, TRUE, BITMAP_Transparent, TRUE, BITMAP_OffsetX, 0, BITMAP_OffsetY, 0, BITMAP_Width, 400, BITMAP_Height, 138, BITMAP_SourceFile, "PROGDIR:img/logo-mame.png", TAG_END), // end of BitMap Object TAG_END), // end of oid_banner LAYOUT_AddChild, objects[OID_CONTAINER] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ, LAYOUT_SpaceOuter, TRUE, LAYOUT_AddChild, objects[OID_LAYOUT_L] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_VERT, LAYOUT_SpaceOuter, TRUE, LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_VERT, LAYOUT_SpaceOuter, TRUE, LAYOUT_BevelStyle, BVS_GROUP, LAYOUT_Label, " Games List ", LAYOUT_AddChild, objects[OID_LISTBROWSER] = IIntuition->NewObject(ListBrowserClass, NULL, LISTBROWSER_Labels, listbrowser_list, LISTBROWSER_MultiSelect, FALSE, LISTBROWSER_ShowSelected, TRUE, TAG_END), // end of ListBrowser TAG_END), // end of bvs_group games_list TAG_END), // end of oid_layout_l LAYOUT_AddChild, objects[OID_LAYOUT_R] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_VERT, LAYOUT_SpaceOuter, TRUE, LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_VERT, LAYOUT_SpaceOuter, TRUE, LAYOUT_BevelStyle, BVS_GROUP, LAYOUT_Label, " Screenshots ", TAG_END), // end of bvs_group screenshots LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_VERT, LAYOUT_SpaceOuter, TRUE, LAYOUT_BevelStyle, BVS_GROUP, LAYOUT_Label, " Options ", LAYOUT_AddChild, objects[OID_CONTAINER_TOP] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ, //LAYOUT_SpaceOuter, TRUE, LAYOUT_AddChild, objects[OID_VLAYOUT_1] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation,LAYOUT_ORIENT_VERT, LAYOUT_AddChild, objects[OID_CHECKBOX_1] = IIntuition->NewObject(CheckBoxClass, NULL, GA_ID, OID_CHECKBOX_1, GA_RelVerify, TRUE, GA_Text, "_Request", GA_HintInfo, "A requester pops up asking you for the right screen mode to open", GA_Selected, FALSE, CHECKBOX_TextPlace, PLACETEXT_RIGHT, TAG_END), // end of chekbox_1 LAYOUT_AddChild, objects[OID_CHECKBOX_2] = IIntuition->NewObject(CheckBoxClass, NULL, GA_ID, OID_CHECKBOX_2, GA_RelVerify, TRUE, GA_HintInfo, "Enable/Disable the Joypad", GA_Selected, FALSE, GA_Text, "_Joypad", CHECKBOX_TextPlace, PLACETEXT_RIGHT, TAG_END), // end of chekbox_2 TAG_END), // end of vlayout_1 LAYOUT_AddChild, objects[OID_VLAYOUT_2] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation,LAYOUT_ORIENT_VERT, LAYOUT_AddChild, objects[OID_CHECKBOX_4] = IIntuition->NewObject(CheckBoxClass, NULL, GA_ID, OID_CHECKBOX_4, GA_RelVerify, TRUE, GA_HintInfo, "use CyberGraphics instead of direct gfxmem access", GA_Selected, FALSE, GA_Text, "_Cgfx", CHECKBOX_TextPlace, PLACETEXT_RIGHT, TAG_END), // end of chekbox_4 LAYOUT_AddChild, objects[OID_HLAYOUT] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ, //LAYOUT_SpaceInner, TRUE, LAYOUT_VertAlignment, LALIGN_BOTTOM, LAYOUT_AddChild, objects[OID_CHECKBOX_5] = IIntuition->NewObject(CheckBoxClass, NULL, GA_ID, OID_CHECKBOX_5, GA_RelVerify, TRUE, GA_HintInfo, "frameskip 1-9 (def: 3)", GA_Selected, FALSE, GA_Text, "_Frameskip", CHECKBOX_TextPlace, PLACETEXT_RIGHT, TAG_END), // end of chekbox_5 LAYOUT_AddChild, objects[OID_INTEGER] = IIntuition->NewObject(IntegerClass, NULL, GA_ID, OID_INTEGER, GA_RelVerify, TRUE, GA_Disabled, TRUE, INTEGER_Arrows, TRUE, INTEGER_MaxChars, 3, INTEGER_Minimum, 0, INTEGER_Maximum, 9, INTEGER_Number, 0, TAG_END), // end of oid_integer TAG_END), // end of hlayout TAG_END), // end of vlayout_2 TAG_END), // end of container_top LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ, //LAYOUT_SpaceOuter, TRUE, LAYOUT_BevelStyle, BVS_GROUP, LAYOUT_Label, " Sound ", LAYOUT_AddChild, objects[OID_LAYOUT_SOUND] = IIntuition->NewObject(LayoutClass, NULL, LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ, //LAYOUT_SpaceOuter, TRUE, LAYOUT_AddChild, objects[OID_CHECKBOX_3] = IIntuition->NewObject(CheckBoxClass, NULL, GA_ID, OID_CHECKBOX_3, GA_RelVerify, TRUE, GA_HintInfo, "Enable/Disable sound emulation", GA_Selected, FALSE, GA_Text, "_Sound", GA_Disabled, FALSE, CHECKBOX_TextPlace, PLACETEXT_RIGHT, TAG_END), // end of chekbox_3 LAYOUT_AddChild, objects[OID_RADIOBUTTON] = IIntuition->NewObject(RadioButtonClass, NULL, GA_ID, OID_RADIOBUTTON, GA_RelVerify, TRUE, GA_Text, radiolist, GA_Disabled, TRUE, RADIOBUTTON_Selected, 1, TAG_END), // end of radio_button TAG_END), // end of oid_layout_sound TAG_END), // end of bvs_group sound TAG_END), // end of bvs_group options TAG_END), // end of oid_layout_r TAG_END), // end of oid_container LAYOUT_AddChild, objects[OID_BSTART] = IIntuition->NewObject(ButtonClass, NULL, GA_ID, OID_BSTART, GA_RelVerify, TRUE, GA_Text, "Start", TAG_END), TAG_END), // end of window_layout TAG_END); // end of window } if(objects[OID_WINDOW] != NULL) { struct Window *window = (struct Window *)IIntuition->IDoMethod(objects[OID_WINDOW], WM_OPEN, NULL); if(window != NULL) { uint32 signal = 0; IIntuition->GetAttr(WINDOW_SigMask,objects[OID_WINDOW],&signal); BOOL done = FALSE; // Our window is open, we can unlock the public screen. IIntuition->UnlockPubScreen(NULL, screen); while(!done) { uint32 wait = IExec->Wait(signal|SIGBREAKF_CTRL_C); if(wait & SIGBREAKF_CTRL_C) { done = TRUE; break; } if(wait & signal) { uint32 result = WMHI_LASTMSG; int16 code = 0; uint32 selected = 0; BOOL chk_sel = FALSE; while((result = IIntuition->IDoMethod(objects[OID_WINDOW],WM_HANDLEINPUT,&code)) != WMHI_LASTMSG) { switch(result & WMHI_CLASSMASK) //CLASSMASK RESTITUISCE LA PARTE BASSA DELLA WORD (L'ID) { case WMHI_GADGETUP: switch(result & WMHI_GADGETMASK) //LA GADGETMASK INVECE RESTITUISCE LA PARTE ALTA DELLA WORD IL BIT { case OID_CHECKBOX_1: IDOS->Printf("Hai premuto il checkbox_1\n"); break; case OID_CHECKBOX_2: IDOS->Printf("Hai premuto il checkbox_2\n"); break; case OID_RADIOBUTTON: IIntuition->GetAttr(RADIOBUTTON_Selected, objects[OID_RADIOBUTTON], &selected); IDOS->Printf("Hai premuto il RadioButton: codice=%lu scelta=%lu\n", code, selected); break; case OID_CHECKBOX_3: IIntuition->GetAttr(GA_Selected, objects[OID_CHECKBOX_3], &selected); IDOS->Printf("Hai premuto il checkbox sound: codice=%lu scelta=%lu\n", code, selected); if(selected==1){ IIntuition->RefreshSetGadgetAttrs((struct Gadget *)objects[OID_RADIOBUTTON], (struct Window *)window, NULL, GA_Disabled,FALSE, TAG_END); } if(selected==0){ IIntuition->RefreshSetGadgetAttrs((struct Gadget *)objects[OID_RADIOBUTTON], (struct Window *)window, NULL, GA_Disabled,TRUE, TAG_END); } break; case OID_CHECKBOX_5: IIntuition->GetAttr(GA_Selected, objects[OID_CHECKBOX_5], &selected); IDOS->Printf("Hai premuto il checkbox frameskip: codice=%lu scelta=%lu\n", code, selected); if(selected==1){ IIntuition->RefreshSetGadgetAttrs((struct Gadget *)objects[OID_INTEGER], (struct Window *)window, NULL, GA_Disabled,FALSE, TAG_END); } if(selected==0){ IIntuition->RefreshSetGadgetAttrs((struct Gadget *)objects[OID_INTEGER], (struct Window *)window, NULL, GA_Disabled,TRUE, TAG_END); } break; case OID_BSTART: if(file = IDOS->Open(autoconsole,MODE_OLDFILE)){ return IDOS->SystemTags(command, SYS_Input, file, SYS_Output, NULL, SYS_Asynch, TRUE, SYS_UserShell, TRUE, TAG_END); } else return(RETURN_FAIL); break; } break; case WMHI_CLOSEWINDOW: window = NULL; done = TRUE; break; } } } } } // Dispose/Close all object and libraries/classes resources IIntuition->DisposeObject(objects[OID_WINDOW]); if(listbrowser_list){ // Free the allocated list nodes. IListBrowser->FreeListBrowserList(listbrowser_list); // Free the allocated list structure. IExec->FreeSysObject(ASOT_LIST, listbrowser_list); } if(WindowBase){ IIntuition->CloseClass(WindowBase); IDOS->Printf("Window Class Closed\n"); } if(LayoutBase){ IIntuition->CloseClass(LayoutBase); IDOS->Printf("Layout Class Closed\n"); } if(ButtonBase){ IIntuition->CloseClass(ButtonBase); IDOS->Printf("Button Class Closed\n"); } if(LabelBase){ IIntuition->CloseClass(LabelBase); IDOS->Printf("LabelBase Class Closed\n"); } if(BitMapBase){ IIntuition->CloseClass(BitMapBase); IDOS->Printf("BitMap Class Closed\n"); } if(CheckBoxBase){ IIntuition->CloseClass(CheckBoxBase); IDOS->Printf("CheckBox Class Closed\n"); } if(SliderBase){ IIntuition->CloseClass(SliderBase); IDOS->Printf("Slider Class Closed\n"); } if(RadioButtonBase){ IIntuition->CloseClass(RadioButtonBase); IDOS->Printf("RadioButton Class Closed\n"); } if(ScrollerBase){ IIntuition->CloseClass(ScrollerBase); IDOS->Printf("Scroller Class Closed\n"); } if(IntegerBase){ IIntuition->CloseClass(IntegerBase); IDOS->Printf("Integer Class Closed\n"); } if(ListBrowserBase){ IExec->DropInterface((struct Interface *)IListBrowser); IIntuition->CloseClass((struct ClassLibrary *)ListBrowserBase); IDOS->Printf("ListBrowser Class Closed\n"); } if(WorkbenchBase){ IExec->DropInterface((struct Interface *)IWorkbench); IDOS->Printf("Workbench Interface Dropped\n"); IExec->CloseLibrary(WorkbenchBase); IDOS->Printf("Workbench Library Closed\n"); } if(IntuitionBase){ IExec->DropInterface((struct Interface *)IIntuition); IDOS->Printf("Intuition Interface Dropped\n"); IExec->CloseLibrary(IntuitionBase); IDOS->Printf("Intuition Library Closed\n"); } if(DOSBase){ IExec->DropInterface((struct Interface *)IDOS); printf("Dos Interface Dropped\n"); IExec->CloseLibrary(DOSBase); printf("Dos Library Closed\n"); } } // End of my program - RETURN_OK return RETURN_OK; }
before using the System() function I tried to use the WBOpenObject() function but i wasn't able to pass argument to the program so I tried the System() function thinking it was the right function to use but I have the problem above.. Any hint on where to find proper example or documentation?
Thanks,
Maybe I solved the problem but tell me if my solution is the right one..
I used this code when the user press the start button:
I changed from IDOS->Open() to IDOS->FOpen(). This function use buffered file so I guessed that could be the reason of trashed window and error when quitting the emulator..
Now i have no more error and trash window when i run the program.. It works both on shell and workbench.
Thanks,
Davide
I would like to mark my question as "solved" but I cannot edit my first post.. By the way the problem is solved :)
Hi, I do use this to execute/launch Time prefs. from a GUI:
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Thanks Jabirulo :)
Nube, before you go I noticed this. You open a console window for input but not output. Which I see is the standard but strange looking way for providing a console. It's unusual to have a window for input and no window for output. You set SYS_Asynch to TRUE which means the system will close your file so you will need to leave it open. Using Open() is fine for that purpose. But then it looks like your program exits immediately without closing the GUI. It is a test program but using FOpen() over Open() shouldn't make any difference so something else is amiss.
@hypex
According to the dos autodocs, SystemTags will copy SYS_Input to SYS_Output if SYS_Output is 0 (zero). However, he needs to check the SystemTags() return value and close the console if SystemTags() returns -1 (error). If SystemTags() succeeds, SystemTags() will close the console (in SYS_Asynch mode) as you pointed out. If SYS_Input is specified as 0 (zero) then SystemTags() will use NIL: for input.
Could that be why his window is being trashed?
X1000 - OS 4.1FE
@Xenic @hypex
Thanks for the reply. I tried using FOpen() and it immediatly solved the trashed window problem but I have to check, as xenic said, the return value to see if there is an error. About the console, as Xenic said, I red in the Autodocs that if you set SYS_Asynch TRUE and SYS_Output 0 it will copy Input to Output so I guess it is correct..
When I exit the emulator (with esc key, it is the MAME) it returns to the gui so I can run another game. Then when I quit the gui it free all the allocated resources..
Now I have no more trashed window by the way I have to check the return code from SystemTags as you said :-)
Thanks for the informations! I'll keep you updated!
P.S.: In the meanwhile I added menu with icons and shortcuts and an infowindow using the new infowindowclass
:-)
Just remember, not everyone will have infowindow.class installed. So unless you only target users with the Enhancer package installed, or provide some other method of showing "About", there may be issues.
Of course, if you are going to provide an alternate "About", it kind of makes using infowindow.class pointless really.
Simon
@Nube
A few minor niggles about your code occurred to me, although they won't affect the problem at hand:
1: both in line 70 and line 501 you define a
struct Window *window.
, of which the first one, line 70, may be removed.2: starting from line 682 you close dos.library preceded by dropping its interface, but hey, you didn't anywhere open c.q get them. And it is not necessary to open c.q. close this library and consequently get and drop the interface as the startup-code will do this for you. You may delete lines 682 upto and including line 687.
3: in line 511 you state
while (!done)
. You assume here that one of the boolean states applied to this variable is 0.'done' is a boolean and has therefore 2 defined states, 'TRUE' and 'FALSE', and 65534 undefined states. Only set the variable with either 'TRUE' or 'FALSE' and test the variable against either 'TRUE' or 'FALSE' (in UNNEGATED form!). 'TRUE' is not equivalent to '!FALSE' and 'FALSE' is not equivalent to '!TRUE'. Also avoid, for the same reason, testing with a negated comparison, likewhile (done != TRUE)
. Use:while (done == FALSE)
and never fall prey to the old April's fool-prank of assigning differnet values to the macro's TRUE and FALSE. I'm speaking here from experience...OldFart
Thanks for the usefull informations :-)
@OldFart:
3. this is nit-picking. In C language zero is defined as boolean false and every non-zero value is treated as boolean true. If you set done to 27, !done will still be 0 and thus false. And !0 is 1.
I agree that you should never do done == TRUE or done != TRUE, but done != FALSE or !done is perfectly ok.
I'd even prefer !done because the ! operator converts the integer with one false and many true values into a bolean with exactly one false and one true value.
Thanks Thomas! and thanks to all of you :-)
@xenic
I agree. Another thing to check.
I wonder if it is. But it has more serious problems. Which I'll point out below.
@Nube
Using the above code as an example, though it would have changed by now, I was referring to this on line 590:
return IDOS->SystemTags(command,
This will call SystemTags(), exit the main() routine, and pass the result to DOS. In fact I noticed when ever there is a fail in the set up it will call
return(0);
. This will exit immediately without freeing any resources. Very bad. :-DBut it gets worse. I compiled your code on my X1000. It doesn't even run. Well I mean it doesn't load up a GUI. The CPU meter goes up for a second and then it totally freezes my system up. I happened to have my debug terminal attached and it killed the system. :-o
It gets to the point of "Get IntegerBase, Integer Class opened" and then full stop. So not only is something amiss, something is very amiss, Very, very, amiss. :-)
I tried to debug it but DB101 just crashes. Which it always does for me even on simple code. First class debugger just a slight embellishment there. Which is unfortunate as clearly a lot of work was put into it. GDB only for us and we don't even have the GUI version of GDB. :-?
Look into this pice of code:
"nodetexts< em >" is wrong and should be "nodetexts[ i ] "
Looks like embedded texteditor changes [ i ] into < em >, just do a find&replace for such piece of code.
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
@jabirulo
Thanks, yes that solves the crash. I saw that. I thought some formatting code was embedded in there and removed it. This was on top of all the '240' codes in it. Looks like it needs a downlink for downloading actual source posted.
In any case now it runs through and just exits. This is a large chunk of code. I wonder if it worked at all? I'm about to get GDB out again and see where it fails. But last time I ran it through GDB it just ran the code when I told it next. Shouldn't do that.
That code is now outdated but you need an image to insert and use in the bitmap inside the window layout that's why it doesn't open the window. About the trashed window it is due to a function that i replaced so no more crashes at all. About the listbrowser i think the problem is the parser of the site that replaced the with ..
@Rigo
Sorry for the late reply I didn't see your answer sorry... yes I though about the About window and I am thinking to check the infowindow base pointer. If it is not availabe, (the infowindow class is not installed on the system) it will open a normal window with information on it.
:-)
@Nube
Ah okay. Well as suspected the code is obsolete. And on that note where was the error about the image. ;-)
What replacing Open() with FOpen()? If so, then your problem isn't fixed, as using Open() is standard for this purpose. Something else is wrong if you can't use Open() to open a console.
Your options would include that as well as an EasyRequest() or you can use a TimedDosRequester(). :-)
Yes, as I replaced FOpen against Open the problem went away. By The Way I have to recheck it again as, as I said before, the code changed alot so i have to recheck it with open function
@Hypex
Just let you know that now with the updated code, it works both with IDOS->Open() and IDOS->FOpen().
@Nube
Well that's strange. I wonder what changed in your code then? Still I'd like to know why GDB doesn't debug on my system and just runs through. I found this using your code. But your code wouldn't be causing GDB to break and just run through without stopping. It's my problem, I'll deal with it. Good you got it going. :-)