I.T. Discussion Community!
-Collapse +Expand
Paradox
Search Paradox Group:

Advanced
-Collapse +Expand Paradox To/From
To/FromCODEGuides
-Collapse +Expand Paradox Store
PRESTWOODSTORE

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

   ► KBDesktop Data...Paradox & Ob...ObjectPAL Co...OPAL: Langua...   Print This     
  From the July 2013 Issue of Prestwood eMag
 
Paradox OPAL: Language Details:
Using Execute in Paradox's ObjectPAL
 
Posted 13 years ago on 2/18/2006 and updated 2/18/2006
Take Away: Using execute() in ObjectPAL.

KB100310



The following demonstrates how to launch an application using the execute() command. It also demonstrates a technique for checking if the application is already running before launching it. This is particularly handy when working with DDE and OLE.

Using execute()

To launch an application in Paradox is easy. For example, the following code from the pushButton event of a button launches Notepad.

method pushButton(var eventInfo Event)
  execute("NOTEPAD.EXE", No, ExeShowNormal)
endMethod
Checking if the application is already open first

To check if an application is running, you can use the enumWinowNames method to list all the running applications within a table. Then use a scan loop with locatePattern to check if the application is running. To make sure the temporary table is not in conflict with other users in a multi-user situation, create the table in each users private folder.

For example:

enumWindowNames(":priv:mytemptable.db")
Clean Up

To automate the cleanup of the temporary table in your private folder, name the table starting with two underscores. Paradox automatically deletes all files in your private folder that start with two underscores whenever Paradox exits.

For example:

enumWindowNames(":priv:__mytemptable.db")
Complete Example

The following code from the pushButton event of a button checks if Microsoft Word is already running and if it is NOT, then launches it. If Word is running, Word is not launched.

method pushButton(var eventInfo Event)
var  
  sTable 		String
  tcApps		TCursor
  lWordOpen	Logical
endVar

  errorTrapOnWarnings(True)

  sTable = ":priv:__apps.db"
  enumWindowNames(sTable)
  tcApps.open(sTable)

  lWordOpen = False
  scan tcApps 
   for tcApps.locatePattern("WindowName", 
    "..Microsoft Word.."):
    lWordOpen = True
    quitloop
  endScan

  if not lWordOpen then
  execute("D:\\Program Files\\Microsoft Office" +
   + "\\Office\\WINWORD.EXE", 
      No, ExeShowNormal)
  endIf
endMethod

Finding WindowNames

You can use a technique similar to the above code to find the window name to search for during your scan loop. For example, the following code from the pushButton event of a button displays a table of all Windows. Just make sure the application you want to search for is running prior to executing this code.

method pushButton(var eventInfo Event)
var 
 sTable String
 tvApps TableView ; Used to find app names.
endVar

  sTable = ":priv:__apps.db"
  enumWindowNames(sTable)
  tvApps.open(sTable) ; Used to find app names.
endMethod

Linked Message Board Threads

 launching audio files from opal in ObjectPAL MB Topic (13 replies)

Comments

1 Comments.
Share a thought or comment...
Comment 1 of 1

Checking to see if the application is open first works great but not if Lync is open.  Running with Office 2013, Paradox will hang up waiting for a response from Lync when looking to see if Outlook is open.  Close Lync and the code proceeds normally.  I had to give up on checking to see if Outlook was open and just start using "/recycle" on the execute command line so it won't open additional sessions if one if already running.

Gene

Posted 5 years ago
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1244A1
Enter key:
KB Post Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #100310 Counter
9996
Since 4/2/2008
Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech