carice
25th June 2002, 17:08
Is it possible to know in a program script where the source of a script, dll,... is situating? Which script does a session used when you start from a certain VRC?

I have to make a program that checks the number of different lines between a baan standard script (that can situated in the standard, update standard, localisation layer) and the customisated script. Aren't there any dll that can help me to do this job?

dhowells
25th June 2002, 17:53
Try calling the explode command (via shell command) from your program script. This will tell you which object is running. From there you could get the appropriate code.

NPRao
25th June 2002, 19:47
Hi Carise,

This is quite easy and there is no existing dll but you can build your own tool.

Firstly, you need to use the function, vrc_search_session() function from the Tools DLL, ttdllvrcsearch and you have to set the package VRC (ttadv111).

After you get a return value > 0 then you need to find the script attached to the session, from the fields, ttadv200.cmop and ttadv200.cprs.

Then you need to use the function, vrc_search_script() and then get the return values > 0. This gives the last found script VRC.

Then reset the VRC tree (ttadv111) to the VRC below the last found VRC, and then use the vrc_search_script again for > 0.

Now you found the last 2 VRC's of that script.

So now get the script source paths using -

1. get.envpath function from the tools DLL - ttdllenvpath (or)
2. BaaN Standard Function - long pathname( string file_basename(16), string file_type, ref string file_path(256) )

Now you can use the shell() or run.prog() functions, to find the differences using -

standard BaaN binary in $BSE/bin/diff[BaaN-version] - (or)
or call the unix command diff and redirect the output to a temporary file.

Then you parse the temporary file to find the LOC, differences etc.

I dont know which BaaN version you are on, I found a new Tools DLL,
Library ttdllnewer.vrc
Component present in newer VRC

Good Luck!

evesely
26th June 2002, 16:10
Just a minor note of warning on the vrc_search functions. They work great, but I believe that you need to be in (or be able to switch to) company zero to run them. I had an application where I wanted to do something similar to your requirements, but it needed to work no matter who ran the script. Since I couldn't count on every user to have the ability to switch to company 0, I had to write a lot of code myself.:(

Good luck!

carice
26th June 2002, 16:17
thanks for your response

I have tried the dll but he always return zero. What am i doing wrong? Did you have an example?
function search.script.vrc()
{
extern domain ttadv.cpac cpac1
extern domain ttadv.cmod cmod1
extern domain ttadv.cprs cprs1
long tdep1

extern domain ttadv.vers tver(50) fixed
extern domain ttadv.rele trel(50) fixed
extern domain ttadv.cust tcus(50) fixed

cpac1 = ttadv176.sofc(1;2)
cmod1 = ttadv176.sofc(3;3)
cprs1 = ttadv176.sofc(6)
tdep1 = 5

retval =vrc_search_script(cpac1,cmod1,cprs1,tdep1,tver,trel,tcus)

if retval <> 0 then
message("found")
endif

}

mark_h
26th June 2002, 18:31
Hello carice!

Below is a sample of one I developed, but have not actually used.


function verify_script_in_vrc()
{
domain ttadv.vers vers.f(2) | Users current version
domain ttadv.rele rele.f(2) | Users current release
domain ttadv.cust cust.f(2) | Users customer version

vers.f(1,1) = parent.version
rele.f(1,1) = parent.release
cust.f(1,1) = parent.customer
if(vrc_search_script(package,module,prog.script,1,vers.f,rele.f,cust.f))
then
else
message("Script not found in parent VRC.")
choice.again()
endif
}


In this example the package, module and program script are form fields. The parent variables are set in another routine, but should contain the package info I am searching. It looks like you need to set the tver, trel, tcus variables. It needs to know where to start the search. In my example I am just verifying that it is in the input package and VRC.

Good Luck!

Mark

mark_h
26th June 2002, 18:33
Thought I would also post the code to get the parent VRC.


function get_parent_pvrc()
{
domain ttadv.vers vers.f,vers.t,vers.r | Users current version
domain ttadv.rele rele.f,rele.t,rele.r | Users current release
domain ttadv.cust cust.f,cust.t,cust.r | Users customer version
| Init stuff.
vers.r = ""
rele.r = ""
cust.r = ""
| Find parent script.
vers.f = first.version
rele.f = first.release
cust.f = first.customer
| Look all the way up to your current VRC.
vers.t = curr.version
rele.t = curr.release
cust.t = curr.customer
if (script.present.in.newer.vrc(
package, | Users current package
module, | Current module.
prog.script, | Program Script
vers.f,
rele.f,
cust.f,
vers.t,
rele.t,
cust.t,
vers.r,
rele.r,
cust.r)) then
parent.version = vers.r
parent.release = rele.r
parent.customer= cust.r
else
parent.version = first.version
parent.release = first.release
parent.customer= first.customer
endif
display("parent.version")
display("parent.release")
display("parent.customer")
}


Mark

NPRao
26th June 2002, 19:46
Carise,

I am not aware of which BaaN version are you working up...

When I checked our system (our version is BaaN-5.2) I found this info in the Program Scripts session - ttadv2130s000.

NPRao
26th June 2002, 20:05
Checking back on Carise's and Mark's code, I suggest to use this code


|* Variables to store the tree depth
domain ttadv.vers tvers.f(40)
domain ttadv.vers tvers.t(40)
domain ttadv.rele trele.f(40)
domain ttadv.rele trele.t(40)
domain ttadv.cust tcust.f(40)
domain ttadv.cust tcust.t(40)
domain ttadv.vers vers.f
domain ttadv.vers vers.t
domain ttadv.rele rele.f
domain ttadv.rele rele.f
domain ttadv.cust cust.t
domain ttadv.cust cust.t
string sourcevrc(10)
string targetvrc(10)
|* source and target VRC
long depth
long tdep.f
long tdep.t

select ttadv111.*
from ttadv111
where ttadv111._index1 = {:ttadv230.cpac,
:vers.f, :rele.f, :cust.f}
as set with 1 rows
selectdo
tdep.f = ttadv111.tdep
copy.mem(tvers.f, ttadv111.tver)
copy.mem(trele.f, ttadv111.trel)
copy.mem(tcust.f, ttadv111.tcus)
endselect

select ttadv111.*
from ttadv111
where ttadv111._index1 = {:ttadv230.cpac,
:vers.t, :rele.t, :cust.t}
as set with 1 rows
selectdo
tdep.t = ttadv111.tdep
copy.mem(tvers.t, ttadv111.tver)
copy.mem(trele.t, ttadv111.trel)
copy.mem(tcust.t, ttadv111.tcus)
endselect

|* First Version
depth = vrc_search_script(ttadv230.cpac, ttadv230.cmod,
ttadv230.cprs, tdep.f, tvers.f,
trele.f, tcust.f)
if depth > 0 then
sourcevrc = tvers.f(1,depth) & trele.f(1,depth) &
tcust.f(1,depth)
|* get the script source
|* you can use the function - search.path.program.script()
|* if depth < 0 it means the components is expired in the first version
|* if depth = 0 it means the components is not found
endif

|* Last Version
depth = vrc_search_script(ttadv230.cpac, ttadv230.cmod,
ttadv230.cprs, tdep.t, tvers.t,
trele.t, tcust.t)
if depth > 0 then
targetvrc = tvers.t(1,depth) & trele.t(1,depth) &
tcust.t(1,depth)
|* get the target source
|* you can use the function - search.path.program.script()
|* if depth < 0 it means the components is expired in the last version
|* if depth = 0 it means the components is not found
endif

|* find differences between these 2 scripts and redirect the diff output
|* file to a temporary file, ex- diff prog1 prog2 > difffile
|* also check the various diff options using $man diff on Unix
|* or with the $BSE/bin/diff[baan-version] --help
|* Parse the diff output file - difffile and get the statistics


I hope this will help you out.

OmeLuuk
27th June 2002, 10:23
Do you know your tools?
Did you ever consider using session ttadv6450m000 (triton2.2, triton3.1, Baan IV, Baan ERP 5.x). It does what you want and even more!

NPRao
27th June 2002, 18:23
OmeLuuk,

The output of the sessions, shows the differences between the 2 VRCs of a script but it does not give you the statistical info.

To get the statistical info one needs to parse the output of a diff between 2 files.

Carise's requirement is

I have to make a program that checks the number of different lines between a baan standard script (that can situated in the standard, update standard, localisation layer) and the customisated script. Aren't there any dll that can help me to do this job?