Writing two equal files without creating two files in dct 
Author Message
 Writing two equal files without creating two files in dct

Hi there

I'm currently on a cascading system of tps files.
It's simple i created always two files in dct with the same content but
different dynamic(!) filepaths, so if i write one file i synchonise the
other too...
But this system seems to me a bit complicated. That's why I'm searching for
a new way to do the same without that work for any file i have

Some Ideas?



Sat, 25 Dec 2004 13:34:36 GMT  
 Writing two equal files without creating two files in dct
Is ALIAS what you're looking for? (in DCT)



Quote:
> Hi there

> I'm currently on a cascading system of tps files.
> It's simple i created always two files in dct with the same content but
> different dynamic(!) filepaths, so if i write one file i synchonise the
> other too...
> But this system seems to me a bit complicated. That's why I'm searching
for
> a new way to do the same without that work for any file i have

> Some Ideas?



Sat, 25 Dec 2004 13:34:59 GMT  
 Writing two equal files without creating two files in dct
Alias should only be used for lookups into the same file. You should
not be performing Add, Change or Delete on Alias files. Such actions
will be performed on the parent file and if you are using the Alias
file to perform the RI functions you can get some really strange
results.

We've had to deal with this issue too. It seems the only way to deal
with it in the Clarion Dictionary solution is to define and maintain
two distinct files. Then pull a lot of hair maintaining them
seperately.



Quote:
>Is ALIAS what you're looking for? (in DCT)



>> Hi there

>> I'm currently on a cascading system of tps files.
>> It's simple i created always two files in dct with the same content but
>> different dynamic(!) filepaths, so if i write one file i synchonise the
>> other too...
>> But this system seems to me a bit complicated. That's why I'm searching
>for
>> a new way to do the same without that work for any file i have

>> Some Ideas?

b. rgds.
Richard


Sat, 25 Dec 2004 13:35:00 GMT  
 Writing two equal files without creating two files in dct
It's been a few versions ago since I've had to do this, but have you looked
into the LIKE function?

You would define your file in the dictionary, then in your procedure (or
even globally if you like), define a file structure like so:

NewFile        LIKE(FIL:Record)

Then handle the assignment of NEW:Record=FIL:Record... something like that,
but my memory is taxed on the particulars of doing this with the file
definition<G>. MikeG


Quote:
> Hi there

> I'm currently on a cascading system of tps files.
> It's simple i created always two files in dct with the same content but
> different dynamic(!) filepaths, so if i write one file i synchonise the
> other too...
> But this system seems to me a bit complicated. That's why I'm searching
for
> a new way to do the same without that work for any file i have

> Some Ideas?



Sat, 25 Dec 2004 13:35:25 GMT  
 Writing two equal files without creating two files in dct
Hi Richard,

Quote:
>if you are using the Alias file to perform the RI functions
>you can get some really strange results.

Could you elaborate on this?
While I normally never change Alias-files, I did just that today.
In a process I'm updating (no add/delete) an Alias-file, which
represent the "children" of the Parent-file (from which it is alias't)
Though the parent-file has many relations, the Alias has not
(just some lookups), i.o.w. I have no RI-constraints on/to the Alias.
Am I in trouble now?

--

Best regards,
Maarten
CDD3.1, C5EEb - ABC & C5.5.04EE
Certainly Clarion Developer



Sat, 25 Dec 2004 13:35:35 GMT  
 Writing two equal files without creating two files in dct
Hi Ravage,

Quote:

>I'm currently on a cascading system of tps files.
>It's simple i created always two files in dct with the same content but
>different dynamic(!) filepaths, so if i write one file i synchonise the
>other too...
>But this system seems to me a bit complicated. That's why I'm searching for
>a new way to do the same without that work for any file i have

You could do this with some template code, by creating a duplicate
structure, but you would not see it in any file schematic.  

This kind of option has been suggested by me and others, so that you
can have a duplicate file structure, like ALIAS, but which does not
share the NAME attribute with the parent.  So that you could create a
"duplicte" file in the dct, exactly like you create an ALIAS, but you
could supply a new name attribute for the duplicate.  That way they do
not share anything except the file structure and could be used in the
same procedure without any conflicts.

Best regards,

Arnr Baldvinsson
Icetips Software        
San Antonio, Texas, USA
www.icetips.com

ICQ:  113314380



Sat, 25 Dec 2004 13:35:47 GMT  
 Writing two equal files without creating two files in dct
Two things you need to do. 1. Create an alias for your file. 2. Use a
variable name for your file.

Normally (for various purposes) an alias is used to open two buffer areas
for the same file. But you can open the file and then change the file name
(via the variable name) and open the alias.


Quote:
> Hi there

> I'm currently on a cascading system of tps files.
> It's simple i created always two files in dct with the same content but
> different dynamic(!) filepaths, so if i write one file i synchonise the
> other too...
> But this system seems to me a bit complicated. That's why I'm searching
for
> a new way to do the same without that work for any file i have

> Some Ideas?



Sat, 25 Dec 2004 13:35:49 GMT  
 Writing two equal files without creating two files in dct


Quote:
>Hi Richard,

>>if you are using the Alias file to perform the RI functions
>>you can get some really strange results.
>Could you elaborate on this?
>While I normally never change Alias-files, I did just that today.
>In a process I'm updating (no add/delete) an Alias-file, which
>represent the "children" of the Parent-file (from which it is alias't)
>Though the parent-file has many relations, the Alias has not
>(just some lookups), i.o.w. I have no RI-constraints on/to the Alias.
>Am I in trouble now?

All I can say is... possibly. The Alias is not really a file and in
some cases the RI can really go south on you. I only say that from
experience, not from any real understanding of the mechanics involved.

Theoretically, the Alias will inherit all of the RI constraints of the
parent. Theoretically. I think it's easy to disturb this relationship
in unintentional code.

Best Regards
Richard

The AppInit Template Set

www.sylkie.com

"Strip mine asteroids not rain forests!"



Sat, 25 Dec 2004 13:35:52 GMT  
 Writing two equal files without creating two files in dct
On Thu, 4 Jul 2002 12:41:07 -0700, "Bob Campbell"

Quote:

>Two things you need to do. 1. Create an alias for your file. 2. Use a
>variable name for your file.

>Normally (for various purposes) an alias is used to open two buffer areas
>for the same file. But you can open the file and then change the file name
>(via the variable name) and open the alias.

This is where I have run into the hammer. Now that you have the alias
open, how do you reference the original file? Can't be done. An Alias
is just a view of a file that IT EXPECTS to be the same as the parent
file. Alias is not a method to access the same file structure in two
seperate instances. From what I understand, that would require
threading the files and some very careful file control.

Best Regards
Richard

The AppInit Template Set

www.sylkie.com

"Strip mine asteroids not rain forests!"



Sat, 25 Dec 2004 13:35:53 GMT  
 Writing two equal files without creating two files in dct
Quote:

> Am I in trouble now?

No!
RI is NOT inherited.
Behaviour depends on the used driver:
SQL specifically allows you to refer multiple times to the same DB with
another name..
ON SQL-SYSTEMS you might still encounter RI-rules that are stored in
the SQL Backend. These might not be visible to your .app & .dct. Think
of triggers.
ON ISAM-SYSTEMS well who's in charge: some databuffers and the VIEW
manager...


Sat, 25 Dec 2004 13:36:14 GMT  
 Writing two equal files without creating two files in dct
Maarten,

Quote:
> In a process I'm updating (no add/delete) an Alias-file, which
> represent the "children" of the Parent-file (from which it is alias't)
> Though the parent-file has many relations, the Alias has not
> (just some lookups), i.o.w. I have no RI-constraints on/to the Alias.
> Am I in trouble now?

Yes ! I would tend to disagree with the generalities as enounced by Richard,
but in the case you explain, yes, you are in trouble. Why ? think one second
about it: ABC automatically do a commit/rollback in regards to the
relationships in the dictionary, but with an alias, you would need to have
TWICE the SAME file in Logout, with DIFFERENT Buffers. Just impossible !
(the way its done in Clarion, in SQL, the relation you describe is perfectly
valid and safe...)

Bernard
Tulsa, Ok.



Sat, 25 Dec 2004 13:36:24 GMT  
 Writing two equal files without creating two files in dct
Richard,

Quote:
> Alias should only be used for lookups into the same file.

Sorry, I disagree. If it's just for lookup on the same file, you don't even
need an alias. Say that you are in  a form, on MYFile record, you just need
to do a savedPosition = Access:MyFile.SaveFile() before looking up in
Myfile, then a Access.myFile.restoreFile(SavedPosition) after the lookup,
and you're safe.

Quote:
>You should
> not be performing Add, Change or Delete on Alias files. Such actions
> will be performed on the parent file.

Yes, but why would that be a problem ? it's a different buffer, can contain
different values, works just fine.

As explained in answering Maarten, yes, there is problems with RI as done by
Clarion and aliases. But the work around is easy enough: Don't declare
aliases relations in the DCT, and do you RI stuff yourself in the File
global object embeds.

Bernard
Tulsa, Ok.



Sat, 25 Dec 2004 13:36:28 GMT  
 Writing two equal files without creating two files in dct
Ravage,

Quote:
> I'm currently on a cascading system of tps files.
> It's simple i created always two files in dct with the same content but
> different dynamic(!) filepaths, so if i write one file i synchonise the
> other too...
> But this system seems to me a bit complicated. That's why I'm searching
for
> a new way to do the same without that work for any file i have

it seems to me that the answer is simple enough, and I am surprised to not
have seen it more than once ( One was close, but not exact)

Declare a second file into your dct, as you do now. Create ONE field, give
it a  label ( in my example, myField), select LIKE as data type, then type
the label for the record of the parent file. I tried that on the state file
in the Clarion invoice example. Below is the generated file declaration.
This way you can change the "parent" file as much as you want, you have
nothing to do to have the "child" file  matching exactly.

state2
FILE,DRIVER('TOPSPEED'),PRE(STA1),CREATE,BINDABLE,THREAD
Record                   RECORD,PRE()
myRecord                    LIKE(Sta:record)
                         END
                     END

There is an inconvenient, though : the templates will not "see" the fields
your record is made from, and you will have to manually format your list
box, etc......but I believe what I describe above is the "clean" way to do
what you want. The syntax to access a field in the above example would be
STA1:Myrecord.name.

Bernard
Tulsa, Ok.



Sat, 25 Dec 2004 13:36:32 GMT  
 Writing two equal files without creating two files in dct
On Fri, 5 Jul 2002 08:45:50 -0500, "Bernard Grosperrin"

Quote:

>Yes, but why would that be a problem ? it's a different buffer, can contain
>different values, works just fine.

As I understand his need, it is to update (use RI) on two physically
different files of the same structure. That can be a problem using an
alias, especially if both files need to be open simultaneously.

Best Regards
Richard

The AppInit Template Set

www.sylkie.com

"Strip mine asteroids not rain forests!"



Sat, 25 Dec 2004 13:36:51 GMT  
 Writing two equal files without creating two files in dct
On Fri, 5 Jul 2002 09:16:34 -0500, "Bernard Grosperrin"

Quote:

>it seems to me that the answer is simple enough, and I am surprised to not
>have seen it more than once ( One was close, but not exact)

>Declare a second file into your dct, as you do now. Create ONE field, give
>it a  label ( in my example, myField), select LIKE as data type, then type
>the label for the record of the parent file. I tried that on the state file
>in the Clarion invoice example. Below is the generated file declaration.
>This way you can change the "parent" file as much as you want, you have
>nothing to do to have the "child" file  matching exactly.

Now THAT's clever. <VBG> I like it!

Best Regards
Richard

The AppInit Template Set

www.sylkie.com

"Strip mine asteroids not rain forests!"



Sat, 25 Dec 2004 13:36:52 GMT  
 
 [ 38 post ]  Go to page: [1] [2] [3]

 Relevant Pages 

1. Writing two equal files at once

2. read two sets of data from two spread sheet files to two arrays problem

3. how to compare two columns in two files?

4. Two files, two linking keys

5. One and One doesn't equal two It equals 1 - The Who

6. One and One doesn't equal two It equals 1 - The Who

7. Create a DDF File from Pervasive SQL since a clarion dictionnary ( DCT File)

8. hwo write to two files?

9. two or more programs writing a single file

10. Merge selected columns from two different files into another file

11. merging 2 columns from two files in one file

12. how to read one file, print to two files

 

 
Powered by phpBB® Forum Software