1 2 Previous Next 17 Replies Latest reply on Jan 17, 2020 1:31 PM by Michael Ferrante-Oracle

    Windows Environment Variables

    MarcLaf

      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

        • 1. Re: Windows Environment Variables
          Oleh Tyshchenko

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

          • 2. Re: Windows Environment Variables
            MarcLaf

            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...

            • 3. Re: Windows Environment Variables
              Michael Ferrante-Oracle

              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

              • 4. Re: Windows Environment Variables
                Frank Hoffmann

                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

                • 5. Re: Windows Environment Variables
                  Volker Deringer

                  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

                  • 6. Re: Windows Environment Variables
                    MarcLaf

                    Sorry... my bad !!!

                     

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

                     

                     

                    Cheers,

                     

                    Marc L

                    • 7. Re: Windows Environment Variables
                      Michael Ferrante-Oracle

                      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.

                      • 8. Re: Windows Environment Variables
                        Volker Deringer

                        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

                        • 9. Re: Windows Environment Variables
                          MarcLaf

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

                           

                          Any reasons for this?

                           

                          Cheers,

                           

                          Marc L

                          • 10. Re: Windows Environment Variables
                            Michael Ferrante-Oracle

                            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

                            • 11. Re: Windows Environment Variables
                              MarcLaf

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

                               

                               

                              Marc L

                              • 12. Re: Windows Environment Variables
                                Michael Ferrante-Oracle

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

                                • 13. Re: Windows Environment Variables
                                  MarcLaf

                                  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

                                  • 14. Re: Windows Environment Variables
                                    Michael Ferrante-Oracle

                                    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;

                                     

                                    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

                                    1 2 Previous Next