PDA

View Full Version : Start DBExplorer/DBBuilder from your application



matthewd
20-Apr-2009, 04:18 PM
The attached file contains a couple of procedures that you can add to your application that will start either DBBuilder or DBExplorer up with the workspace that is currently in use by your application. This is mainly for when you are working on a client's system, just to save you all that tedious mucking about with starting the utilities from an Explorer or Command Prompt window and going through the workspace selection dialog.

Oh yeah, it also sets dbAdminMode to DDB automatically for you. Of course, if the sysadmin has locked down HKEY_LOCAL_MACHINE, that won't do you much good. (This last weekend I ran into a system where I was locked out of REGEDIT, but the program could still write to HKEY_LOCAL_MACHINE, so this did the trick.)

If you've subclassed the Panel class, that would be a good place to put these procedures, then you can just set up secret shortcut keys, toolbar buttons or menu options to activate the utilities. The only thing these depend on is the classic DoStartDocument procedure which is included if you don't happen to already have it.

This should work on any version of VDF (tested on 12.1 and 14.0).

Garret Mott
20-Apr-2009, 05:03 PM
Cool!

Thanks Matt!!!!!!

BTW - re: your tag line: Betcha I was ready for that...

Allan Greis Eriksen
24-Apr-2009, 02:52 AM
Oh yeah, it also sets dbAdminMode to DDB automatically for you.

You could just set it to ON instead of DDB. That leaves out the DataDictionary part. Not sure why you would like to have the DD files at the customer site (other than FastView and
VDFStruct)?

matthewd
28-Apr-2009, 11:36 AM
I was not aware that ON could be used on dbAdminMode. Learn something new everyday! The -d- option starts DBBLDR without the DD support though.

Allan Greis Eriksen
29-Apr-2009, 07:23 AM
...and I havn't tried starting the dbBuilder with paramteres so the -d- option was new to me ;)

Peter Crook
30-Apr-2009, 04:09 AM
Thanks Matt, nice one!

BTW what's dbAdminMode? Can't find it in the Help Index.

Peter

Vincent Oorsprong
30-Apr-2009, 04:13 AM
Peter,

dbAdminMode is a registry setting. You can find it in HKEY_LOCAL_MACHINE\Software\Data Access Worldwide\Visual DataFlex\<version>\Defaults.

It is used with VDF14.0 and lower for telling Database Builder if it should operate in end-user mode (OFF), in table editing mode (ON) or DataDictionary mode (DDB). Since 14.1 the last option is not used anymore since DD maintenance is now fully in the Studio. Database Explorer uses the same registry value to determine if you can open the configuration dialog and click the readonly/readwrite icon.

Peter Crook
30-Apr-2009, 07:26 AM
Thanks Vincent, a very clear explanation.

BTW, on a completely different topic (and I know this isn't really the place), in your AccelMix.pkg you say you use a trick so that "a part of the code is executed as if the code was part of the key destination object". Are you saying that the trick simulates a
"Procedure <name> for <object>" syntax analogous to the "procedure <name> for <class>"?

Regards

Peter

Vincent Oorsprong
30-Apr-2009, 10:16 AM
Peter,

I am not aware of a AccelMix.Pkg, so I cannot really comment on that.

Peter Crook
30-Apr-2009, 10:25 AM
Oh! The source file says:

// Modifications:
// ~~~~~~~~~~~~~~
// 15/ 9/1996 Created by Vincent Oorsprong.

Guess it must be the other Vincent Oorsprong:D

It's a jolly useful package to automatically assign an accelerator key based on the letter following the ampersand in a button name.

Peter

Vincent Oorsprong
30-Apr-2009, 11:30 AM
interesting, where did you find it and what does it contains?

Garret Mott
30-Apr-2009, 11:32 AM
Oh! The source file says:

// Modifications:
// ~~~~~~~~~~~~~~
// 15/ 9/1996 Created by Vincent Oorsprong.

Guess it must be the other Vincent Oorsprong:D

It's a jolly useful package to automatically assign an accelerator key based on the letter following the ampersand in a button name.

Peter

Can't tell you how many times I've looked at code & said "I wrote that????" ;) Problem is - that's usually followed by "What was I thinking?". Document code? Nah - that's for wimps....

Peter Crook
30-Apr-2009, 12:52 PM
Can't remember where I got it, the contents are attached.

Regards

Peter

Vincent Oorsprong
30-Apr-2009, 01:19 PM
Peter,

Thanks. I recognize the code and it was written by me. Not the package though so someone else (PDC?) changed and published it somewhere.

Back to your questions; In a way it is comparable with procedure for classname. With procedure for classname - which is really asking for spaghetti coding - you add a procedure in an existing class. This can and should be done with subclassing. The On_Key definition while the current object is changed to another object is less dangerous but is tricky as well. At the time I wrote the code (13 years ago) I felt it was pretty good and nice but over time you learn a lot and it is not a correct way of coding. I don't use the code anymore myself and would not advise the use of it too anymore. But, hey, old code lives forever...

Peter Crook
1-May-2009, 10:31 AM
Hi Vincent

I recognize the code and it was written by me. Not the package though so someone else (PDC?) changed and published it somewhere.
I (PDC) changed the code to use Alt rather than Ctrl as the modifier key because Alt with "alphabetic key navigates to the menu or control marked with that key as a mnemonic" The Windows Interface - An Application Design Guide Microsoft Press 1992 p13. (Ctrl plus alphabetic keys "yields shortcuts " ibid). I haven't published it anywhere.

Back to your questions; In a way it is comparable with procedure for classname. With procedure for classname - which is really asking for spaghetti coding - you add a procedure in an existing class. This can and should be done with subclassing. The On_Key definition while the current object is changed to another object is less dangerous but is tricky as well.
I should be surprised if I have ever used Procedure for <class> (my memory is worse than yours:D), but occainsionally while debugging I have felt that a Procedure for <object> might be a quick and dirty way of helping me solve a problem.

At the time I wrote the code (13 years ago) I felt it was pretty good and nice but over time you learn a lot and it is not a correct way of coding. I don't use the code anymore myself and would not advise the use of it too anymore.
So what should I use instead? Or have I missed something and it's supproted 'out of the box' (in which case is it obvious how to change the modifier key as I suspect it will still be Ctrl?).

But, hey, old code lives forever...Long live old code!

Regards

Peter

Vincent Oorsprong
2-May-2009, 04:42 AM
Peter,

The code came from a dbExplorer version that was translatable. All labels were stored externally. I had to find out a way to support hotkeys. So I made code to parse labels for the '&' and create on_keys for it. I think the better way is "just" hardcode the on_key in the right object, it is much more clear than what the code is doing.

Larry Heiges
13-May-2009, 11:56 PM
Can't tell you how many times I've looked at code & said "I wrote that????" ;) Problem is - that's usually followed by "What was I thinking?". Document code? Nah - that's for wimps....

Remember when you could go back to work on Monday and remember what you were doing on Friday? That's the main reason I still use Multi-edit and hibernate... those little blue marks next to changed code so I can resync my brain.

Bengt
7-Apr-2018, 10:59 AM
Has someone get this code to work in recent times? I tried today but gave it up and used Runprogram Background instead with the disadvantage that you have to select workspace. I didn’t even succeed to locate Registry keys.

Bengt


// external function call used in Procedure DoStartDocument
External_Function ShellExecute "ShellExecuteA" shell32.dll ;
Handle hWnd ;
String lpOperation ;
String lpFile ;
String lpParameters ;
String lpDirectory ;
DWord iShowCmd Returns Handle


// this will perform an operation on a file (e.g. open) with the application
// registered in the Windows Registry to open that type of file (via its extension)
// sOperation would be "OPEN" (it could also be "PRINT", "EDIT", "CONNECT" etc).


Procedure DoStartDocument Global String sOperation String sDocument String sParam
Local Handle hInstance hWnd
Get Window_Handle to hWnd
If (Num_Arguments=2) Move (ShellExecute (hWnd, sOperation, (Trim (sDocument)), '', '', 1)) to hInstance
If (Num_Arguments=3) Move (ShellExecute (hWnd, sOperation, (Trim (sDocument)), (Trim(sParam)), '', 1)) to hInstance
End_Procedure // DoStartDocument


Procedure OpenDBExplorer
Boolean bOpened bExists
String sPath sArg sBin sWorkspace sVersion sRevision
Integer p
Handle hoReg hoWorkspace

Object oReg is a cRegistry
Set phRootKey to HKEY_LOCAL_MACHINE
Move Self to hoReg
End_Object

Get KeyExists of hoReg "SOFTWARE" to bExists // to check if key was found, but False


Version_information sVersion sRevision p
// Get OpenKey of hoReg ("Software\Data Access Worldwide\Visual Dataflex\"+sVersion+"."+sRevision+"\Defaults") to bOpened
Get OpenKey of hoReg ("SOFTWARE\WOW6432Node\Data Access Worldwide\DataFlex\"+sVersion+"."+sRevision+"\Defaults") to bOpened

If (bOpened) Begin
Send WriteString of hoReg "dbAdminMode" 'DDB'
Get ReadString of hoReg "DFPath" to sPath
If (sPath<>'') Begin
Get phoWorkspace of ghoApplication to hoWorkspace
Get psWorkspaceWSFile of hoWorkspace to sWorkspace
Move (sPath+';') to sPath
Repeat
Move (Pos(';',sPath)) to p
Move (left(sPath,P-1)) to sBin
If (right(Uppercase(sBin),3)<>"BIN") Move '' to sBin
Move (mid(sPath,length(sPath),p+1)) to sPath
Until (sBin<>'' or sPath='')
Move ('"'+sWorkspace+'"') to sWorkspace
Move (sBin+'\dbexplor.exe') to sPath
Move ('-x'+sWorkspace) to sARg
Send DoStartDocument "OPEN" sPath sArg
End
End
Send destroy to hoReg
End_Procedure

Vincent Oorsprong
8-Apr-2018, 02:10 AM
Bengt,

With runprogram you should be able to pass the workspace information as well. The workspace name is the full path to the .WS file and since this path may have spaces you need to surround it in double quotes, e.g.

dbexplor.exe "-xc:\DataFlex 19.0 Examples\Order Entry\Programs\Config.ws"

The code using the registry may fail because:
- You don't have rights to read it
- You aren't using a 64 bit version of the OS
- You don't have rights to write the DDB string
- ...