Link to home
Start Free TrialLog in
Avatar of jim_1234567890
jim_1234567890

asked on

Determining a Forms location

Like most developers we have different servers and location for Oracle forms - I.E. DEVelopment, TEST, & PRODuction.

As developers we always work in the Development area.  Then we promote our work to Test where tester does their stuff.  Eventually the form is promoted to Production.

Now our tests are not full time dedicated testers.  So they often work in production and in test.

They have their computers set up so that production forms are on the 'P' drive and the test forms on 'T' drive.  When they are testing they have their registry setting set up to point the FORMS path to the 'T' Drive.  When they are working in production they have their registry settings set up to point the FORMS path to the 'P' drive.   They switch back and forth via a .bat file that changes their registry settings.

This appears to work in general and is the best solution we have found for them so far.

The issue occurs that sometimes the tester forget to reset their registry settings and run the TEST forms while logged into the production database.  This can result in some bad data in production.

We have the forms show which database they are logged into.  But we wanted to display which environment they where launch the forms from (DEV, TEST, or PROD).

How can you determine the launching location of a form?  Identifying the drive letter would be usefully but the best would be if you could look at the under lying server (IE:  \\DEV\forms\, \\TEST\forms\, \\PROD\forms\).

We do not want to change anything in the form from the TEST area to the PRODuction area.  So by simply changing the code or forms title and then recompiling is not an acceptable choice.  If the form passes in TEST then it promote into production with out being re-compiled.  Any time a form is re-compiled it must be tested again.  A 'WHEN-NEW-FORM-INSTANCE' program solution is what is needed.

Have something like:

the_username := upper(get_application_property (username));
the_instance := UPPER (get_application_property (connect_string));
set_window_property (MAIN_WIN, title, 'App Title         ' || the_username || '@' || the_instance || ' on ' || the_FormsSource);

Just need to figure out how to determine the variable: the_FormsSource

I am Currently using FORMS 5, but will most likely upgrade to FORMS 6i in the next year or two.

Any Ideas?

Avatar of Ora_Techie
Ora_Techie

Which Operating System you are currently using ?
ASKER CERTIFIED SOLUTION
Avatar of aabbas
aabbas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

create different shortcuts on desktop for development, test and production and pass different parameters to the initial form (Parameter may be DEV, TEST, LIVE) and display this parameter on MDI_WINDOW title to distinguish forms.

Property of a shortcut for PRODUCTION;  --my parameter name = environment

Target : C:\orant\BIN\ifrun60.EXE module=MyLogon userid=myuser/mypass@production environment=PRODUCTION

Start In :  \\PROD\forms\

in Pre-form trigger of Mylogon.FMB you can show parameter environment.

So no need to make changes in registry because your application will be started by dirrenet short-cuts.

regards.


Avatar of jim_1234567890

ASKER

Here is what I used:

DECLARE
   
-- Could be use for
-- WHEN-NEW-FORM-INSTANCE
   the_username     VARCHAR2 (20);
   the_instance     VARCHAR2 (20);
   the_formspath    VARCHAR2 (254);
   the_formsname    VARCHAR2 (254);
   the_enviroment   VARCHAR2 (50);
   tab              VARCHAR2 (5)      := '     ';
   v_file           text_io.file_type;
   v_filename       VARCHAR2 (254);
BEGIN
   the_formspath := UPPER (get_application_property (current_form));
   the_formsname := UPPER (get_application_property (current_form_name));
   v_filename := SUBSTR (the_formspath, 1, (INSTR (the_formspath, the_formsname, 1)) - 1) || 'version.txt';
     
-- Use the text.io functionality to read in the first line
-- of a text file, called version.txt
-- This version.txt is in the same directory as the launching form
-- We just read in the first line.

   BEGIN -- test to see if you can open the file
      v_file := text_io.fopen (v_filename, 'r');
      text_io.get_line (v_file, the_enviroment);
      text_io.fclose (v_file);
   EXCEPTION
      WHEN OTHERS THEN
         the_enviroment := '';   -- can not open the file
   END;

   the_username := UPPER (get_application_property (username));
   the_instance := UPPER (get_application_property (connect_string));
   set_window_property ('FORM_WIN', title, 'Forms Title' || tab || the_username || '@' || the_instance || the_enviroment);
END;
A side note note here:

I have tried:

the_formsname := UPPER (get_application_property (current_form_name));
test := get_form_property (the_formsname, file_name);

Which will return say:  C:\testingforms\mytest.fmx

This return when I run the form form the forms builder.

It will also work when launch it from a desktop icon and I have target set as:
C:\ORANT\BIN\F50RUN32.EXE C:\testingforms\mytest.fmx
&
Start in set as anything.
& the FORMS50 path in the registry setting may or may not contain C:\testingforms

Now if I have a short cut with:
Target:  C:\ORANT\BIN\F50RUN32.EXE mytest.fmx
Start in: anything
& the  FORMS50 path in the registry setting containing C:\testingforms

then the above test will return:  mytest.fmx


The whole point of this get_application_property or get_form_property  is to return the full path.  It return only the full path when in the desk top short cut I have the full path to the form or I have the 'Start in' pointing to the location of the form.

The reason I do not want to have the full path in the Target and/or the Start in is because it can be launch from different mapped drives.

If I hard coded the target as P:\forms\myform.fmx then the end user must have a mapped P drive.  That is not always the case.  Especially if the user is running serveral other applications.

I wanted to return the full path to the launching from.  The method of launching is via a desktop short cut with:
Target:  C:\ORANT\BIN\F50RUN32.EXE mytest.fmx
Start In: could be anything (most likely preset to c:\)
In the registry setting the FORMS50 will contain P:\forms


The idea of having differnt different shortcuts only confuses the end users.


Simiply put the end users only has the desktop short cut that contains:
Target:  C:\ORANT\BIN\F50RUN32.EXE mytest.fmx
Start In: could be anything (most likely preset to c:\)
In the registry setting the FORMS50 will contain P:\forms

So the solution must come from updating the form so it can determine the path name.

















Here is the work around I found:

-- Fetch the FORMS50_PATH

tool_env.getvar ('FORMS50_PATH', the_forms50path);
   the_environment := 'UNKNOWN';

-- We will parse the registry settings for FORMS50.
-- Loop at each path for the version.txt exists there.

   WHILE INSTR (the_forms50path, ';', 1) > 0 LOOP
      BEGIN
         the_path := SUBSTR (the_forms50path, 1, INSTR (the_forms50path, ';', 1) - 1);

--  See if it is c:\temp\ or c:\temp
--  That way we can concatenate the version.txt to that path.

         IF SUBSTR (the_path, LENGTH (the_path), 1) = '\' THEN
            v_filename := the_path || 'version.txt';
         ELSE
            v_filename := the_path || '\version.txt';
         END IF;

-- This looks for the first occurance of version.txt in their path.
         BEGIN -- test to see if you can open the file

-- Use the text.io functionality to read in the first line
-- of a text file, called version.txt
-- We just read in the first line.

            v_file := text_io.fopen (v_filename, 'r');
            text_io.get_line (v_file, the_environment);
            text_io.fclose (v_file);
            the_forms50path := the_path;

         EXCEPTION
            WHEN OTHERS THEN
               -- file does not exsist.
               the_forms50path := SUBSTR (the_forms50path, INSTR (the_forms50path, ';', 1) + 1);
         END;
      END;
   END LOOP;