#: 57539 S7/Psion Inc. [PALMTOP] 19-Jul-93 04:34:36 Sb: OPL & app switching. Fm: Marcos Molinero 71572,662 To: Mark Esposito 70713,1407 (X) Mark, Do you know how I can switch from one application(not just the built in S3 apps) to another with OPL? There are online files in this forum (such as S3KILL, RUNOPA, KILLAPPS, ...) which explain how to run a program from within another but if you use it to load an already running program, it will load it a second time and you will have 2 copies running, unless an error occurs. An example program could be Tetrion.app, not just the built in apps. The file "S3KILL.OPL" shows how to get a list of processes in existence and how to obtain the ID of a process. Is there a special address value for OS calls or for ret%? The S3 opl manual does not cover any of this. - Do you know if it ispossible to write a system extension with OPL that detects key-presses regardless of where you are (the system or any app)? Thank you very much for your help. Marcos. #: 57632 S7/Psion Inc. [PALMTOP] 19-Jul-93 21:27:05 Sb: OPL & app switching. Fm: Mark D Esposito 70713,1407 To: Marcos Molinero 71572,662 (X) Marcos, I believe that everything you want to do is possible. You asked for it, here goes! In regards to switching to a running Opl app there is no problem as long as you initiated the Opo procedure. Here's why. I tried endlessly to figure a way to identify a running Opl application, but it was a problem since Opl procedures actually are run under Sys$Prgo, and therefore get a name like sys$prgo.$09 and sys$prgo.$10. The problem is figuring out which one is the Opl app you want to jump to. Of course if you were using IPC (Interprocess Communication) you could set your app to be the only one able to respond correctly to your message, and this would be a possibility, although more complex. Finally Wolfgang Shirmer figured out a way to do it that was right in front of our faces. Just launch the Opo, and rename it right after it launches to whatever name you want to give it. Now you can do a wildcard search on all pids and find your app by name. The new Notepad 4.6 does this now so that in Spy.app Notepad shows up as such in the list, and so does the Alarm Server, even though these are both Opl applications. On the other question it would require spawning an app that would just check keypresses coming from within your main app through IPC. So here's what you need to do. I wrote out this proc, and I guess I'll upload it as a file. Note that all it will do is start an Opo procedure, allowing you to rename it, and then jump to it by name. This first time you enter the app is when it launches, and the second time is when it was jumped to by name. Proc Switch: local d%,name$(12),jumppid%,fil$(128),pid% dinit"Locate Opo to run" dfile fil$,"",0 dedit name$,"Rename app to:",18 if dialog name$=name$+chr$(0) REM char str Zero pid%=launch:(fil$) REM Launch app if pid% REM good launch pause 40 REM pause to differentiate the jumps into the app front: REM bring me back to foreground giprint"App launched..." if Rename:(name$,pid%) REM successfully renamed Jumppid%=Wildfind:(name$) REM Renamed app found by name if jumppid% Jump:(jumppid%) REM Jump to app endif endif endif endif Endp Proc Launch:(fn$) local f$(128),ret%,cmdl$(128),z$(1),hpid% z$=chr$(0) Rem zero onerr z cmdl$="ORunopl"+z$+z$+fn$+z$ f$="ROM::sys$prgo"+z$ ret%=call($0187,addr(f$)+1,addr(cmdl$),0,0,addr(hpid%)) if ret%<0 return 0 Rem unsuccessful endif call($0688,hpid%) Rem ProcResume return hpid% z:: giprint err$(err) Endp Proc Rename:(name$,apid%) local ret%,n$(12) local ax%,bx%,cx%,dx%,si%,di% bx%=apid% n$=name$ di%=addr(n$)+1 ax%=$0c00 Rem Zero C zero zero ret%=os($88,addr(ax%)) if ret% and $1 giprint err$((ax% and $ff)-256) pause 30 else return 1 endif Endp Proc Wildfind:(n$) local fpid%,nam$(12) nam$=n$ fpid%=call($0188,addr(nam$)+1,0,0,0,0) if call($8c8d,fpid%)>=0 return fpid% else return 0 endif Endp proc Jump:(jpid%) call($998d,0,jpid%) Endp Proc Front: call($998d,0,0,0,0,0) Endp #: 57716 S7/Psion Inc. [PALMTOP] 20-Jul-93 14:50:14 Sb: OPL & app switching. Fm: Marcos Molinero 71572,662 To: Mark D Esposito 70713,1407 (X) Mark, Thank you very much for your helpful and detailed explanation on how to switch applications on the S3 using OPL and for your ideas on how to detect key-presses throughout apps. Now I just need to find out about IPC. I'll let you know when I succeed in getting my program to switch apps. Regards, :-) Marcos #: 58301 S7/Psion Inc. [PALMTOP] 26-Jul-93 15:26:38 Sb: #OPL & app switching. Fm: Marcos Molinero 71572,662 To: Mark D Esposito 70713,1407 (X) Mark, Thank you for your information on how to switch apps with OPL. The program I was finishing off and have just uploaded is "Launcher". Could you tell me how I can find out more about IPC, that you mentioned? Thanks again, Marcos * Reply: 58367 #: 58367 S7/Psion Inc. [PALMTOP] 26-Jul-93 23:36:32 Sb: #58301-#OPL & app switching. Fm: Mark D Esposito 70713,1407 To: Marcos Molinero 71572,662 (X) Marcos, You can find out more about IPC in two places that I know of. First the Extended Opl/w examples here on the forum in Lib 7. Secondly by purchasing the SDK documentation.