PDA

View Full Version : clarion redirection file



NewsArchive
12-06-2008, 03:29 AM
Hi all,

Could anyone using SB to update the Clarion redirection file please point me
to some working code to test if the red file contains all the necessary
3rdParty required entries pls ?

I use the text handling to locate and then the instring function to replace
and then the putini but it seems that when the red file has been modified bu
the user (ie replace *.dll = xxxx by *.dll=xxxx then I am in trouble)

Any working example would be most welcome and if there is a way to find out
the red file name also as now I have to ask the user to locate it - c5 to c7
.......

Merci

--

Thank you - Merci

Cordialement - Best Regards
Jean-Pierre GUTSATZ

DMC - Data Management Center - A tool to let you Migrate Import Export
Transfer all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"
party entries

NewsArchive
12-08-2008, 03:05 AM
Hi all,

For those interested here is the required code to check on a red file if the
relevant rdPa3rty entries are present or not

I found out when trying on a clean brand new clarion installation a template
installer that of course they were not so I had to find a way to see if and
if etc .....

I also found out by seing several red files from different installs that not
two are the same and many many template sellers simply always add
......resulting in a nice mess .....

The basic rule was to check wether the five following entries were present
and if not to add them at the end of the relevant lines without touching
whatever was before of course

*.dll for the bin dir
*.lib for the lib files
*.tp? for the template files
*.* for the libsrc and the images

With all the power of SetupBuilder it was just a question of thinking
straight and using the good ones (I had started with file handling mixed to
putini orr other combinations but none were fullproof because some red file
contained for example
*.dll = xxxxx
*.dll = xxxx
*.DLL = xxxxx
etc .....

So I decided to simply use variables to store all necessary values and to
UPPER the red file lines when needed and to compare all in UPPERCASE

The function used is Handle Text File Operation

The top variable is the result IF need be (can be left empty)
The function is to choose the operation to perform
The fileName is ......for the file name :)
The Line is always the LINE NUMBER of the file to work on which means you
need to find it out in a loop on the file
The Advanced is used only in some cases

The principle was to :
1. add a dialog to ask the user to select his red file - as each clarion
version has a different name and we all have our preferences ..... way
easier then to try and detect automatically from the version..
2. loop on this red file and search for the relevant lines each time storing
in a variable the LINE NUMBER and the VALUE
3. for each line change to UPPERCASE and increment a counter variable to get
the line number
4. for each line use a function to find the LEFT,3 and LEFT,5 chars because
*.dll and *.DlL etc ...are always 5 and *.* are 3
5. for each line to compare the LEFT,3 OR LEFT,5 to what you are looking for
6. when a relevant line is found - *.dll or *.lib or *.* or *.tp? store the
value of what is written in that line as it is
7. store the line NUMBER in a variable we will need later to update
8. when such a relevant line is found to search in it for (as we are
UPPERCASED) \3RDPARTY\BIN for example and if found change a variable from 0
to 1

At the end of this loop we then have all five entries found flag to 0 or 1
and all five line numbers and all five line original cased values

Then we simply use the line NUMBERS to REPLACE the existing text with the
same PLUS whatever we need to add ......

This is the code used :

!
////////////////////////////////////////////////////////////////////////////////
! Check redirection file for 3rdParty entries
Set Variable %FILE_LINE_NB% to "0"

Set Variable %FILE_LINE% to ""
Set Variable %FILE_LINE_LEFT_3% to ""
Set Variable %FILE_LINE_LEFT_5% to ""
Set Variable %FILE_LINE_ASIS% to ""

Set Variable %FILE_LINE1_NB% to "0"
Set Variable %FILE_LINE2_NB% to "0"
Set Variable %FILE_LINE3_NB% to "0"
Set Variable %FILE_LINE4_NB% to "0"
Set Variable %FILE_LINE5_NB% to "0"
Set Variable %FILE_LINE1_FOUND% to "0"
Set Variable %FILE_LINE2_FOUND% to "0"
Set Variable %FILE_LINE3_FOUND% to "0"
Set Variable %FILE_LINE4_FOUND% to "0"
Set Variable %FILE_LINE5_FOUND% to "0"
Set Variable %FILE_LINE1_CONTENT% to ""
Set Variable %FILE_LINE2_CONTENT% to ""
Set Variable %FILE_LINE3_CONTENT% to ""
Set Variable %FILE_LINE4_CONTENT% to ""
Set Variable %FILE_LINE5_CONTENT% to ""

Set Variable %FILE_ITEMS% to "0"
Set Variable %FILE_ITEMS% to FUNCTION:Count Lines from "%CLARION_REDFILE%"

Loop (%FILE_ITEMS% Times)
Set Variable %FILE_LINE_NB% to (Increment Variable by 1)
Set Variable %FILE_LINE_ASIS% to FUNCTION:Get Line %FILE_LINE_NB% from
"%CLARION_REDFILE%"
Set Variable %FILE_LINE% to FUNCTION:Upper("%FILE_LINE_ASIS%")
Set Variable %FILE_LINE_LEFT_3% to FUNCTION:Left("%FILE_LINE%", "3")
Set Variable %FILE_LINE_LEFT_5% to FUNCTION:Left("%FILE_LINE%", "5")
! dll
If %FILE_LINE_LEFT_5% Equals "*.DLL" Then
Set Variable %FILE_LINE1_CONTENT% to FUNCTION:Get Line %FILE_LINE_NB%
from "%CLARION_REDFILE%"
Set Variable %FILE_LINE1_NB% to "%FILE_LINE_NB%"
If %FILE_LINE% Contains "\3RDPARTY\BIN" Then
Set Variable %FILE_LINE1_FOUND% to "1"
End
End
! template
If %FILE_LINE_LEFT_5% Equals "*.TP?" Then
Set Variable %FILE_LINE2_CONTENT% to FUNCTION:Get Line %FILE_LINE_NB%
from "%CLARION_REDFILE%"
Set Variable %FILE_LINE2_NB% to "%FILE_LINE_NB%"
If %FILE_LINE% Contains "\3RDPARTY\TEMPLATE" Then
Set Variable %FILE_LINE2_FOUND% to "1"
End
End
! lib
If %FILE_LINE_LEFT_5% Equals "*.LIB" Then
Set Variable %FILE_LINE3_CONTENT% to FUNCTION:Get Line %FILE_LINE_NB%
from "%CLARION_REDFILE%"
Set Variable %FILE_LINE3_NB% to "%FILE_LINE_NB%"
If %FILE_LINE% Contains "\3RDPARTY\LIB" Then
Set Variable %FILE_LINE3_FOUND% to "1"
End
End
! libsrc under all files
If %FILE_LINE_LEFT_3% Equals "*.*" Then
Set Variable %FILE_LINE4_CONTENT% to FUNCTION:Get Line %FILE_LINE_NB%
from "%CLARION_REDFILE%"
Set Variable %FILE_LINE4_NB% to "%FILE_LINE_NB%"
If %FILE_LINE% Contains "\3RDPARTY\LIBSRC" Then
Set Variable %FILE_LINE4_FOUND% to "1"
End
! images
If %FILE_LINE% Contains "\3RDPARTY\IMAGES" Then
Set Variable %FILE_LINE5_FOUND% to "1"
End
End
End

! dll
If %FILE_LINE1_FOUND% Equals "0" Then
Text File: Replace Line %FILE_LINE1_NB% from "%CLARION_REDFILE%" --
%FILE_LINE1_CONTENT%; %CLARIONROOT%\3RDPARTY\BIN
End
! template
If %FILE_LINE2_FOUND% Equals "0" Then
Text File: Replace Line %FILE_LINE2_NB% from "%CLARION_REDFILE%" --
%FILE_LINE2_CONTENT%; %CLARIONROOT%\3RDPARTY\TEMPLATE
End
! lib
If %FILE_LINE3_FOUND% Equals "0" Then
Text File: Replace Line %FILE_LINE3_NB% from "%CLARION_REDFILE%" --
%FILE_LINE3_CONTENT%; %CLARIONROOT%\3RDPARTY\LIB
End
! libsrc AND images under all files
If %FILE_LINE4_FOUND% Equals "0" And %FILE_LINE5_FOUND% Equals "0" Then
Text File: Replace Line %FILE_LINE4_NB% from "%CLARION_REDFILE%" --
%FILE_LINE4_CONTENT%; %CLARIONROOT%\3RDPARTY\LIBSRC;
%CLARIONROOT%\3RDPARTY\IMAGES
! Environment Variable
Edit Environment Variable PATH = ";%CLARIONROOT%\3rdParty\bin;"
ElseIf %FILE_LINE4_FOUND% Equals "0" And %FILE_LINE5_FOUND% Equals "1" Then
Text File: Replace Line %FILE_LINE4_NB% from "%CLARION_REDFILE%" --
%FILE_LINE4_CONTENT%; %CLARIONROOT%\3RDPARTY\LIBSRC
ElseIf %FILE_LINE4_FOUND% Equals "1" And %FILE_LINE5_FOUND% Equals "0" Then
Text File: Replace Line %FILE_LINE4_NB% from "%CLARION_REDFILE%" --
%FILE_LINE4_CONTENT%; %CLARIONROOT%\3RDPARTY\IMAGES
End
!
////////////////////////////////////////////////////////////////////////////////


I also added in this the add to environment PATH because IF the *.dll did
not already point to the good dir then the path also had not been updated
......

......... nearly a days work on this one but at least now......the template
registration seems safe and sound to my eyes (Friedrich checked and finds it
cool <bg>) so here I am .....

feel free to use it of course if you need it .....



--

Thank you - Merci

Cordialement - Best Regards
Jean-Pierre GUTSATZ

DMC - Data Management Center - A tool to let you Migrate Import Export
Transfer all your Data very easily
www.dmc-fr.com
Certified by Microsoft : "Works with Vista" & "Works with Windows Server
2008"