Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arrays
#1
I declare array create 10 elements. I use first 2 elements rest 8 contains null. How can I remove 8 elements.
#2
a.redim(2)
#3
This works fine for single dimesion array. Acutally I have 2 dimension it matches strings if match is found the array element should remove itself from the list. How do I do that?
#4
Please show your code.
#5
Code:
Copy      Help
1,,,count1=es4.NumRows+1
2,,,for count 2 count1
3,,,,es4.GetCell(scrip 1 count)
4,,,,out "%i %s %s %i" count scrip am[acount 1] acount
5,,,,if scrip=am[acount 1]
6,,,,,es4.GetCell(qty 2 count)
7,,,,,qty=val(qty)+val(am[acount 2])
8,,,,,if val(qty)=0
9,,,,,,rang.from(count ":" count)
10,,,,,,es4.ws.Range(rang).Delete
11,,,,,,am.remove(acount)
12,,,,,,acount=acount-1
13,,,,,,row=row-1
14,,,,,else
15,,,,,,es4.SetCell(qty 2 count)
16,,,,,,am.remove(acount)
17,,,,,,acount=acount-1

Now on Line 10 & 11 if the total of both strings is 0 then the excel row & the array element should delete itself.
#6
Function ArrayStrRemoveRow
Code:
Copy      Help
;/
function ARRAY(str)&a row

;Removes one row from 2-dim str array.
;Error if some argument is invalid.


if(a.ndim!=2 or row<a.lbound or row>a.ubound) end ES_BADARG

str* b=&a[a.lbound(1) row]
int i inrow=a.len(1)
for(i 0 inrow) b[i].all

inrow*sizeof(str)
int nmove=a.ubound-row*inrow
if(nmove) memmove b b+inrow nmove; memset &a[a.lbound(1) a.ubound] 0 inrow

a.redim(a.len-1 a.lbound)

err+ end _error

example
Macro
Code:
Copy      Help
out
ARRAY(str) a.create(2 4) ;;2 columns, 4 rows
int i
for i a.lbound a.ubound+1
,a[0 i]=i
,a[1 i]=i+10

ArrayStrRemoveRow a 1

for i a.lbound a.ubound+1
,out "%s %s" a[0 i] a[1 i]


Forum Jump:


Users browsing this thread: 1 Guest(s)