Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to extract filename, indexname, key from .dbc
Message
From
21/05/1999 13:26:30
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00221452
Message ID:
00221470
Views:
14
>I have an index routine that uses a KEYS.DBF file. This file contains the filename, index name, key expression and Ascending/Descending indicator.
>
>Is there a way to populate this file by reading the .dbc directly?
>
>Ideally, I'd like to run "LoadKeys()" at app startup as well as intermittently during development.
>
>TIA
Hi Larry,
As George said with native FP2.x commands it's not hard to accomplish. Here are partial codes that I used for save_dictionary and create_dbfs in FP2.x (main purpose was to supply info to repair prg) (Ignore var naming convention).
* Part saving tags to a table - dbftags
select (dbname)
for tg=1 to tagcount()
  insert into dbftags values ;
	(dbname,tag(tg,dbname),;
	key(tg,dbname), ;
        IIF(EMPTY(ALLTRIM(sys(2021,tg,dbname))),;
        "",ALLTRIM(sys(2021,tg,dbname))),;
	descending(tg,dbname),unique(tg,dbname)) 
endfor
* Part using dbftags to recreate indexes
  FUNCTION db_create
  PARAMETERS mdbname
  SELECT field_name,field_type,field_len,field_dec ;
    from strulist ;
    where filename==mdbname ;
    into array fstruc
  SELECT key,tag,;
    iif(empty(TRIM(dbftags.filter)),space(200),"for "+dbftags.filter), ;
    iif(dbftags.desc,"descending","          "), ;
    iif(dbftags.unique,"unique","      ") ;
    from dbftags ;
    where filename==mdbname ;
    into array taglist
  ? "Creating "+mdbname
  CREATE table (targetdir+trim(mdbname)) from array fstruc
  IF type("taglist")="U"
    USE
    RETURN
  ENDIF
  FOR KXCP=1 TO ALEN(taglist,1)
    taglist[KXCP,3]=TRIM(taglist[KXCP,3])
    taglist[KXCP,4]=TRIM(taglist[KXCP,4])
    taglist[KXCP,5]=TRIM(taglist[KXCP,5])
  ENDFOR
  FOR tgcnt=1 to alen(taglist,1)
    INDEX on &taglist[tgcnt,1] ;
      tag (trim(taglist[tgcnt,2])) ;
      &taglist[tgcnt,3] ;
      &taglist[tgcnt,4] ;
      &taglist[tgcnt,5]
  ENDFOR
  USE
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
Previous
Reply
Map
View

Click here to load this message in the networking platform