Virtual System Table FieldNames

rajeev.babu

Member
Dear All,

Can anybody help me to extract (4GL Code) the VST field names from a table. I want to display the fieldnames from a table.

Suppose _ActIOFile contains the fields _IOFile-BufReads, _IOFile-BufWrites etc...

Is is possible to get the fieldnames from a table using a progress 4GL code.
 
Here is part of code.

Code:
find first system._File where system._File._File-Name = TableName NO-LOCK NO-ERROR.
if not available system._File then RETURN.

create TableInfo.
assign
  TableInfo.table_name  = system._File._File-Name
  TableInfo.table_label = system._File._File-Label
  TableInfo.sys         = system._File._Frozen
  TableInfo.dump_name   = system._File._Dump-name
  TableInfo.table_desc  = system._File._Desc
  TableInfo.valexp      = system._File._Valexp
  TableInfo.valmsg      = system._File._Valmsg.
if TableInfo.sys then 
do:
  TableInfo.valmsg = "".
  TableInfo.valexp = "".
end.

for each system._File-Trig of system._File NO-LOCK:
  create TTriggers.
  assign
    TTriggers.event     = system._File-Trig._Event
    TTriggers.proc_name = system._File-Trig._Proc-Name
    TTriggers.override  = system._File-Trig._Override.
  if system._File-trig._Trig-Crc <> 0 AND system._File-trig._Trig-Crc <> ? THEN 
    TTriggers.checkcrc = yes.
  else
    TTriggers.checkcrc = no.
  run LoadSrc (TTriggers.proc_name, OUTPUT TTriggers.ttext).
end.

FOR EACH system._Field OF system._File NO-LOCK:
  create TFields.
  assign
    TFields.pos          = system._Field._Order
    TFields.field_name   = system._Field._Field-name             
    TFields.field_label  = system._Field._Label
    TFields.dt           = system._Field._Data-Type
    TFields.field_format = system._Field._Format
    TFields.initial      = system._Field._Initial.
  TFields.flags =
      (IF system._Field._Fld-case THEN "c" ELSE "") +
      (IF CAN-FIND(FIRST system._Index-field OF system._Field) THEN "i" ELSE "") +
      (IF system._Field._Mandatory THEN "m" ELSE "") +
      (IF CAN-FIND(FIRST system._View-ref WHERE
                   system._View-ref._Ref-Table = system._File._File-name AND
                   system._View-ref._Base-col  = system._Field._Field-name)                    
      THEN "v" ELSE "").
  if TFields.dt = "decimal" then 
    TFields.dt = TFields.dt + "(" + string(system._Field._Decimals) + ")".
  if TableInfo.sys then TFields.field_format = "".
  run CalcFieldWidth (TFields.dt, TFields.field_format, OUTPUT TFields.field_width).
end.                                                                   

for each system._Index of system._File NO-LOCK:
  create TIndexes.

  find first system._Index-field where
      system._Index-field._Index-recid = RECID(system._Index) NO-LOCK NO-ERROR.
  TIndexes.flags = 
      (IF system._File._Prime-index = RECID(system._Index) THEN "p" ELSE "") +
      (IF system._Index._Unique                            THEN "u" ELSE "") +
      (IF system._Index._Wordidx = 1                       THEN "w" ELSE "") +
      (IF AVAILABLE system._Index-field 
          AND system._Index-field._Abbreviate              THEN "a" ELSE "") +
      (IF NOT system._Index._Active                        THEN "i" ELSE "").

  assign
    TIndexes.pos = system._Index._idx-num
    TIndexes.name = system._Index._Index-Name
    TIndexes.idesc = system._Index._Desc
    TIndexes.num_fields = system._Index._Num-comp.

  for each system._Index-field where
    system._Index-field._Index-recid = RECID(system._Index) NO-LOCK,
    first system._Field where
          system._Index-field._Field-recid = RECID(system._Field) NO-LOCK:

    TIndexes.fields_name = TIndexes.fields_name + 
      (IF system._Index-field._Ascending then "+ " else "- ") +
      _Field._Field-Name + " ".
  end.
  TIndexes.fields_name = TRIM(TIndexes.fields_name).
end.
 

rajeev.babu

Member
If u dont mind...please let me know how to compile it

* I have tried connecting the sports2000 DB and compiled the code in procedure editor.

Unknown database name system. (855)
Unknown or ambiguous table _File. (725)
** Could not understand line 1. (196)

am a starter...please bear me
 

TomBascom

Curmudgeon
Code:
for each _file no-lock where _file._file-name = "_ActIOFile":
  for each _field no-lock where _field._file-recid = recid( _file ):
    display _file._file-name _field._field-name.
  end.
end.
 
Top