Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!decwrl!ucbvax!pasteur!ames!ncar!oddjob!gargoyle!att!ihnp4!cbmvax!carolyn From: carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) Newsgroups: comp.sys.amiga.tech Subject: Re: Having trouble with the Execute() dos call Keywords: AmigaBasic Message-ID: <3862@cbmvax.UUCP> Date: 24 May 88 22:35:16 GMT References: <24869@bbn.COM> Reply-To: carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) Organization: Commodore Technology, West Chester, PA Lines: 58 In article <24869@bbn.COM> cosell@BBN.COM (Bernie Cosell) writes: >Hi- > In the unlikely event that there's an AmigaBasic wizard out there some >place, I thought I'd push my luck and try another inquiry about the mysteries >of using the "real" libraries out of Basic. This time, I'm doing battle >with Execute&(). As I read the description of that call, it _seems_ >benign enough, but when I try to call it, my Amiga goes up in flames in >all kinds of exciting ways -- of course, making it impossible to figure out >what went wrong. I tried something REAL simple like: > library "dos.library" > declare function Execute&() library > Execute& (sadd ("date > ram:junk"), 0&, 0&) >Guru-central. If I try the above with the "> ram:junk" left out, I >assumed (with my eternal naivete) that date would inherit the "current" >screen, which I hoped would be the basic screen. No such luck, of >course -- this time, I think it just made the machine stop dead in its >tracks: no guru, nothing (wouldn't track the mouse or do ANYTHING). Yes, you blew up your system by using the Execute() function, no doubt from within a program that was started from Workbench and therefore had NO stdout. Execute()ing a CLI command requires a CLI environment or at least someplace for stdout to go. You must use the dos.library Open() function (that's xOpen from AmigaBASIC due to name conflict) to open some kind of file for Execute()'s output to go to. That file would generally be a CON:nn/... window or NIL:. In addition - What's with the SADD("string") ???? I'd be real surprised if that works. In my experience YOU are responsible for null terminating your amigabasic strings before passing them to a system call. (As below) (P.S. - I am typing this in off the top of my head. May not be exactly right but it's at least close) DECLARE FUNCTION Execute&() LIBRARY DECLARE FUNCTION xOpen&() LIBRARY LIBRARY "dos.library" outfile$ = "NIL:" + CHR$(0) command$ = "date > ram:datefile" + CHR$(0) modenew& = 1006 handle& = xOpen(SADD(outfile$),modenew&) if(handle& > 0) then success& = Execute(command&, 0&, outfile&) xClose(handle&) endif LIBRARY CLOSE -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Carolyn Scheppner -- CATS >>Commodore Amiga Technical Support<< UUCP ...{allegra,ihnp4,rutgers}!cbmvax!carolyn PHONE 215-431-9180 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=