Dynamic Library

55 views
Skip to first unread message

EJ-Boy Perez

unread,
Oct 7, 2015, 2:16:45 AM10/7/15
to OpenROAD Users Mailing List
Hi!

Good day to everyone. i am a neophyte in OpenRoad Programming. i'm currently developing an application wherein i will be using the MS Office Library. my problem is that i have variant versions of MS Office installed in some of our workstations. Is there a way to have a dynamic library that will be used in my application?

I am thinking to have this approach such that at the run-time the program will check the current MS Office installed on that workstation and gather information of the MS Office and create an External Class Library.

Does anyone have the solution on this issue?

if you have, can i ask some tips or sample codes for me complete my application.

Thank you

adr...@octavo2.demon.co.uk

unread,
Oct 7, 2015, 3:03:52 AM10/7/15
to openroa...@googlegroups.com

Hi,

 

It is possible to query the registry to look for the installed version of Office (Office 9/10/11/12 etc) and then to create a dynamic external user object to support the ActiveX interface to this (ExtLibSource.Create()) filling in the attributes from the registry information.

 

Once you have this ExtLibSource you can compile (i.e. Parent it to your application) at runtime and then make another source object to interact with it.

 

So if your ExtLibSource office object is always called MSOffice you can make a  new dynamic ghost frame (so you can catch events) source object called ‘MSOfficeX’ referencing MSOffice by:

 

·         Using stored strings in the your code or in your database to make the script

·         Using an include script  (the image which contains this include script will need to be built as a library (-l))

o   this is what I have seen done

 

Once you have built and parented MSOfficeX to you application this can be called by making by name calls using the callframe :MSOfficeX_Name() type syntax.

 

I understand that between different versions of MSOffice that there are differences in how it needs to be driven, you will need to embed the solution in this for MSOfficeX either by having multiple include scripts to cover the different versions of Office or if you are a 3GL freak you could use macro variable language in a single include script to customise the MSOfficeX script before it is compiled.

 

I didn’t implement this I am just working from memory of 14 years watching it evolve…

 

We are all happy to help you along while you get this working, just ask questions when you get stuck.

 

Good luck,

 

Adrian

--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To post to this group, send email to openroa...@googlegroups.com.
Visit this group at http://groups.google.com/group/openroad-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/65a9d610-9071-4622-9547-db350d53faba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

adr...@octavo2.demon.co.uk

unread,
Oct 7, 2015, 3:33:05 AM10/7/15
to openroa...@googlegroups.com

Hi,

 

The registry can be queried by creating 3GL procedures in OpenROAD to access the advapi32.dll.

 

You need to look up procedures in this library like:

 

regopenkeya

regclosekey        

regenumvaluea    

regqueryvalueexa

 

Also when I said ‘callframe :MSOfficeX_Name() type syntax’

 

I forgot to mention that MSOfficeX_Name is a varchar(32) with the value ‘msofficex’ to match your new ghost frame.

 

Cheers

 

Adrian

Bodo Bergmann

unread,
Oct 7, 2015, 4:52:38 AM10/7/15
to openroa...@googlegroups.com

Attached is the export file of a sample application, which does it:

 

The 4GL Procedure “createExcelLib” scans the registry (using the undocumented REGISTRYKEY class) and creates an External Class Library “MSExcel” according to the version found.

The IncludeScript “top_script” contains the code you would usually use in the frame script (if you have MSExcel defined in your application).

The frame “top” is the frame which does the Excel connection when pressing a button.

The starting procedure   “starter” calls “createExcelLib”, fetches the CompSource of frame “top” and of the IncludeScript “top_script”,
then sets the Script of the frame “top” to the one in the IncludeScript, which contains the “MSExcel” library references.

Then the frame is called after setting IsStale=TRUE to force recompilation.

This “detour” is required as the script wouldn’t compile in the frame at development time due to the missing “MSExcel” library.

 

When building an image file of the application you’ll have to use the “-l” (Library) flag, otherwise the IncludeScript wouldn’t be contained in the image.

 

HTH.

 

Regards,
Bodo.

--

Bodo Bergmann

Senior Software Engineer

Actian | Engineering

Phone: +49.6103.3033.734

www.actian.com

 

GESELLSCHAFTSANGABEN: Geschäftsführer: Steven R. Springsteel, Stephen Mark Padgett, Markus Bockle

Sitz der Gesellschaft: Hamburg| Handelsregister: Amtsgericht Hamburg | HRB 135991| USt-IdNr: DE252449897

--

excelDyn.xml

EJ-Boy Perez

unread,
Oct 7, 2015, 11:25:03 AM10/7/15
to OpenROAD Users Mailing List
Thank you so much sir.... it works...

EJ-Boy Perez

unread,
Oct 7, 2015, 11:25:03 AM10/7/15
to OpenROAD Users Mailing List
Sir:

I compiled the sample application you provided using OR 5.1, i marked the Library (-l) during the image building.
unfortunately upon execution, the application will just flash and encountered an error E_WT0029 Error at Line 15 of starter.

To post to this group, send email to openro...@googlegroups.com.

Auto Generated Inline Image 1

EJ-Boy Perez

unread,
Oct 7, 2015, 11:25:03 AM10/7/15
to OpenROAD Users Mailing List
Sir:

what will be my approach on this situation, because the codes in exporting the date to excel located in the second frame (i have my first frame which is the main_menu Frame).




On Wednesday, 7 October 2015 16:52:38 UTC+8, Bodo wrote:

To post to this group, send email to openro...@googlegroups.com.

EJ-Boy Perez

unread,
Oct 7, 2015, 11:25:03 AM10/7/15
to OpenROAD Users Mailing List
Sir:

I compiled the sample codes you provided using OR5.1... I marked checked on Library (-l) and created an image... when i execute the application on workstation with msoffice 2007, it flashes only and immediately closed the application.. when i execute on my workstation with ms office 2013, it appears this error



On Wednesday, 7 October 2015 14:16:45 UTC+8, EJ-Boy Perez wrote:
Auto Generated Inline Image 1

Bodo Bergmann

unread,
Oct 7, 2015, 11:44:24 AM10/7/15
to openroa...@googlegroups.com

Then just don’t call it there – this is just an example.

After changing the FrameSource of the frame (setting Script and IsStale attributes),
the frame will automatically be compiled whenever it is called the first time (later).

To post to this group, send email to openroa...@googlegroups.com.

Bodo Bergmann

unread,
Oct 7, 2015, 11:55:10 AM10/7/15
to openroa...@googlegroups.com

Is this still relevant, because the next mail I received from you said “Thank you so much sir.... it works...”?

To post to this group, send email to openroa...@googlegroups.com.

EJ-Boy Perez

unread,
Oct 7, 2015, 8:14:13 PM10/7/15
to OpenROAD Users Mailing List
SIr:

its still relevant, i test your sample codes only at workbench... but when i execute the image (compiled with Librayr (-l)) i encountered this error "E_WT0029 Error at Line 15 of starter".
hope you can help me with this..

EJ-Boy Perez

unread,
Oct 7, 2015, 10:15:24 PM10/7/15
to OpenROAD Users Mailing List
Sir:

sorry sir, i cant figure out on how to deal with it:

on your sample code, the procedure starter called the procedure CreateExcelLib and the Frame top (which is the First -Main Frame) with the IncludeScript procedure top_script.

in my case, how do i call the procedure top_script on the Second Frame?

hope you can teach me...

thank you

EJ-Boy Perez

unread,
Oct 7, 2015, 11:00:51 PM10/7/15
to OpenROAD Users Mailing List
sir:

i already know why i encountered an error ("E_WT0029 Error at Line 15 of starter") during run-time.. this is because the workstation has previous installation of MS Office 2007 then updated to MS Office 2013... on the registry HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046} there are two sub items.. 1.6 and 1.8...

upon during run-time, the 1.6 will be read (even though its already uninstalled) instead of 1.8.. then it will cause an error at line 15.

what can you suggest on this, is there any registry location where we can check the active msoffice installed.

EJ-Boy Perez

unread,
Oct 8, 2015, 4:49:33 AM10/8/15
to OpenROAD Users Mailing List, adr...@octavo2.demon.co.uk
Sir:

do you have an idea on how to list down the Subkeys of a particular key in the registry using OpenRoad?

i just want to list down the subkeys of HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}

Hope you can help me..

Bodo Bergmann

unread,
Oct 8, 2015, 4:50:14 AM10/8/15
to openroa...@googlegroups.com

The frame “top” is just an example name, it does not have to be the first frame in your application,
I could have called it “someframe”.

If your second (or any other) frame in the application contains the references to MSExcel,
then you will need to do the following steps for the according frame(s):

- Fetch the FrameSource

- Set its Script (e.g. using an IncludeScript, but can also come from somewhere else)

- Set its IsStale to TRUE

To post to this group, send email to openroa...@googlegroups.com.

Bodo Bergmann

unread,
Oct 8, 2015, 5:32:47 AM10/8/15
to openroa...@googlegroups.com

Ok, with multiple versions under the key there is a problem.

 

You could loop through all the subkeys of the HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046} node, e.g.:

 

FOR i=0 TO rk_excel_typelib.NumSubkeys-1 DO

    so_version = rk_excel_typelib.EnumKey(keyindex=i);

    …

ENDFOR;

But even then you would not know which is the current one – a higher version does not mean that this is the current one.
It might have been installed once, and later uninstalled, but the registry entry still remained. See for example here:

https://social.msdn.microsoft.com/Forums/en-US/d35f6852-8770-4503-8428-4a7040b654cd/suddenly-automation-error-library-not-registered

 

So, the only way I see is a case statement for the current version of Excel.Application class.

Example – change the script for the  createExcelLib procedure to the following – you will have to add code for the other Excel versions:

 

PROCEDURE createExcelLib()=

DECLARE

    excelExtLibSource = ExtLibSource;

    rk_root = REGISTRYKEY;

    rk_excel_app_curver = REGISTRYKEY DEFAULT NULL;

    so_subkey = StringObject;

    so_version = StringObject DEFAULT NULL;

ENDDECLARE

BEGIN

    rk_root.Initialize(HKEY_CLASSES_ROOT);

    so_subkey.Value = 'Excel.Application\CurVer';

    rk_excel_app_curver = rk_root.Open(subkey=so_subkey);

    IF rk_excel_app_curver IS NULL THEN

      MESSAGE 'HKEY_CLASSES_ROOT\Excel.Application\CurVer not found.';

      RETURN ER_FAIL;

    ENDIF;

    so_version = rk_excel_app_curver.GetValue();

    IF so_version IS NULL THEN

      MESSAGE 'No value for HKEY_CLASSES_ROOT\Excel.Application\CurVer';

      RETURN ER_FAIL;

    ENDIF;

   

    excelExtLibSource.Name = 'MSExcel';

    excelExtLibSource.UniqueId = '{00020813-0000-0000-C000-000000000046}'; // for Excel

    CASE so_version.Value OF

      'Excel.Application.15' :

      {

            excelExtLibSource.majorVersion = 1;

            excelExtLibSource.minorVersion = 8;

      }

      // TODO: Do the same block for other Excel versions

      DEFAULT:

      {

            MESSAGE 'Unknown Excel.Application version: ' + so_version.Value;

      }

    ENDCASE;

    excelExtLibSource.ParentApplication = CurProcedure.ObjectSource.ParentApplication;

    RETURN  ER_OK;

END

 

HTH.

 

Regards,

Bodo.

To post to this group, send email to openroa...@googlegroups.com.

EJ-Boy Perez

unread,
Oct 8, 2015, 10:00:53 PM10/8/15
to OpenROAD Users Mailing List, adr...@octavo2.demon.co.uk
Thank you for the sample scripts.. it works...

sir with regards to the Include Script.. how do i issue the command because the frame that will call my 4gl procedure for Excel application, contains commands like this...

initialize
(arr_stl_master = array of uc_stl_master,
 arr_er_master = array of uc_er_master)=
declare
   ...
   ...
enddeclare
{
   ...
   ...
   ...
}


On Click btn_close,
On WindowClose, On Terminate=
{
   Return;

EJ-Boy Perez

unread,
Oct 9, 2015, 1:02:54 AM10/9/15
to OpenROAD Users Mailing List, adr...@octavo2.demon.co.uk
Sir:

how do i issue the command so that on the frame (where the top_script will be initializing and running) i can use both MSWord and MSExcel External Library.. (i have already made the External Lib).

Bodo Bergmann

unread,
Oct 9, 2015, 4:53:18 AM10/9/15
to openroa...@googlegroups.com, adr...@octavo2.demon.co.uk

Create an additional 4GL procedure to dynamically create an MSWord external class library,
the same way as for MSExcel (just with different TypeLib IDs, version numbers, etc.),

then also call it from the starter procedure.

Alternatively you could extend the existing procedure (and probably rename it).

 

From: openroa...@googlegroups.com [mailto:openroa...@googlegroups.com] On Behalf Of EJ-Boy Perez
Sent: Freitag, 9. Oktober 2015 07:03
To: OpenROAD Users Mailing List <openroa...@googlegroups.com>
Cc: adr...@octavo2.demon.co.uk
Subject: Re: [openroad-users] Dynamic Library

 

Sir:

Reply all
Reply to author
Forward
0 new messages