Making a program that uses IDOS->System Tags Workbench friendly?

6 posts / 0 new
Last post
AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 10 years 3 months ago
Joined: 2011-11-14 16:18
Making a program that uses IDOS->System Tags Workbench friendly?

Hi,

I noticed that if I use any IDOS->Printf() statements in a program, that program will have DSI errors if the printf gets executed if the program is setup to be run as a Tool with an icon indicating start from Workbench instead of start from shell.

Similarly, if a program has a statement such as (IDOS->SystemTags("copy file1 file2",0,0)) and for any reason the copy fails and results in text output, the program locks up if it is run as a tool started with workbench.

Is there a remedy for this? I have tried redirecting the output of the copy command to NIL:, but that does not seem to help.

Thanks

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
What does IDOS->Output()

What does IDOS->Output() return? Does it return a valid file handle or ZERO? It should return a valid file handle otherwise this is why Printf() crashes. The SystemTags() launched program by default uses the launching program's standard i/o file handles unless you tell it to do otherwise.

I tried compiling a test program that opens a new CON: window and outputs the three standard i/o filehandles (IDOS->Input(), IDOS->Output() and IDOS->ErrorOutput()) using IDOS->FPrintf(). I tried compiling it with vbcc and gcc (using newlib and clib2) and launching it from WB (start from set to WB on the icon) but wasn't able to reproduce your problem.

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 10 years 3 months ago
Joined: 2011-11-14 16:18
@salass00 wrote "I tried

@salass00 wrote
"I tried compiling a test program that opens a new CON: window and outputs the three standard i/o filehandles "

I am not opening a con: window at all. I am creating a reaction window with gadgets and listbrowsers.

When I run this program in a shell, it works fine. When I run it from an icon using SHELL as the start method, it runs fine. But if I run it from an icon (as a Tool) and either IDOS->Printf or printf or any AmigaDOS command is called that generates an output (such as in the case where you go to copy a file but it is missing) then I immediately get DSI erros and soon a lockup.

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
This is the test program I

This is the test program I wrote and used:

  1. #include <proto/dos.h>
  2.  
  3. int main (void) {
  4. BPTR con;
  5. if (IDOS->Output()) {
  6. IDOS->Printf("input: 0x%08lx\n", IDOS->Input());
  7. IDOS->Printf("output: 0x%08lx\n", IDOS->Output());
  8. IDOS->Printf("error: 0x%08lx\n", IDOS->ErrorOutput());
  9. }
  10. con = IDOS->Open("CON:", MODE_NEWFILE);
  11. if (con) {
  12. IDOS->FPrintf(con, "input: 0x%08lx\n", IDOS->Input());
  13. IDOS->FPrintf(con, "output: 0x%08lx\n", IDOS->Output());
  14. IDOS->FPrintf(con, "error: 0x%08lx\n", IDOS->ErrorOutput());
  15. IDOS->FGetC(con); // wait for user to press RETURN
  16. IDOS->Close(con);
  17. }
  18. return 0;
  19. }

and compiled using:
gcc -mcrt=newlib -O2 -Wall -o stdio_test stdio_test.c
gcc -mcrt=clib2 -O2 -Wall -o stdio_test stdio_test.c
vc -O2 -o stdio_test stdio_tesr.c

Depending on the startup code used the Output() filehandle (used by Printf()) might be pointing to NIL: when started from WB (like with vbcc all three are the same NIL: filehandle) so if I write anything to it it will just be ignored so in order to get any output I had to create a new CON: filehandle.

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 10 years 3 months ago
Joined: 2011-11-14 16:18
@Salass00 You are

@Salass00

You are obviously correct.
The DSI errors I was getting seem to be because of other issues with pointers.

mackya87 (not verified)
mackya87's picture
I really appreciate your

I really appreciate your work,thanks for posting…please write more blogs on such topics.
pest removal cost

Log in or register to post comments