I need to call an external program from HiSoft Basic and return to the running program. According to the (not faultless) manual Gemdos FUNCTION Pexec() should do it.
This is as far as I get, strictly following the manual
Don't know if the command internally adds the required nulls. If the null isn't added it might not see the path correctly. Try adding the null, it shouldn't hurt anything, since the string is passed via address.
theres a hisoft pdf somewhere around here , very user friendily manual
its focus is for v 2 and from my use of h.s.basic or power basic or first basic is 2nd version is different from first
ill try to dig it up and show link or ill snap photo of my manual
Charles
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!
FUNCTION GetWholeEnvironment$
STATIC i,res$,a$
res$=""
i=1
DO
a$=ENVIRON$(i)
IF a$="" THEN EXIT LOOP
res$=res$+a$+CHR$(0)
INCR i
LOOP
GetWholeEnvironment$=res$
END FUNCTION
FUNCTION killpath$ (path$)
STATIC i,ch
i=LEN(path$)
DO
ch=ASC(MID$(path$,i,1))
IF ch="\"% OR ch=":"% THEN EXIT LOOP
IF i=1 THEN EXIT LOOP
DECR i
LOOP
killpath$=LEFT$(path$,i)
END FUNCTION
FUNCTION killname$ (path$)
STATIC i,ch,dummy$
i=LEN(path$)
DO
ch=ASC(MID$(path$,i,1))
IF ch="\"% OR ch=":"% THEN EXIT LOOP
IF i=1 THEN EXIT LOOP
DECR i
LOOP
dummy$=RIGHT$(path$,i)
i=LEN(dummy$)
DO
ch=ASC(MID$(dummy$,i,1))
IF ch="."% THEN EXIT LOOP
IF i=1 THEN EXIT LOOP
DECR i
LOOP
killname$=LEFT$(dummy$,i-1)+" "
END FUNCTION
SUB Execute(nname$,commline$)
SHARED menutree&
STATIC junk&,junk,curhandle,i,curtop
STATIC dummypath1$,dummypath2$,dummydrive,pe,mxprogs
STATIC WindX,WindY,WindW,WindH,cur_top
mxprogs=PEEKW(PEEKL(GB+4)+ap_count)
pe=0
IF mxprogs=-1 THEN pe=100
IF i=-1 THEN junk=form_alert (1,"[1][ VA server not found! ][ OK ]")
IF i<>-1 THEN
POKEW a&,&H4711
POKEW a&+2,PEEKW(PEEKL(GB+4)+4)
POKEW a&+4,0
POKEL a&+6,c&
POKEW a&+10,0
appl_write i,16,a&
END IF
END SUB
SUB ViewFileMulti (filename$,comm$)
STATIC mxprogs,editorva$,junk
mxprogs=PEEKW(PEEKL(GB+4)+ap_count)
IF filename$="" THEN
junk=form_alert (1,"[1][ No editor set! ][ OK ]")
ELSE
IF mxprogs=-1 THEN
editorva$=killname$ (filename$)
IF appl_find (editorva$)<>-1 THEN ' ie program already running
CALL va_send (editorva$,comm$)
ELSE
CALL Execute (filename$,comm$)
END IF
ELSE
CALL Execute (filename$,comm$)
END IF
END IF
Not sure what manual you are using, but mine says something about pexec() falling if the calling program doesn't leave the operating system enough free ram to execute the requested program.
charles wrote: Sat Jan 16, 2021 2:46 am
theres a hisoft pdf somewhere around here , very user friendily manual
I use the ones on dev-docs https://docs.dev-docs.org/htm/search.php?find=hisoft, probably the same.
Thanks to your elaborate example I found the problem. According to the manual the call is pexec%() but that won't work. However pexec&() does .
So the working code is
lp wrote: Sat Jan 16, 2021 5:28 am
Not sure what manual you are using, but mine says something about pexec() falling if the calling program doesn't leave the operating system enough free ram to execute the requested program.
True. HBasic has those weird compiler directives that look like remarks to take care of that. I use
and this is a great example on how every one should submit their code
because lost documents or misdirection leave use of programs clueless
but more importantly broadens user base making us a stronger collective.
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!
charles wrote: Sat Jan 16, 2021 2:13 pm
and this is a great example on how every one should submit their code
because lost documents or misdirection leave use of programs clueless
but more importantly broadens user base making us a stronger collective.
Agree. So here's another HiSoft Basic quirk I encountered:
Some calls in their Gemdos lib are defined as FUNCTION, others as SUB. You can call a function just by its name
But you can call a sub just by its name only when you're passing none or just one argument. If you need to pass more than one you need to add CALL.
This is the code I use now for calling a TOS program and redirecting its output to NULL (using fforce() ). Mode 100 means load, go, don't wait http://toshyp.atari.org/en/00500b.html#Pexec
lp wrote: Sat Jan 16, 2021 1:40 pm
Well I would not have spotted the "%" versus "&" issue. Not sure what that even implies. The GFA manual also has it share of quirks.
Is that a HSBasic sort of thing me wonders,I mean never done anything more than 'hello world' thingy in basic itself even if figured out how to do c-style asm calls some years back in HSBasic XD
Kinda neat trick btw.
Anywho,gets me to think of C and adresses with the &.
And about the REM thing,that sounds real odd to me that parameters of that kind is passed on as 'reminders' or whatever REM stands for?