` Printed Icetips Article

Icetips Article



Templates: Comparing two file structures
1998-10-23 -- Mike Hanson
 
Newsgroups: topspeed.products.c4

This should do the trick:

#!-----
#TEMPLATE(MyTpl,'My Templates'),FAMILY('ABC')
#!-----
#EXTENSION(EnsureDupFiles,'Ensure Dup Files'),APPLICATION,MULTI
#PROMPT('File 1:',FILE),%File1,REQ
#PROMPT('File 2:',FILE),%File2,REQ
#VALIDATE(%File1<>%File2,'These cannot be the same!')
#!-----
#ATSTART
  #DECLARE(%MyKeyStruct),MULTI
  #DECLARE(%MyFieldStruct),MULTI
  #PURGE(%MyKeyStruct)
  #PURGE(%MyFieldStruct)
  #FIX(%File,%File1)
  #FOR(%Key)
    #ADD(%MyKeyStruct,%KeyStruct)
  #ENDFOR
  #FOR(%Field)
    #ADD(%MyFieldStruct,%FieldStruct)
  #ENDFOR
  #FIX(%File,%File2)
  #IF(ITEMS(%Key)<>ITEMS(%MyKeyStruct))
    #INSERT(%NoMatch)
  #ENDIF
  #IF(ITEMS(%Field)<>ITEMS(%MyFieldStruct))
    #INSERT(%NoMatch)
  #ENDIF
  #FOR(%Key)
    #SELECT(%MyKeyStruct,INSTANCE(%Key))
    #IF(%KeyStruct<>%MyKeyStruct)
      #INSERT(%NoMatch)
    #ENDIF
  #ENDFOR
  #FOR(%Field)
    #SELECT(%MyFieldStruct,INSTANCE(%Field))
    #IF(%FieldStruct<>%MyFieldStruct)
      #INSERT(%NoMatch)
    #ENDIF
  #ENDFOR
#ENDAT
#!-----
#GROUP(%NoMatch)
#ERROR(%File1 &' and '& %File2 &' do not match!')
#!-----

Catch you later!

-=> Mike Hanson <=-
www.BoxsoftDevelopment.com


Chris Moore  wrote:

>Is it possible for a Template (global) to compare the structure (field
>labels, types & sizes) between 2 files? I would like to have a Global
>template that could do this everytime I compiled my DATA.DLL for my
>system. (I must keep 2 files identical - except for the file name).
>
>Thanks
>
>Chris



Printed May 4, 2024, 9:40 am
This article has been viewed/printed 35112 times.
Google search has resulted in 31 hits on this article since January 25, 2004.