mikep@hpmwtd.HP.COM (Mike Powell) (12/14/90)
Hi folks... I'm hoping to accomplish a few tasks with BASIC on the Amiga... I'm using HiSoft BASIC which is supposed to be fully compaitble with Amiga BASIC.... so if you have some AmigaBASIC techinques to share I would sure apprieciate them.... I'd like to be able to launch programs from BASIC without killing the BASIC program. I have used the CHAIN and the RUN commands, which work fine, except BASIC closes all it's open files and windows and just basically bows out. The other thing I'd like to do is to have BASIC read a directory... If I could just call the DIR command and re-direct it into a file in ram: I'd be o.k. But that brings us back to the first problem of launching a program.... Pleezzze help..... -Mike Powell-
peterk@cbmger.UUCP (Peter Kittel GERMANY) (12/15/90)
In article <730026@hpmwngf.HP.COM> mikep@hpmwtd.HP.COM (Mike Powell) writes: > > I'd like to be able to launch programs from BASIC without killing > the BASIC program. I have used the CHAIN and the RUN commands, which > work fine, except BASIC closes all it's open files and windows and > just basically bows out. What was the phrase? Ah: "It's in there!" Just look into your Extras disk and look closely at the program "Library" in the BasicDemos drawer. It does exactly this (besides other things). Now, the interesting part of the program, where a List command is executed, is normally outcommented, because you have to assure one additional thing: To do things like this, you HAVE to invoke AmigaBASIC from Shell or CLI, NOT Workbench! To call DOS, AmigaBASIC needs this CLI background, else you get a real Guru. > The other thing I'd like to do is to have BASIC read a directory... > If I could just call the DIR command and re-direct it into a file > in ram: I'd be o.k. But that brings us back to the first problem > of launching a program.... See above. -- Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions... Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk
robin@niksula.hut.fi (Jarto 'Robin' Tarpio) (12/16/90)
In article <643@cbmger.UUCP> peterk@cbmger.UUCP (Peter Kittel GERMANY) writes:
Now, the interesting part of the program, where a List command is
executed, is normally outcommented, because you have to assure one
additional thing: To do things like this, you HAVE to invoke
AmigaBASIC from Shell or CLI, NOT Workbench! To call DOS, AmigaBASIC
needs this CLI background, else you get a real Guru.
Not exactly. If you open a file for output and give it's FileHandle
to the oputput in dos.library's Execute(), you can call DOS no
matter where you started your program from. And open the output-
file with dos.library's Open to get the FileHandle. (dos: XOpen)
It's not a very good idea to read a dir by examining the output
of list or dir. But it's the easiest way :-)
For sporty ones: Here's how you should do it in principal:
- Allocate 260 bytes for FileInfoBlock (exec:AllocMem)
- Lock the dir (dos:Lock)
- Examine the dir (dos:Examine)
- Test if it was a dir and not a file
PEEKL(FileInfoBlock+4) positive
- Let's loop !
- Take the next file/dir with ExNext (dos:ExNext)
- If it returned 0, it was the last one
- The name starts at FileInfoBlock+8
and is null-terminated.
- If PEEKL(FileInfoBlock+4) positive,
it was a dir.
- Back to the beg of loop !
- Clean up:
- UnLock the dir (dos:UnLock)
- Free the FileInfoBlock (exec:FreeMem)
To start with:
LIBRARY "exec.library"
LIBRARY "dos.library"
DECLARE FUNCTION AllocMem&() LIBRARY
DECLARE FUNCTION Lock&() LIBRARY
DECLARE FUNCTION Examine&() LIBRARY
DECLARE FUNCTION ExNext&() LIBRARY
For example:
The allocation: FIB&=AllocMem&(260,65537)
The lock: DirLock&=Lock&(SADD(YourDir$),1005)
The examine: Success&=Examine&(DirLock&,FIB&)
These are not at all detailed instructions, but it's always the
hardest thing to find out the idea. Go step by step and examine,
what you get. And be prepared to gurus ! If you do mistakes
allocating the FIB and give FIB&=0 to Examine, the ExecBase doesn't
like it at all :-)
--
Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions...
Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk
/robin
--
Jarto Tarpio StarSoft Ky, Finland ADSPE: Commercial ECO101
Helsinki University of Technology EMAIL: robin@niksula.hut.fi
peterk@cbmger.UUCP (Peter Kittel GERMANY) (12/18/90)
In article <ROBIN.90Dec16122002@robin.hut.fi> robin@niksula.hut.fi (Jarto 'Robin' Tarpio) writes: > > It's not a very good idea to read a dir by examining the output > of list or dir. But it's the easiest way :-) Ok, it's definitely the laziest way. But you spare another effort that you didn't mention in your else nice example: If you want to look at a whole directory, than you have to provide a sort of stack or buffer area to hold all that. And the size of this you must know in advance. And when you guessed too low than you must try again with a higher value. That's all really embarrassing and can simply be avoided by letting DOS do all this, trusting that the RAM disk will suffice to hold the result... :-) -- Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions... Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk