Solved

Getting Path information at forms runtime

Posted on 2002-04-10
6
1,837 Views
Last Modified: 2012-06-27
Hi,

I have a question which i can't seem to solve, but i think it's pretty easy to do.

This is it:

I'm building an application using among others Oracle Forms 5.0 . Integrated in the application is a piece of software called fire from Formida. We use this to project Oracle Spatial-data to a map of the port of Rotterdam.

Formida needs certain commandfiles to do its magic. But it can't use the working directory forms is using. So what i want to do is at runtime pass the path in which i'm working to this programm.

The passing of information is no problem, but i want to load the path-information (which can vary because of the mapping of users) in a variable.

How do i do this...?

Any (fast) help would be greatly appreciated.

Rick Leijs @ the port of Rotterdam
(avotar)
0
Comment
Question by:Avotar
  • 3
  • 2
6 Comments
 
LVL 47

Expert Comment

by:schwertner
ID: 6933270
The way I see is to pass the directory info as parameter to the root form and desiminate it using global variable. If it is connected with the client computer the way is to store it as environment variable at the client site and access it by the starting form.
0
 

Author Comment

by:Avotar
ID: 6933310
OK... that's a nice solution.. but for 200 points i would like a piece of coding to go with it... ;-)
0
 
LVL 2

Expert Comment

by:vanmeerendonk
ID: 6933348
Did you look at the magic of the D2KWUTIL.PLL?
In there there is a package WIN_API_ENVIRONMENT
with e.g. the functions Get_Environment_string
and Get_Working_Directory.

I think this is what you want.

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 47

Expert Comment

by:schwertner
ID: 6933462
I think the main issue is how to read the environment variables from Forms. I hope the following note will direct you. It covers both Unix and Windows.





While running an Oracle Forms, Reports, or Graphics application,
how do you isolate the following information?
 
 o  UNIX group name that a user belongs to
 
 o  values of DOS environment variables defined in the AUTOEXEC.BAT file
 
 o  values of environment variables defined in ORACLE.INI and WIN.INI files
 
 
Problem Explanation:
====================
 
TOOL_ENV.GETVAR returns only variables declared in the ORACLE.INI file
or the Windows Registry.
 
How do you return environment variables from the SYSTEM.INI
and AUTOEXEC.BAT files?
 
 
[ Search Words: uid, variable, TEMP, TERM, terminal, VT100, VT220, printer,
                GET_APPLICATION_PROPERTY, GETDOSENVIRONMENT(),
                GetPrivateProfileString, WritePrivateProfileString,
                D2KWUTIL, INI, files, reading, writing, accessing,  
                Win_API_Environment, Read_INI_File, Write_INI_FILE,  
                GETVAR,  PATH, d2kapi ]

NEW: UNIX: HOST() TO EXECUTE; REDIRECT OUTPUT TO FILE; READ WITH TEXT_IO

Solution Description:
=====================
 
o Use HOST() to issue the UNIX command from Forms to output the information
  you want.
 
o Use the UNIX Pipe ( | ), to send the output through the UNIX awk/sed
  utilities to extract just the values you want.
 
o Redirect the output of this to a unique filename  
 
  For example:
 
  HOST('uid | awk ... | sed ...> filename )
 
o Back in forms, open and read the file using the Text_IO package.
 
o You could then use HOST() again to remove the created file.
 
 
 
Solution Explanation:
=====================
 
For example: the uid UNIX command will give the the user's userid and group
id, which you could then access from Oracle Forms using the method described
above.



UNIX: CREATE TABLE, USE GET_APPLICATION_PROPERTY, HOST, RUN_PRODUCT

Solution Description:  
=====================  
 
1.  Create a table named tenv.  
    Use this table for compilation purposes of the form.  
 
2.  Insert the following code in the desired trigger or procedure.  
    This example uses the RUN_PRODUCT built-in to call Oracle Graphics and  
    accesses the environment variable GPATH.  
 
DECLARE  
  un  VARCHAR2(80);  
  pw  VARCHAR2(80);  
BEGIN  
  un := GET_APPLICATION_PROPERTY(USERNAME);  
  pw := GET_APPLICATION_PROPERTY(PASSWORD);  
  FORMS_DDL('CREATE TABLE tenv (v1  VARCHAR2(100))');  
  HOST('echo set termout off > tenv.sql');  
  HOST('echo insert into tenv values \('||'\'''||'\&1'||'\'''||'\)\; >>  
        tenv.sql');  
  HOST('echo commit\; >> tenv.sql');  
  HOST('echo exit >> tenv.sql');  
  HOST('sqlplus -S '||un||'/'||pw||' @tenv $GPATH');  
  SELECT v1  
    INTO :global.gp  
    FROM tenv;  
  FORMS_DDL('DROP TABLE tenv');  
  HOST('rm tenv.sql');  
  RUN_PRODUCT(GRAPHICS, :global.gp || '/disp1.ogd', SYNCHRONOUS, BATCH,  
              FILESYSTEM, NULL, 'dept.c1');  
  END;  
 
3.  Before you run the form, drop the table tenv.  
 
 
Solution Explanation:  
=====================  
 
You can refer to Oracle Support Bulletin 107368.663.  However, this uses an  
external file and database table, which can be a problem in a multi-user  
environment and requires you to keep track of more objects.
 
 
 Access Environment Variables from Forms



DOS: CREATE FORMS PARAMETER AND USE %VAR% TO PASS ON F45RUN COMMAND LINE

Solution Description:
=====================
 
To obtain a "DOS" variable:
 
1.  Declare a parameter in the form:
       DOS_PARAM   VARCHAR2(200)
 
2.  Pass this parameter to Oracle Forms on the command line
    when you invoke Runform.
     o  You can set up a Runform icon that runs the form  
        with this parameter specified.
 
    Set DOS_PARAM to the desired DOS variable enclosed in percent (%) signs.
       f45run module=myform userid=username/password DOS_PARAM=%TEMP%
 
    Windows expands %TEMP%, so the parameter holds the full value at runtime.
 
However, this method only works from Runtime and is somewhat clumsy.  
 
 
Solution Explanation:
=====================



WIN: USE TOOL_ENV.GETVAR TO GET ORACLE ENVIROMENT VARIABLE VALUES

Solution Description:
=====================
 
Use the TOOL_ENV.GETVAR built-in to interact with Oracle environment variables.
 
Syntax:   PROCEDURE TOOL_ENV.GETVAR
              (varname    VARCHAR2,
             varvalue   VARCHAR2);
 
          varname  - is the name of the environment variable
          varvalue - is the value of the environment variable
 
TOOL_ENV.GETVAR allows you to import a valid ORACLE environment variable
(e.g. on Windows: ORACLE_HOME, TK21_ICON, OTM25, etc.) into a VARCHAR2
variable.
 
If you supply a varname parameter that is not a valid ORACLE environment
variable, the varvalue returned is null.  Even if you create and set  
your own environment variable, TOOL_ENV.GETVAR does not return the  
assigned value.  Since the user-defined variable is not a valid ORACLE
environment variable, TOOLS_ENV.GETVAR returns a null as the varvalue.
 
Example 1
---------
To read the ORACLE_HOME environment variable into an Oracle Forms item:
        TOOL_ENV.GETVAR('ORACLE_HOME', :block.item);
 
Example 2
---------
To read the terminal environment variable into a Forms item:
        TOOL_ENV.GETVAR('TERM', :block.item);
 
Example 3
---------
To read the printer environment variable into a Forms item,
issue the following:
        TOOL_ENV.GETVAR('PRINTER', :block.item);
 
 
Note:
-----
If you are using the 32-bit version of Oracle Forms then TOOL_ENV.GETVAR()
will work for only the HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE section of the
Registry.
 
For the other sections use the D2KWUTIL package as:
 
WIN_API_ENVIRONMENT.read_registry
 
similarly, to write to the registry use:
 
WIN_API_ENVIRONMENT.write_registry
 
 
Solution References:
====================
 
The TOOL_ENV Package
in chapter 8, "Oracle Procedure Builder Packages",
of the Procedure Builder 1.5 Developer's Guide



WIN: USE ORAFFI TO CALL WINAPI GETDOSENVIRONMENT(),GETPRIVATEPROFILESTRI

Solution Description:
=====================
 
You can use the ORAFFI to call WinAPI GetDOSEnvironment() to get DOS
environment variables.
 
Read in the ini file variables using the GetPrivateProfileString, and
WritePrivateProfileString to write to an ini file.  These are windows
functions. These function can be called using the ORA_FFI built-in package.  
 
For the 32 bit tools you can use the equivalent functions for accessing the  
registry.  See the D2KWUTIL package.
 
 
Solution Explanation:
=====================



USE HOST TO WRITE VALUE TO FILE AND TEXT_IO TO READ IT IN FORMS

Solution Description:
=====================
 
UNIX:
-----
o Use HOST() to issue the UNIX command from Forms to output the information
  you want.
 
o Use the UNIX Pipe ( | ), to send the output through the UNIX awk/sed
  utilities to extract just the values you want.
 
o Redirect the output of this to a unique filename  
 
  For example:
 
  HOST('uid | awk ... | sed ...> filename )
 
o Back in forms, open and read the file using the Text_IO package.
 
o You could then use HOST() again to remove the created file.
 
For example, the uid UNIX command will give the the user's userid and group  
id, which you could then access from Oracle Forms using the method described  
above.  
 
 
WINDOWS:
--------
1.  To retrieve the value of the environment variable in a text file,
    issue the HOST command to execute an operating system command.
    Include the following PL/SQL code in a trigger:
 
    HOST('echo %TEMP% > out.txt');
 
2.  Use the TEXT_IO package to read the text file into Oracle Forms.
    See Oracle Support Bulletins 106573.931 "(V45) Reading and Writing Text
    Files" and 11165515.61 "Using the TEXT_IO Package"
 
 
 



WIN 32-BIT: D2KWUTIL UTILITY IS AVAILABLE

Solution Description:
=====================
 
The following is a summary of how you can access various types of  
Environment Variables on Windows platforms:  
 
1. Values in INI files (e.g. the old ORACLE.INI or SYSTEM.INI which
   duplicates some Registry info on Win95):  
 
   To Read:  Win_API_Environment.Read_INI_File in D2KWUTIL  
   To Write: Win_API_Environment.Write_INI_FILE in D2KWUTIL  
 
2. Values in the HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE section of the registry  
 
   To Read:  TOOL_ENV.GETVAR() built-in  
   To Write: Win_API_Environment.Write_Registry in D2KWUTIL  
 
3. Values in other sections of the registry  
 
   To Read:  Win_API_Environment.Read_Registry in D2KWUTIL  
   To Write: Win_API_Environment.Write_Registry in D2KWUTIL  
 
4. "DOS" environment Variables (e.g. PATH set in AUTOEXEC.BAT)  
 
   To Read: Win_API_Environment.Get_Environment_String in D2KWUTIL  
 
 
Solution Explanation:
=====================
 
The D2KWUTIL utility is currently available for 32-bit ports only.
It is on the 32 bit Developer/2000 r1.3.2 cd-rom in the fdemo45 directory but
this is not the latest version.  The latest version can be obtained via email
from Oracle WorldWide Support.
 
SOME of the Functions the Utility Provides:  
-------------------------------------------  
* Read and Write Registry  
* Environment functions:  
        Get DOS variable  
        Get Windows Username  
        Get Windows Directory  
        Get Temp Directory  
0
 

Author Comment

by:Avotar
ID: 6936370
nice cut and paste action..

but still not waht i'm looking for.

The trouble is that the same application is in 4 different environments. 80% works in 1 environment and you can guide them through registry setting and getting them the way you say.
Unfortunately 20% works different environments, different directories, databases, but same application. I can't set any info at startup...
0
 
LVL 47

Accepted Solution

by:
schwertner earned 200 total points
ID: 6936578
Thanks. Nice to hear that....It seems that the people in Roterdam are very polite. Now I am not so sure that we have to join the EU....

I think you have to maintain some "navigation" tables and create dblinks to these tables. The main goal of these tables will be to get the application oriented where they have to find the needed resouces in the complicated environment you have mentioned above. I think also that you can use only one table for this aim and also use the columns instead the environment variables in my earlier proposal. Of course there are other solutions and other Experts will be so kind to help you.

Good luck!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now