Columns 1 and 2 are the codename and the verbose name for a function that is calling to another function (defined by columns 4 and 5, in the same way)
I have the folowing script to process the file
Code:
#Este AWK imprime el arbol de llamadas de funciones
BEGIN{
FS="|"
Debug=1
}
{
t=FuncIsUsing[$1] $4 ", "
FuncIsUsing[$1]=t
t=FuncIsUsedBy[$4] $1 ", "
FuncIsUsedBy[$4]=t
TotFunctions[$1]
TotFunctions[$4]
}
END{
#Detect not used functions
for (x in TotFunctions){
if (!(x in FuncIsUsedBy)){
print "Function ["x"] is not used"
FuncNotUsed[x]
}
}
#Recorrer cada rama de las que no son llamadas
for (x in FuncNotUsed){
printBranch(x, 1)
}
}
function printBranch(raiz, sangria){
for (i=1;i<sangria;i++){
printf " "
}
print "["raiz"]"
if (raiz in FuncIsUsing){
if (1==Debug) print "Function ["raiz"] is using: ["FuncIsUsing[raiz]"]"
split(FuncIsUsing[raiz], funcQueLlama, ", ")
for (f in funcQueLlama){
if ("" != funcQueLlama[f])
printBranch(funcQueLlama[f], sangria+1)
}
}else{
if (1==Debug) print "Is not using functions"
}
}
It produces the following output
Code:
Function [SPF_HC00041] is not used
Function [SPF_HC00045] is not used
Function [SPF_HC00046] is not used
Function [SPF_HC00048] is not used
Function [SPF_HC00049] is not used
Function [SPF_RS00045] is not used
Function [SPF_RS00063] is not used
Function [SPF_RS00064] is not used
Function [SPF_HC00035] is not used
Function [SPF_HC00050] is not used
[SPF_HC00035]
Function [SPF_HC00035] is using: [SPF_HC00034, SPF_HC00044, SPF_HC00044, ]
[SPF_HC00034]
Function [SPF_HC00034] is using: [SPF_HC00047, ]
[SPF_HC00047]
Is not using functions
[SPF_HC00045]
Function [SPF_HC00045] is using: [SPF_HC00039, SPF_HC00024, ]
[SPF_HC00039]
Is not using functions
[SPF_HC00024]
Is not using functions
[SPF_RS00063]
Function [SPF_RS00063] is using: [SPF_HC00014, SPF_HC00001, ]
[SPF_HC00014]
Function [SPF_HC00014] is using: [SPF_HC00026, ]
[SPF_HC00026]
Is not using functions
[SPF_RS00045]
Function [SPF_RS00045] is using: [SPF_HC00013, SPF_HC00026, ]
[SPF_HC00013]
Function [SPF_HC00013] is using: [SPF_HC00029, ]
[SPF_HC00029]
Is not using functions
[SPF_HC00046]
The matter is in the next output part:
Code:
Function [SPF_RS00063] is using: [SPF_HC00014, SPF_HC00001, ]
[SPF_HC00014]
Function [SPF_HC00014] is using: [SPF_HC00026, ]
[SPF_HC00026]
Is not using functions
[SPF_RS00045]
It dosn't print detail for SPF_HC00001, when it makes the recursive call, lost the current values for my array funcQueLlama.
declare ALL your local variables in the function declaration - even-though you don't pass them. See if it helps:
Code:
function printBranch(raiz, sangria, i,funcQueLlama,f){
for (i=1;i<sangria;i++){
printf " "
}
print "["raiz"]"
if (raiz in FuncIsUsing){
if (1==Debug) print "Function ["raiz"] is using: ["FuncIsUsing[raiz]"]"
split(FuncIsUsing[raiz], funcQueLlama, ", ")
for (f in funcQueLlama){
if ("" != funcQueLlama[f])
printBranch(funcQueLlama[f], sangria+1)
}
}else{
if (1==Debug) print "Is not using functions"
}
}
Hello forum members,
Please wirte a sample program for print the 1 - 100 and 100 -1 using recursive function.
Thanks & regards
Siva Rangnanath (2 Replies)
Hi,
I don't know if you can help or if this is even possible, but I am trying to run the following function over an ssh and (depending on the itteration I choose) keep getting unexpected token or undefined symbol errors.
The function is:
killtree()
{
typeset parent=$1
typeset child... (1 Reply)
I created two functions that output two random variables. I want to output them in the output file. But it does not seem to work.
# Function rgaussian1(r1, r2)
# Gaussian random number generator
function rgaussian1(r1, r2) {
pi = 3.142
v1 = sqrt( -2 * log(rand()) )
v2... (18 Replies)
I am facing some problem in perl recurssive function function
my @array_parent = (Some inegers);
my $outputfile = 'output.txt';
my $master_file = 'master.txt';
open (MASTER,"$>>master.txt");
foreach my $child (@array_parent){
my $line = `grep "$child" "$outputfile"`;
... (1 Reply)
I have the following function in a bash script that fails to return the sorted array. I think the problem lies in the recursion not correctly passing the arrays, but I can't tell what I'm doing wrong. Anyone see the problem?
function quicksort () {
local array=( `echo "$1"` )
local... (7 Replies)
Actually I got a list of file end with *.txt
I want to use the same command apply to all the *.txt
Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics.
For example:
I got the file below:
file1.txt
file2.txt
file3.txt... (4 Replies)
Can someone tell me, how do i write a recursive code using shell ( eg like 'for' loop in C) which outputs the record to a database table as one row per iteration? (7 Replies)
This is shell script I have made to lists out directory contents and filenames for any given directory (without using ls command). There is some problem in dirfunc function call which I have marked 1 is not working. Can anybody suggest what is the problem there and how should I correct it.
... (2 Replies)
Hi all,
I have to move all the files in a tree directory structure to a single directory. Inorder to know which file is from which directory , i'll have to add the name of the directory to the file name. For this i wrote a recursive function which is as follows... (4 Replies)
Hi everyone, i need your input on this. We can express a function recursivly like this
A(n) = (2 n = 0
5 n = 1
A(n − 1) + A(n − 2) % 47 n > 1
How would i go about constructing a recursive function for this?... (1 Reply)