ajout des fonction __get{h,i,}()

This commit is contained in:
Jephté Clain 2014-10-04 10:07:05 +04:00
parent cdfb6d6f92
commit e8481054f4
3 changed files with 31 additions and 6 deletions

View File

@ -1 +1 @@
003005000
003006000

View File

@ -402,6 +402,25 @@ function do_once(key) {
return 1
}
function __geth(field, HEADERS, nbfields, i) {
nbfields = array_len(HEADERS)
if (int(field) == field) {
field = int(field)
if (field >= 1 && field <= nbfields) return field
else return 0
}
field = tolower(field)
for (i = 1; i <= nbfields; i++) {
if (field == tolower(HEADERS[i])) {
return i
}
}
return 0
}
function __geti(num, HEADERS) { if (num != 0) return HEADERS[num] }
function __get(field, HEADERS) { return __geti(__geth(field, HEADERS), HEADERS) }
function ogeth(field, nbfields, i) {
nbfields = array_len(ORIGHEADERS)
if (int(field) == field) {

View File

@ -1995,8 +1995,11 @@ function __array_parsecsv(fields, line, nbfields, colsep, qchar, echar, shou
i = i + 1
}
if (nbfields) {
while (array_len(fields) < nbfields) {
fields[array_len(fields) + 1] = ""
nbfields = int(nbfields)
i = array_len(fields)
while (i < nbfields) {
i++
fields[i] = ""
}
}
return array_len(fields)
@ -2068,7 +2071,7 @@ function printcsv(output, fields) {
array_fill(fields)
array_printcsv(fields, output)
}
function array_findcsv(fields, input, field, value, nbfields, orig, found) {
function array_findcsv(fields, input, field, value, nbfields, orig, found, i) {
array_new(orig)
array_fill(orig)
array_new(fields)
@ -2085,8 +2088,11 @@ function array_findcsv(fields, input, field, value, nbfields, orig, fou
if (!found) {
delete fields
if (nbfields) {
while (array_len(fields) < nbfields) {
fields[array_len(fields) + 1] = ""
nbfields = int(nbfields)
i = array_len(fields)
while (i < nbfields) {
i++
fields[i] = ""
}
}
}