Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rotating a grid
Message
De
14/02/2004 03:25:35
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
13/02/2004 15:42:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Divers
Thread ID:
00867251
Message ID:
00877369
Vues:
17
>>>I would like to take an existing table and have it display the data in a grid, but I need the grid to be rotated 90 degrees so that:
>>>
>>>
>>>
>>>           Field 1      Field 2    Field 3
>>>--------------------------------------------------
>>>Record 1
>>>--------------------------------------------------
>>>Record 2
>>>--------------------------------------------------
>>>Record 3
>>>--------------------------------------------------
>>>
>>>becomes:
>>>
>>>           Record 1      Record 2    Record 3
>>>--------------------------------------------------
>>>Field 1
>>>--------------------------------------------------
>>>Field 2
>>>--------------------------------------------------
>>>Field 3
>>>--------------------------------------------------
>>>
>>>
>>>Is there an easy way to accomplish this that I am just overlooking?
>>>
>>>TIA,
>>
>>Phil,
>>
>>#Define MAXFIELDS 255
>>Local ix
>>Create Cursor test (Field1 i, Field2 c(15), Field3 d)
>>For ix = 1 To MAXFIELDS
>>  Insert Into test Values (m.ix,Sys(2015),Date()+m.ix)
>>Endfor
>>Local Array aMaxLen[1],aStruc[Reccount(),4]
>>Select Max(Max(;
>>  Len(Trim(Transform(Field1))),;
>>  Len(Trim(Transform(Field2))),;
>>  Len(Trim(Transform(Field3))))) ;
>>  from test ;
>>  into Array aMaxLen
>>Local lcTempFile, lcTemp
>>lcTempFile = Sys(2015)+'.tmp'
>>Set Textmerge To Memvar m.lcTemp Noshow
>>Set Textmerge On
>>For ix=1 To Fcount()
>>  Scan
>>\\<<Evaluate(Field(m.ix))>>,
>>  Endscan
>>\
>>Endfor
>>Set Textmerge To
>>Set Textmerge Off
>>Strtofile(m.lcTemp,m.lcTempFile)
>>
>>aStruc = 0
>>For ix=1 To Alen(aStruc,1)
>>  aStruc[m.ix,1] = 'rec'+Ltrim(Str(m.ix))
>>  aStruc[m.ix,2] = 'C'
>>  aStruc[m.ix,3] = aMaxLen
>>Endfor
>>Create Cursor Rotated From Array aStruc
>>Append From (m.lcTempFile) Type Delimited
>>Erase (m.lcTempFile)
>>Browse
>>
Cetin
>
>Cetin, your code is BRILLIANT !!!

Enrique,
Thanks for the compliment :) Honestly I too originally thought as you, putting into an array then transposing (I already have array transposing code ready:). But as soon as I noticed max allowable fields*records would exceed array limit regreted, plus an 255 records table operation with scan..endscan, strtofile() etc was nothing to VFP speed wise :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform