Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I align 2 arrays?
#6
Try this for string arrays:

Macro Align String Arrays
Code:
Copy      Help
str a2=
;AA
;BB
;FF
;GG
;HH

str a1=
;CC
;DD
;EE
;FF
;GG

ARRAY(str) a b
a=a1; b=a2
ARRAY(str) c.create(a.len*4)
ARRAY(str) d.create(b.len*4)
int i j k; int base=65

for i 0 a.len
,j=a[i][0]-base
,c[j]=a[i]

for i 0 b.len
,k=b[i][0]-base
,d[k]=b[i]

if(j>k) c.redim(j+1); d.redim(j+1)
else c.redim(k+1); d.redim(k+1)

a=c; b=d;
c.redim; d.redim
out
for i 0 a.len
,out "a[%i]= %s" i a[i]
out ""
for i 0 b.len
,out "b[%i]= %s" i b[i]


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)