cosell@bbn.com (Bernie Cosell) (05/23/88)
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). This and my previous inquiry (that about Examine()) all clearly come from a lack of understanding about what is REALLY going on in the underpinnings of amigabasic -- is there someone out there who is willing to enlighten me a bit? Or perhaps, is there some "official" place I could ask questions like this -- can I call Microsoft and try to find "amigabasic support"? How about trying to find someone at CATS tasked with being wizard-of-basic? Thanks __ / ) Bernie Cosell /--< _ __ __ o _ BBN Labs, Cambridge, MA 02238 /___/_(<_/ (_/) )_(_(<_ cosell@bbn.com
barrett@ektools.UUCP (Chris Barrett) (05/24/88)
In article <24869@bbn.COM>, cosell@bbn.com (Bernie Cosell) writes: > 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 I believe the problem that you ar having is that BASIC doesn't append a null character to the end of a string, so AmigaDOS keeps trucking through the name you passed in intil it find a 0x00. Give this a try: DECLARE FUNCTION Execute& LIBRARY LIBRARY "dos.library" command$ = "date > ram:junk" + CHR$(0) status = Execute& (SADD(command$), 0&, 0&) I don't know how the Execute command handles the redirection of your date command, you could try using a file handle for the output file. Good luck! Chris. ...rochester!kodak!ektools!barrett
carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (05/25/88)
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 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=