Hi
I have an associative array, when I want to print this array via a function, I have no problem.
this array is populate whit a file that contain this structure
file.txt
******** begin
data
fin
******** begin
data
fin
********
But if I include into the print cycle another function to capture a record of a file, the original associative array is modified.
I do not understand why. It is no logical, because already the associative array exist. Only I included a function, to extract a certain value , from another file.csv.
function PrintAssociativeArray(arreglo){
for i=1 to counter
{
print arreglo
extract var from arreglo[9]
###value=OpenFiletoExtractValue(var) - If i include this, the associative array is modified. arreglo[2] always
print value
}
}
function OpenFiletoExtractValue(variable, valor){
while ( getline "file.csv")
if variable
return valor
}
##Main
{
populate array
PrintAssociativeArray(array)
}
output without OpenFiletoExtractValue(var) function
-----------------------------------------------------------------------------------------------------------------------------------------
C_ATLENBSUR,53268357,0,0,1,1,0,0,1,16
0,
1,********************** TRAZA ABONADO: 53268357 ACCION ;C_ATLENBSUR;ATL;48803192 ********************** original
2,CENTRAL: C_ATLENBSUR
3, <
4,
5,
6,SUSCP: SNB=3268357;
7,COMANDO ACEPTADO
8,SUBSCRIBER DATA
9,SNB DEV DETY SUT SCL MIS COS
10,53268357 LI3-15197 OBA-74
C_ATLENBSUR,LI3,15197 "this is the var"
-2
11, KWC-1
12, CCB-1
13,
14,END
15,
16,
C_ATLENBSUR;53268357;53268357;LI3-15197;; ;OBA-74|KWC-1|CCB-1;3
output with OpenFiletoExtractValue(var)
always is modified the second line of my associative array. Print the last line of the file C_TOLENITAS;C_TOLENITAS;LIPRAE-0&&-127;SS9.
-----------------------------------------------------------------------------------------------------------------------------------------
C_ATLENBSUR,53267454,0,0,1,1,0,0,1,16
0,
1,C_TOLENITAS;C_TOLENITAS;LIPRAE-0&&-127;SS9 - modified, always this is the last line from file.csv, is not logical
2,CENTRAL: C_ATLENBSUR
3, <
4,
5,
6,SUSCP: SNB=3268357;
7,COMANDO ACEPTADO
8,SUBSCRIBER DATA
9,SNB DEV DETY SUT SCL MIS COS
10,53268357 LI3-15197 OBA-74
C_ATLENBSUR,LI3,15197 "this is the var"
15197;15104;15231;C_ATLENBSUR;R_ATLENSDAD;LI3;15104 -2 "this is the value returned, ok
11, KWC-1
12, CCB-1
13,
14,END
15,
16,
C_ATLENBSUR;53267454;53268357;LI3-15197;; ;OBA-74|KWC-1|CCB-1;3
and always print at the last line de same second field 53267454.
file.csv
C_ATLENBSUR;C_ATLENBSUR;LI3-0&&-127;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-128&&-255;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-256&&-383;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-384&&-511;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-512&&-639;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-640&&-767;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-768&&-895;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-896&&-1023;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-1024&&-1151;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-1152&&-1279;SS0
..
...
.....
......
I appreciated any suggestion.
Thanks malpa
I have an associative array, when I want to print this array via a function, I have no problem.
this array is populate whit a file that contain this structure
file.txt
******** begin
data
fin
******** begin
data
fin
********
But if I include into the print cycle another function to capture a record of a file, the original associative array is modified.
I do not understand why. It is no logical, because already the associative array exist. Only I included a function, to extract a certain value , from another file.csv.
function PrintAssociativeArray(arreglo){
for i=1 to counter
{
print arreglo
extract var from arreglo[9]
###value=OpenFiletoExtractValue(var) - If i include this, the associative array is modified. arreglo[2] always
print value
}
}
function OpenFiletoExtractValue(variable, valor){
while ( getline "file.csv")
if variable
return valor
}
##Main
{
populate array
PrintAssociativeArray(array)
}
output without OpenFiletoExtractValue(var) function
-----------------------------------------------------------------------------------------------------------------------------------------
C_ATLENBSUR,53268357,0,0,1,1,0,0,1,16
0,
1,********************** TRAZA ABONADO: 53268357 ACCION ;C_ATLENBSUR;ATL;48803192 ********************** original
2,CENTRAL: C_ATLENBSUR
3, <
4,
5,
6,SUSCP: SNB=3268357;
7,COMANDO ACEPTADO
8,SUBSCRIBER DATA
9,SNB DEV DETY SUT SCL MIS COS
10,53268357 LI3-15197 OBA-74
C_ATLENBSUR,LI3,15197 "this is the var"
-2
11, KWC-1
12, CCB-1
13,
14,END
15,
16,
C_ATLENBSUR;53268357;53268357;LI3-15197;; ;OBA-74|KWC-1|CCB-1;3
output with OpenFiletoExtractValue(var)
always is modified the second line of my associative array. Print the last line of the file C_TOLENITAS;C_TOLENITAS;LIPRAE-0&&-127;SS9.
-----------------------------------------------------------------------------------------------------------------------------------------
C_ATLENBSUR,53267454,0,0,1,1,0,0,1,16
0,
1,C_TOLENITAS;C_TOLENITAS;LIPRAE-0&&-127;SS9 - modified, always this is the last line from file.csv, is not logical
2,CENTRAL: C_ATLENBSUR
3, <
4,
5,
6,SUSCP: SNB=3268357;
7,COMANDO ACEPTADO
8,SUBSCRIBER DATA
9,SNB DEV DETY SUT SCL MIS COS
10,53268357 LI3-15197 OBA-74
C_ATLENBSUR,LI3,15197 "this is the var"
15197;15104;15231;C_ATLENBSUR;R_ATLENSDAD;LI3;15104 -2 "this is the value returned, ok
11, KWC-1
12, CCB-1
13,
14,END
15,
16,
C_ATLENBSUR;53267454;53268357;LI3-15197;; ;OBA-74|KWC-1|CCB-1;3
and always print at the last line de same second field 53267454.
file.csv
C_ATLENBSUR;C_ATLENBSUR;LI3-0&&-127;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-128&&-255;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-256&&-383;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-384&&-511;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-512&&-639;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-640&&-767;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-768&&-895;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-896&&-1023;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-1024&&-1151;SS0
C_ATLENBSUR;C_ATLENBSUR;LI3-1152&&-1279;SS0
..
...
.....
......
I appreciated any suggestion.
Thanks malpa