Hi Evan

This might be of some help .. It's a quick hacky utility I wrote to list all
fields in a file for a given set of record ids.
You can customize it to your own use.


Just to echo what others have said: this isn't necessarily the best way to
get to the content, since UniVerse dictionaries typically accumulate lots of
crap, including once-only synonyms, lots of calculated and translation
fields etc. 

There are two routines: LIST.FIELDS is the main routine, which just calls
one subroutine called stdTCL.

Good luck.

PS: one thing to beware of. It is possible (and I don't condone it, it's a
really stupid idea) to have a calculated field call a subroutine that
actually does something like an update. So do check for these sorts of
things before running it.. 

Brian

-----------------------------------------| LIST.FIELDS
|--------------------------------------------


PROGRAM LIST.FIELDS
*
---------------------------------------------------------------------------
*  @@Name        : LIST.FIELDS
*  @@Description : List all fields for given record(s)
*  @@Version     : 1.0
*
---------------------------------------------------------------------------
*  Brief Description
*  -----------------
*  @@INFO {
*   This displays records whilst listing all fields (including ITypes)
*   in the dictionary.
*   You can choose to show just the data fields, and listings that ignore
*   synonyms.
*  }
*
---------------------------------------------------------------------------
*  Warnings
*  --------
*
*
---------------------------------------------------------------------------
*  Modification History
*  --------------------
*  @@Log
*
---------------------------------------------------------------------------
* Keywords
* --------
*
* --------------------------------------------------------------------------
* To Do List
* ----------
*
* --------------------------------------------------------------------------
$OPTIONS PICK

       EQU ASSOC.NAME To 1
       EQU ASSOC.LIST To 2
       EQU ASSOC.WIDTH To 3

       Call stdTCL( FileName, FL, ItemList, Options )

       If FileName = "" then
          GoSub Usage
          STOP
       End

       NoPage = Count(Options,"NOPAGE")
       Sparse = Count(Options, "SPARSE")
       DataOnly = Count(Options,"DATA")

       If ItemList = '' Then
          GoSub Usage
          STOP
       End


       Open "DICT", FileName To DFL Else
          Crt "Cannot open DICT ":FileName
          STOP
       end

       Dim FieldList(300)
       If Count(Options,"PRINTER") Then
          Printer On
          PageWidth = @LPTRWIDE
       End Else
          PageWidth = @CRTWIDE
       End



       FieldNames = ""
       SparseList = ""
       NonAssoc   = ""
       Assocs     = ""

       SSelect DFL
       NoFields = 0
       Fin = 0

       Loop
          ReadNext Id Else Fin = 1
       Until Fin Do
          Read DRec From DFL, Id Else
             DRec = ""
          End
          First = Upcase(TrimF(DRec)[1,1])
          AssocName = ''
          Begin Case
             Case First = "D" Or First = "A" Or First = "S"
                If DRec<2> Match "1n0n" Then
                   If Sparse Then
                      If DRec<2> > 0 Then
                         If SparseList<DRec<2>> = "" Then
                            SparseList<DRec<2>> = Id
                            NoFields += 1
                            FieldNames<NoFields> = Id
                            FieldList(NoFields) = DRec
                            If First = 'D' Then
                               AssocName = DRec<7>
                               Width = DRec<5>["L",2,1]["R",2,1]["T",2,1]
                            End
                            GoSub UpdateAssoc
                         End
                      End
                   End Else
                      NoFields += 1
                      FieldNames<NoFields> = Id
                      FieldList(NoFields) = DRec
                      If First = 'D' Then
                         AssocName = DRec<7>
                         Width = DRec<5>["L",2,1]["R",2,1]["T",2,1]
                      End
                      GoSub UpdateAssoc
                   End
                End

             Case First = "I"
                If Not(DataOnly) Then
                   If DCount(DRec,@fm) >= 20 Then
                      NoFields += 1
                      FieldNames<NoFields> = Id
                      FieldList(NoFields) = DRec

                      AssocName = DRec<7>
                      Width = DRec<5>["L",2,1]["R",2,1]["T",2,1]
                      GoSub UpdateAssoc
                   End
                End
          End Case
       Repeat


       If NoFields = 0 Then
          Crt "No Fields to display"
          STOP
       End

       NoItems = DCount(ItemList,@fm)
       NoNonAssocs = DCount(NonAssoc, @FM)
       NoAssocs = DCount(Assocs,@FM)

       For I = 1 To NoItems
          Remove @ID From ItemList Setting DVAR
          Print "Item = ":@ID
          Read @Record From FL, @ID Then
             GoSub GetRec
          End Else
             Print "  *** Item Missing"
          End
          Print
          Print
       NExt

       If Count(Options,"PRINTER") Then
          Printer Off
          Printer Close
       ENd

       STOP

*---------------------------------------------------------------------------
* GetField
*---------------------------------------------------------------------------
GetField: 
       DRec = FieldList(FieldNo)
       First = UpCase(trimF(DRec)[1,1])
       Begin Case
          Case First = "D"
             If DRec<2> = 0 Then
                D = @ID
             End Else
                D = @Record<DRec<2>>
             End
             C = DRec<3>
          Case First = "A" Or First = "S"
             If DRec<2> = 0 Then
                D = @ID
             End Else
                D = @Record<DRec<2>>
             End
             If DRec<8> <> "" Then
                D = OConvS(D,DRec<8>)
             End
             C = DRec<7>
          Case First = "I"
             D = IType(DRec)
             C = DRec<7>
       End Case
       If C <> "" then
          D = OConvS(D,C)
       End
       Return

*---------------------------------------------------------------------------
* GetRec
*---------------------------------------------------------------------------
GetRec:   
* First do any non-associated fields
       For J = 1 To NoNonAssocs
          FieldNo = NonAssoc<J>
          GoSub GetField
          Print FieldNames<FieldNo> "L#15":":":
          If IsNull(D) Then
             Print "NULL"
          End Else
             Print D<1,1>
             For K = 2 To DCount(D,@vm)
                Print Space(16):D<1,K>
             Next
          End
       Next

* Now try to fit any associations across

       ThisAssoc = ''
       Depth = 0
       For A = 1 To NoAssocs
          Dc = DCount(Assocs<ASSOC.LIST,A>,@SVM)
          For J = 1 to Dc
             FieldNo = Assocs<ASSOC.LIST,A, J>
             GoSub GetField
             If IsNull(D) Then
                D = "NULL"
             End

             ThisAssoc<J> = D
             If DCount(D,@VM) > Depth Then
                Depth = DCount(D,@VM)
             End
          Next

* Column headers
          SoFar = 0
          For J = 1 to Dc
             Width = Assocs<ASSOC.WIDTH, A, J>
             FieldNo = Assocs<ASSOC.LIST, A, J>
             If Width + SoFar >= PageWidth Then
                Print
                SoFar = 0
             End
             Print FieldNames<FieldNo> ("L#":Width) :" ":
             SoFar += (Width + 1)
          Next
          Print

* Now the data
          For K = 1 to Depth
             SoFar = 0
             For J = 1 to Dc
                Width = Assocs<ASSOC.WIDTH, A, J>
                FieldNo = Assocs<ASSOC.LIST, A, J>
                If Width + SoFar >= PageWidth Then
                   Print
                   SoFar = 0
                End
                Print ThisAssoc<J, K> ("L#":Width) :" ":
                SoFar += (Width + 1)
             Next
             Print
          Next
       Next

       If Not(NoPage) then
          Crt "Press any key to Continue ":; C = KeyIn()
          C = Upcase(C)
          If C = "Q" Then STOP
          If C = "N" Then NoPage = @True
       End
       Return

*---------------------------------------------------------------------------
* UpdateAssoc
*---------------------------------------------------------------------------
UpdateAssoc:      

       If AssocName = '' then
          NonAssoc<-1> = NoFields
       End Else
          Locate AssocName In Assocs<ASSOC.NAME> By "AL" Setting Pos Else
             Ins AssocName Before Assocs<ASSOC.NAME,Pos>
             Ins "" Before Assocs<ASSOC.LIST,Pos>
             Ins "" Before Assocs<ASSOC.WIDTH, Pos>
          End
          Assocs<ASSOC.LIST,Pos,-1> = NoFields
          If Not(Width) then Width = 10
          Assocs<ASSOC.WIDTH,Pos,-1> = Width
       End

       Return

*---------------------------------------------------------------------------
* Usage
*---------------------------------------------------------------------------
Usage:         
       Crt "LIST.FIELDS"
       Crt "==========="
       Crt
       Crt "List all/designated fields for selected records."
       Crt
       Crt "Syntax:"
       Crt
       Crt "LIST.FIELDS filename {*|[id id..]} options"
       Crt
       Crt "Options:"
       Crt
       Crt " /DATA     Show Data fields only (no I Descriptors)"
       Crt " /SPARSE   Do not show synonyms"
       Crt " /PRINTER  Send to printer"
       Crt " /NOPAGE   Disable paging"
       Crt
       RETURN

       Return

-----------------------------| END OF LIST.FIELDS
|------------------------------

-----------------------------|      stdTCL
|------------------------------

       SUBROUTINE stdTCL( FileName, FL, ItemList, Options )
*--------------------------------------------------------------------------
*  Name        : stdTCL
*  Description : Get TCL Arguments
*  Author      : Brian Leach
*  Date        : 
*  Project     :    
*  Module      : GENERAL
*--------------------------------------------------------------------------
*  Notes
*  -----                            
*--------------------------------------------------------------------------
*  Modification History
*  --------------------
*
*  Date        Who  Version     Description
*  ----        ---  -------     -----------
*--------------------------------------------------------------------------
*  Version Stamp
*  -------------
!V!
*--------------------------------------------------------------------------

$OPTIONS PICK
$OPTIONS PICK
       VOCNAME = "VOC"
       EQU True            To 1
       EQU False           To 0
       EQU TAB             To Char(9)
       EQU LF              To Char(10)
       EQU FF              To Char(12)
       EQU CR              To Char(13)                             
       EQU ESC             To Char(27)
       EQU ZERO            To Char(0)  
       EQU FM              To Char(254)
       EQU VM              To Char(253)
       EQU SVM             To Char(252)
       EQU CRLF            To Char(13):Char(10)
       EQU BIG             To 999
       EQU HUGE            To 99999999
       Prompt ""
       ProgramName = '' 
       GoSub tcl.h
       RETURN
sentence.h: 
       ASentence = ""
       ASentence = @Sentence
       RETURN
args.h: 
       GoSub sentence.h
       ArgList = ""
       Loop
          Get(Arg.) AnArg Else
             AnArg = ""
          End
       Until AnArg = "" Do
          ArgList<-1> = AnArg
       Repeat
       Return
readlist.h: 
       List = ""
       If ListName = "" Then
          ReadList List Else List = ""
       End Else
          ReadList List From ListName Else List = ""
       End
       Return
tcl.h:  
       ItemList = ""
       Options = ""
       GoSub args.h
       LArgNo = 1
       FileName = ArgList<LArgNo>
       If FileName = "" Then
          Crt "File ": ; Input FileName
          If FileName = "" then Return
       End
       Open FileName To FL Else
          Crt "Cannot Open ":FileName
          FileName = ""
          Return
       End
       Loop
          LArgNo = LArgNo + 1
          Item = ArgList<LArgNo>
       Until Item = "" Do
          If Item[1,1] = "/" Or Item[1,1] = "-" Then
             Options<-1> = Item[2,99]
          End Else
             ItemList<-1> = Item
          End
       Repeat
       Begin Case
          Case ItemList = "" And System(11) 
             ListName = ""
             GoSub readlist.h
             ItemList = List
          Case ItemList = ""
             Crt "Item ": ; Input ItemList
          Case ItemList = "*"
             Perform "SELECT ":FileName
             ListName = ""
             GoSub readlist.h
             ItemList = List
       End Case             
       Return
--------------------------------| END OF stdTCL
|--------------------------------------



 

-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Evan Carroll
Sent: 21 January 2010 12:05 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] UniVerse RetreiVe how do I query a file for all of its
column's values?

This is a repost from a stackoverflow question I asked:
http://stackoverflow.com/questions/2068026/universe-retreive-how-do-i-query-
a-file-for-all-of-its-columns-values


=== START REPOST ===
In UniVerse you can't query a file for all of its columns unless the @
phrase in your file's dictionary is set to all of the tables columns.
If it isn't how do you query a table for all of its column's values?
So I can get the total column listing (column name & display name)
using:

LIST DICT file NAME

This will return a listing of all columns and their display names. How do I
then query the table for all of the columns it has?

LIST file

Will only query it for LIST file @id (@id is the only thing in @).
....
=== END REPOST ===

I'd like to follow up with a request to see if anyone has a copy of a BASIC
program that does this, I imagine it is something every heavy universe must
keep in arms reach.

Thanks a ton,

--
Evan Carroll
System Lord of the Internets
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.730 / Virus Database: 271.1.1/2634 - Release Date: 01/20/10
09:12:00

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to