                        Using the EXTERNAL Attribute
                    Variable or FILE defined externally.

All this is described(briefly) in the Clarion Doc's on the External Attr or
you can get SwiftPro and it is at your finger tips. I don't know how anyone
can program quickly by not using SwiftPro to answer the questions that arise
while programing .

This example is how one way to use the external attribute on files and
variables with DLL's. Variables are easy, files will take more work.

The App Gen can be used for all developement. If one wants to use files then
you will need to generate the code for the application and then add the
external('') attribute to any file in the main cla file for the app.
(see below)

 Variables:

Compile the App's and check out how the variable can be changed in the exe
and Dll's and the changes are seen wherever you are. Look at the embed source
for the exe and Dll's for this variable.

I used this approach for the variable:

1. Created a dll(a hand coded program with the variable declared without the
   External attribute).

2. Compiled as a dll. Named as Extinc.DLL.

3. Declared the same variable with the external attribute in the exe and any
   other dll's that will use this var(in an embed source pt).

4. In the project file for the exe and the dll's link in the Extinc.dll as a
   Lib or Obj.


   ** Note: **

   If you will notice I made a procedure for this Extinc.dll. I used this
   approach to call this procedure from my exe to load these var's. The reason
   I did this was I create dll's in separate dir's. I only want to use
   one set of files. I declare all my files in the exe and all dll's(not
   Extinc.dll) with the External(''),Name(VarName). The name I put on in the
   dictionary. The Varname's all have the path to a directory where my files
   rest. This would allow the changing only of one var to change the path for
   any files. This could have definite advantages for archived files.

   Look below for example
   **       **


If you will notice:

1. In the example you cannot add a record in the DLL.
2. The reason is the files have been allocated different space.
3. The same files are being declared in the exe and the Dll's.
4. The External for files is not given as a demo but the way to code this
   is given below.

One way to solve this problem is the same as the External var's.

1. This takes more work. We are only talking about the files that will be
   used in other DLL's, but I use all the files because it is easier.

2. I declare the files in a DLL(same one as Var's) making sure it is a
   program module. Use the CDD editor and import all the definitions into
   your Extinc.Cla file.

3. After generating the code for my exe or DLL's that will all use the same
   file, I change the Main cla file for each. They all need to have the
   External('') Attr on the files that are declared in the other Extinc.DLL.

4. This really is easy by using the program Extern.zip I downloaded form DBA
   Software Solutions. I also modified this code and now you can use
   Externfx.exe. Call the batch file Extfx.bat and give the name of the cla
   file as the required two parameters and it will add the External('') to all
   files in that cla. No parameters does the same thing Extern.zip does, lets
   you give the string inside the left and right parenthesis.

5. You can now not compile again from the App Generator, unless you do the
   above again.

6. Load the Cla file into the Editor from the Clarion Env and then load the
   project file. Recompile again.

$Unresolved$
If one just declares a var in one DLL and declares the same var in another
 DLL with the External Attr you will get an Unresolved Link error. When the
 Unresolved appears while compiling the DLL's it is because the DLL
 cannot find the variable that has been declared without the external Attr.
 This is why I put the variable in a DLL without the External Attr and add it
  to the project file. If I call a procedure in this dll to load


  This is the Dll that has all the files and var's declared normally. Below
  it is the include file that is used by all app's.


           PROGRAM

           MAP
              SetFilePath
           END

INCLUDE('FILEPATH.INC','FileVarsDef')

File1       FILE,PRE(REC),DRIVER('Clarion'),CREATE,RECLAIM,NAME(F__Var1)
File2       FILE,PRE(REC),DRIVER('Clarion'),CREATE,RECLAIM,NAME(F__Var2)
"
"
"

  CODE
     SetFilePath
  RETURN

SetFilePath       PROCEDURE

  CODE

   INCLUDE('FILEPATH.INC','SetPathsVars')

   INCLUDE('FILEPATH.INC','SetFileVars')

  RETURN




   FilePath.inc

         SECTION('FileVarsDef')
         ! Include at source point "Before File Declarations" in dll file.

F__Var1       STRING(60)
F__Var2       STRING(60)

F__PATH1      STRING(48)

         SECTION('FileVarsExtDef')
         ! EXTERNAL DECLARATIONS
         ! Include at source point "Before File Declarations" in main file.
         ! of dll's
F__Var1       STRING(60),EXTERNAL
F__Var2       STRING(60),EXTERNAL

F__PATH1      STRING(48),EXTERNAL


         SECTION('SetPathsVars')
         ! Include at source point "Setup" in main file.

   F__PATH1   = 'PathToFiles\'                    ! Put backslash on end

         SECTION('SetFileVars')
         ! Include at source point "Setup" in main file.
         ! This section can also be used after path is changed at run time.

  F__Var1         = CLIP(F__PATH1) & 'File1'
  F__Var2         = CLIP(F__ PATH1) & 'File2'





  These are the statements to use in your app's to declare the var's

Include('FILEPATH.INC','FileVarsDef')
Include('FILEPATH.INC','SetPathsVars')
Include('FILEPATH.INC','SetFileVars')



Hope this helps. It took some time to figure this all out but am glad to pass
it along to you people. I know, I will need questions answered in the future.


Thanks to Fred for his code to Extern.zip. This is from his readme file.

Fred Schmitthammer
Professional Practice Systems, INC.
(310)804-7674

To use this just compile the .CLA file and run the program in the directory
that contains the file you want to convert.

If you like it let me know....if you don't like it then delete it and don't
let me know !

THIS PROGRAM CHANGES FILES !!!!  MAKE SURE YOU HAVE A BACKUP !!!

YOU USE THIS PROGRAM AT YOUR OWN RISK !!!!!!

Jimmy Rogers
JJ Software
(904) 249-9098

