problem with Shel_Read (AES 120)

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

problem with Shel_Read (AES 120)

Postby rockyone » Sun Aug 24, 2014 5:41 pm

IF COMPILER THEN
'Shel_Read

Sh_Rpcmd%L= MEMORY( SPC(128)):Sh_Rp_Tail%L= MEMORY( SPC(100))
Intin%(0)=128
Intin%(1)=100
MEMORY_MOVE VARPTR(Sh_Rpcmd%L),8 TO Addrin%L
MEMORY_MOVE VARPTR(Sh_Rp_Tail%L),8 TO Addrin%L+8
AES (120,Global%(0),Intin%(2),Addrin%L(2),Intout%(1),Addrout%L(0))

'path full launch
Z%=0
WHILE PEEK(Sh_Rpcmd%L+Z%)>0:Z%=Z%+1 WEND
Rpcmd$=SPC(Z%)
MEMORY_MOVEB Sh_Rpcmd%L,Z% TO LPEEK( SEGPTR +28)+ LPEEK( VARPTR(Rpcmd$))

'Searching for the last "\" path
WHILE Z%>0: IF PEEK(Sh_Rpcmd%L+Z%)=92 THEN EXIT ENDIF Z%=Z%-1 WEND

'******************************************
'Path and Name ( ACC or PRG )

IF Z%=0 THEN' "name.ACC"

If another accessory was run before,
it is his name which can be found here

Name_Prg$=Rpcmd$' <<<<<< problems here

For an accessory, "Shel_Read" contains no path
Chem_prg$="A:\"

ELSE' "name.PRG"

Name_Prg$= MID$(Rpcmd$,Z%+2)
Chem_Prg$= LEFT$(Rpcmd$,Z%+1)

ENDIF

'*****************************************

'useless here
'z%=0: WHILE PEEK(Sh_Rp_Tail+z%)>$D:Rptail$=Rptail$+ CHR$( PEEK(Sh_Rp_Tail+z%)):z%=z%+1 WEND

FRE (Sh_Rp_Tail%L)
FRE (Sh_Rpcmd%L)
Accessory%= ABS(Z%=0)
ENDIF

User avatar
Mikefulton
Captain Atari
Captain Atari
Posts: 169
Joined: Sun Nov 29, 2015 10:27 am

Re: problem with Shel_Read (AES 120)

Postby Mikefulton » Fri Jan 15, 2016 9:30 am

I know it's an old post but...

1) What flavor of BASIC is this?

2) What exactly is the problem you were having? It's not clear.

rockyone
Captain Atari
Captain Atari
Posts: 307
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: problem with Shel_Read (AES 120)

Postby rockyone » Sat Jan 16, 2016 11:55 pm

in basic omikron

I wanted to recover Shel_Read with the name of the launched program to differentiate its execution mode (ACC / PRG)

For Shel_Read prg, although the non Contains the program launched

But for an accessory, the name returned by Shel_Read, does not correspond to the non-open accessory.
If I remember correctly, for an open accessory from the menu, the name contained in Shel_Read, is the last (I find it the right word) executed or initialized program.

User avatar
Mikefulton
Captain Atari
Captain Atari
Posts: 169
Joined: Sun Nov 29, 2015 10:27 am

Re: problem with Shel_Read (AES 120)

Postby Mikefulton » Sun Jan 17, 2016 4:32 am

rockyone wrote:in basic omikron

I wanted to recover Shel_Read with the name of the launched program to differentiate its execution mode (ACC / PRG)


That's not, strictly speaking, what shel_read is supposed to return. The shel_read call simply returns the last thing done with shel_write. In many, if not most cases, that will be the command that launched the current program. But that's not guaranteed and shouldn't be relied upon.


rockyone wrote:For Shel_Read prg, although the non Contains the program launched

But for an accessory, the name returned by Shel_Read, does not correspond to the non-open accessory.
If I remember correctly, for an open accessory from the menu, the name contained in Shel_Read, is the last (I find it the right word) executed or initialized program.


No, shel_read only returns what was done with shel_write. If something is executed via GEMDOS function Pexec without shel_write, then shel_read won't have any knowledge of it.

Under vanilla TOS, there is no 100% reliable way for a program to determine the executable file it came from.

However, looking for "ACC" or "PRG" in the filename isn't the right way to go about determining the launch mode anyway. Take a look at this article I wrote on the subject a LLLLLLLOOOOOOOOONNNNNNNNGGGGGGGG freakin' time ago... :wink:

http://dev-docs.atariforge.org/files/AR ... y-1991.pdf

Page 3 is where the article starts, and there's another article about desk accessory stuff after it.


Social Media

     

Return to “Other BASIC”

Who is online

Users browsing this forum: No registered users and 1 guest