Forum Stats

  • 3,734,386 Users
  • 2,246,958 Discussions
  • 7,857,255 Comments

Discussions

Windows Environment Variables

MarcLaf
MarcLaf Member Posts: 160 Blue Ribbon
edited Jan 17, 2020 8:31AM in Forms

Hi,

Is the a way to get the content of an environment variable from a local desktop (windows 7) into Oracle Forms 11g? I've tried the TOOL_ENV.getvar, but this only reads the content of the ORACLE.INI file...

Please Help

Marc L

Best Answer

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,644 Employee
    edited Jan 16, 2020 3:20PM Accepted Answer

    Wow.  So you are using very old and unpatched versions.  Likely this is the reason things aren't working as expected.  I tested in 12.2.1.4 using Java 8u241 (released this week) and things work as expected.  Below is the code I tested.  I copy the selected path to a text item in the last line before End. 

    PROCEDURE get_client_filename IS

        l_filename varchar2(200);

        default_path varchar2(500);

       

    BEGIN

        -- Global for user_home created in WNFI trigger since this may be used several times

        default_path := :global.user_home || '\Desktop\';

       

        l_filename := client_get_file_name(directory_name => default_path

                                        ,file_name      => null

                                        ,file_filter    => 'GIF Files (*.gif;*.png)|*.gif;*.png|All Files (*.*)|*.*'

                                        ,message        => null

                                        ,dialog_type    => null

                                        ,select_file    => null

                                        );

      :builtins.file_name := l_filename;

    END;

    pastedImage_1.png

    Unrelated to this issue, you should really consider upgrading everything.  The latest version is far better than the version you are using and has many new features.  You can try it out in Cloud.  Check out this thread.  https://community.oracle.com/thread/4275496

    Details about the latest version, including downloads and documentation can be found here:  https://www.oracle.com/database/technologies/developer-tools/forms.html

Answers

  • Oleh Tyshchenko
    Oleh Tyshchenko Member Posts: 692 Gold Trophy
    edited Jan 15, 2020 11:28AM

    If you are familiar with Webutil you may use JAVA_SYSTEM.getenv()

  • MarcLaf
    MarcLaf Member Posts: 160 Blue Ribbon
    edited Jan 15, 2020 11:36AM

    Well, in fact I am using WEBUTIL to select a file from the Users PC...

    webutil_file.file_open_dialog (directory_name     => p_default_dir_in

                                       , file_name          => ''

                                       , file_filter        => l_file_filter

                                       , title              => l_dialog_title

                                        );

    But I want to get the Users documents path, to be able to put that in my directory_name...

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,644 Employee
    edited Jan 15, 2020 12:20PM

    @MarcLaf

    If you are using WebUtil, you can do the following to return the user's "My Documents" directory.

    rtn := CLIENT_WIN_API_ENVIRONMENT.GET_ENVIRONMENT_STRING('USERPROFILE') || '\Documents\';

    The result should be something like this:

    C:\Users\<CURRENT USER>\Documents

  • Frank Hoffmann
    Frank Hoffmann Member Posts: 778 Gold Badge
    edited Jan 16, 2020 6:00AM

    I am not sure if WIN_API will work on MAC - this here seems to be a more general approach:

    rtn := webutil_clientinfo.get_system_property('user.home') || webutil_file.get_file_separator || 'xxx.pdf';

    Frank

  • Volker Deringer
    Volker Deringer Member Posts: 135 Blue Ribbon
    edited Jan 16, 2020 6:16AM

    Did you try CLIENT_TOOL_ENV.getv() ?

    With you can get the value from variables on the client - that's what your are looking for, or?

    yours


    Volker

  • MarcLaf
    MarcLaf Member Posts: 160 Blue Ribbon
    edited Jan 16, 2020 10:38AM

    Sorry... my bad !!!

    I want the USERS DESKTOP (not Documents...) path... Is there a way to get that from webutil?

    Cheers,

    Marc L

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,644 Employee
    edited Jan 16, 2020 11:06AM

    The concept is exactly the same.  <USER HOME>\Desktop

    This is mostly Windows functionality and not Forms.

    rtn := CLIENT_WIN_API_ENVIRONMENT.GET_ENVIRONMENT_STRING('USERPROFILE') || '\Desktop\';

    As Frank mentioned, these calls will only work on Windows machines.  If you have users running MAC or Unix/Linux then you'll need to adapt your code.

  • Volker Deringer
    Volker Deringer Member Posts: 135 Blue Ribbon
    edited Jan 16, 2020 11:09AM

    what do you mean by USERS DESKTOP ?

    You may get almost everything with CLIENT_TOOL_ENV or WEBUTIL_CLIENTINFO or CLIENT_WIN_API_ENVIRONEMENT,

    but you have to know which system property or variable your are looking for ..

    Do you have an example for a value your are looking for?

    If your open a CMD-Box on your windows system and type in "set" ... do you see the value/information your are looking for?

    Volker

  • MarcLaf
    MarcLaf Member Posts: 160 Blue Ribbon
    edited Jan 16, 2020 11:21AM

    Nearly works.... It doesn't get to the Desktop directory, it stop at the users directory:

    pastedImage_0.png

    Any reasons for this?

    Cheers,

    Marc L

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,644 Employee
    edited Jan 16, 2020 12:20PM

    Try something like this (just an example and not complete);

    DECLARE

        l_filename varchar2(200);

        home_dir varchar2(200);

    BEGIN

    -- Get user home directory

        home_dir := webutil_clientinfo.get_system_property('user.home');

        l_filename := client_get_file_name(directory_name => home_dir || '\Desktop\'

                                        ,file_name      => null

                                        ,file_filter    => 'Excel Files (*.xls|*.xls|All Files (*.*)|*.*'

                                        ,message        => null

                                        ,dialog_type    => null

                                        ,select_file    => null

                                        );

    END;

    It just occurred to me that you are using Forms 11.  I don't believe you can use multiple filters on the same entry in the file dialog.  This is something that was corrected in 12.2.1.4

  • MarcLaf
    MarcLaf Member Posts: 160 Blue Ribbon
    edited Jan 16, 2020 12:43PM

    Tried it... No luck, still does not get into the users ..\Desktop directory. It stops at the users home directory...

    Marc L

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,644 Employee
    edited Jan 16, 2020 1:24PM

    Please share the relevant code you are using.  And include the exact Forms version and JRE version.

  • MarcLaf
    MarcLaf Member Posts: 160 Blue Ribbon
    edited Jan 16, 2020 1:39PM

    Forms Version 11.1.2.1.0

    ******

    FUNCTION get_workbook_name (

        p_default_dir_in   IN   VARCHAR2 DEFAULT DefaultDIR

      )

        RETURN VARCHAR2

      IS

        l_name_out     VARCHAR2(200);

        l_dialog_title VARCHAR2(100);

        l_file_filter  VARCHAR2(100) := 'Excel Files (*.xls; *.xlsx)|*.xls*';

        home_dir VARCHAR2(200);

       

      BEGIN

      IF :GLOBAL.LANGUAGE = 'F' THEN

          l_dialog_title := 'Sélectionnez le fichier à télécharger';

        ELSE

          l_dialog_title := 'Select the file to upload';

        END IF;

       

        home_dir := webutil_clientinfo.get_system_property('user.home');

       

        l_name_out :=

          webutil_file.file_open_dialog (directory_name     => home_dir || '\Desktop\'

                                       , file_name          => ''

                                       , file_filter        => l_file_filter

                                       , title              => l_dialog_title

                                        );

        RETURN l_name_out;

    ******

    Using JRE 1.7.0.25

    Cheers,

    Marc L

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,644 Employee
    edited Jan 16, 2020 3:20PM Accepted Answer

    Wow.  So you are using very old and unpatched versions.  Likely this is the reason things aren't working as expected.  I tested in 12.2.1.4 using Java 8u241 (released this week) and things work as expected.  Below is the code I tested.  I copy the selected path to a text item in the last line before End. 

    PROCEDURE get_client_filename IS

        l_filename varchar2(200);

        default_path varchar2(500);

       

    BEGIN

        -- Global for user_home created in WNFI trigger since this may be used several times

        default_path := :global.user_home || '\Desktop\';

       

        l_filename := client_get_file_name(directory_name => default_path

                                        ,file_name      => null

                                        ,file_filter    => 'GIF Files (*.gif;*.png)|*.gif;*.png|All Files (*.*)|*.*'

                                        ,message        => null

                                        ,dialog_type    => null

                                        ,select_file    => null

                                        );

      :builtins.file_name := l_filename;

    END;

    pastedImage_1.png

    Unrelated to this issue, you should really consider upgrading everything.  The latest version is far better than the version you are using and has many new features.  You can try it out in Cloud.  Check out this thread.  https://community.oracle.com/thread/4275496

    Details about the latest version, including downloads and documentation can be found here:  https://www.oracle.com/database/technologies/developer-tools/forms.html

  • Frank Hoffmann
    Frank Hoffmann Member Posts: 778 Gold Badge
    edited Jan 17, 2020 3:07AM

    Marc,

    I think there was a bug in this version which will jump to "user.home" directory if the file_name is not filled. Try "*.xls" or a single character like a space.

    Frank

  • MarcLaf
    MarcLaf Member Posts: 160 Blue Ribbon
    edited Jan 17, 2020 7:32AM

    I'm in the process of configuring a new Windows 10 PC with Oracle Fusion Middleware 12c (with new version of Oracle Forms) and newest version of JAVA.

    I will test it when everything is set up!

    Thanks for all you reponses!


    Cheers,

    Marc L

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,644 Employee
    edited Jan 17, 2020 8:31AM

    Mark,

    In order to ensure the installation process goes well, be sure to take a look at these documents before starting:

    System Requirements

    Installation Guide

    Release Notes

    Tips (mentioned in docs above):

    • Be sure the machine has 8gig RAM or more.
    • Be sure there is free disk space.  Consider that you need space for the downloaded zips, room to extract them, space for temp during install, and space for the install.
    • The user performing the installation must be a member of the Windows Administrator group.
    • Although it is technically possible to install from a remote drive, running the installers from the local machine is recommended.
    • Although you can install on a machine that does not have a static IP address, it is recommended.  If you don't want a static IP, installing and configuring the Windows Loopback adapter and using it is recommended.
    • Be sure to refer to the Installation Guide.  It mentions several critically important steps that you may not consider otherwise.  For example, when you start servers for the first time you must start them in an elevated shell (which is not the same as being an Administrator).
    • You will need access to an Oracle Database v11.2.0.4 or newer to perform the installation.

    The installation process:

    1.  Download and install the latest Java 8 JDK (64bit)

    2.  Download and install WLS Infrastructure 12.2.1.4 (do not configure)

    3.  Download and install Forms and Reports 12.2.1.4 (do not configure)

    4.  Run Repository Creation Utility (RCU) and select the needed schemas or select All (see "Forms and Reports Installation Guide")

    5.  Run WLS Configuration Wizard to create the WLS Domain

    6.  Start the servers (in order) from an elevated shell.  Node Manager then Admin Server.  The managed servers (e.g. WLS_FORMS) can be started from with Fusion Middleware Control (FMC) once the Admin Server has been started.  Until the servers have been successfully started you cannot and should not attempt to make any configuration changes.  (refer to the Installation Guide)

    More information about Oracle Forms, to include documentation, downloads, announcements, and much more can be found on the Forms product page on Oracle.com

    https://www.oracle.com/database/technologies/developer-tools/forms.html

Sign In or Register to comment.