* OPT 1: a little quicker than nested for..next (depending on how many)

xx = dcount(array<1>,@vm)
for x = 1 to xx
  newarr<-1> = array<1,x>:@vm:array<2,x>
next x

---- OR ----------------------------------------

* OPT 2: the fastest...(cos it maintains a file pos pointer)

arr1   = array<1>
arr2   = array<2>
more = 1
loop
   remove val1 from arr1 setting more
   remove val2 from arr2 setting junk
   newarr<-1> = val1:@vm:val2
while more
repeat

---- OR ----------------------------------------
OPT 3: the neatest.. (ie least maintainable)

arr1 = array<1>
arr2 = array<2>
arr1 = change(arr1,@vm, '+':@vm) : '+'
newarr = cats(arr1,arr2)
convert '+' to @vm in newarr

(use whatever char you wont have in your data)

On 10 September 2012 23:39, Dave Laansma <dlaan...@hubbardsupply.com> wrote:

> I get flat files that I'd like to 'flip' to accommodate the multi-value
> database. For example, given this table:
>
>
>
> 123456<vm>DAVID JONES<vm>1234 MAIN ST.<vm>ANYWHERE<vm>MI<vm>12345<am>
>
> 654321<vm>JOHN SMITH<vm>4321 MAIN ST.<vm>ANYWHERE<vm>MI<vm>12345
>
>
>
> Is there a function that will change it to:
>
>
>
> 123456<vm>654321<am>
>
> DAVID JONES<vm>JOHN SMITH<am>
>
> 1234 MAIN ST.<vm>4321 MAIN ST.<am>
>
> ANYWHERE<vm>ANYWHERE<am>
>
> MI<vm>MI<am>
>
> 12345<vm>12345
>
>
>
> Right now I use these nested loops, which tend to take a while depending
> on the size of TABLE:
>
>
>
> NEW.TABLE = ""
>
>
>
> FOR A1 = 1 TO DCOUNT(TABLE,@AM)
>
>   FOR V1 = 1 TO DCOUNT(TABLE<A1>,@VM)
>
>     NEW.TABLE<V1,A1> = TABLE<A1,V1>
>
>   NEXT V1
>
> NEXT A1
>
>
>
> TABLE = NEW.TABLE
>
>
>
> Sincerely,
>
> David Laansma
>
>
>
> _______________________________________________
> U2-Users mailing list
> U2-Users@listserver.u2ug.org
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to