Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Files 2

Status
Not open for further replies.

northman

Programmer
Dec 12, 2002
15
CA
Iwould like to archive my files at year end. For example I would rename FileA.TPS as F2005.TPA at the start of 2006, and rename FileA.TPS as F2006.TPA at the end of 2006, and so on. That part is easy. Now I would like to be able to bring back a file on special occasions (e.g. F2005.TPS ==> FileA.TPS). This is where I hit the wall.

Is there a way in Clarion (CW2.0) to do this?
Thanks in advance for any help
 
Not sure of CW 2.0, but isn't there a COPY() or RENAME() function to do that. The only issue is that you need to do the copying when the file is NOT open by any User.

Also, You can set a Global Variable as the file name in the Dictionary i.e. Set Full Path Name of the file to !GLO:FileName, define a Global Data Variable called GLO:FileName as STRING(12) and assign the value to the variable before the file is Open.

The latest version of Clarion i.e. v6.x allows you to just do FILELABEL{PROP:Name} = 'F2005.tps' i.e. no need of global variable.

HTH-Regards
 
Thanks Shankar: I may not have been clear about my problem, I can use Rename()/Copy() when I have defined that file in the dictionary. I am using Rename to create the back-up files (F2005.TPS, etc.). Where I am haveing trouble is Renaming/Copying a file that is not in the dictionary (such as F2005.TPS) to restore the original file.

Finance.TPS ==> F2005.TPS Easy to do!

F2005.TPS ==> Finance.TPS This is the problem

Serge
 
Serge,

From the Help in Clarion v6.2

[small][tt]
RENAME(file,new file)

RENAME Renames a FILE.

file The label of a FILE to rename, or a string constant or variable containing a file specification.
new file A string constant or variable containing a file specification. If the file specification does not contain a drive and path, the current drive and directory are assumed. If only the path is specified, the filename and extension of the original file are used for the new file. Files cannot be renamed to a new drive.

The RENAME statement changes the file specification to the specification for the new file in the directory. The file to rename must be closed, or the "File Already Open" error is posted. If the file specification of the new file is identical to the original file, the RENAME statement is ignored. If any error is posted, the file is not renamed.
Since some file drivers use multiple physical disk files for one logical FILE structure, the default filename and extension assumptions are dependent on the file driver.

Errors Posted: 02 File Not Found
03 Path Not Found
05 Access Denied
52 File Already Open

Example:

RENAME(Text,'text.bak') !Make it the backup

RENAME(Master,'\newdir') !Move it to another directory
RENAME('C:\AUTOEXEC.BAT','C:\AUTOEXEC.SAV') !Make it the backup
[/tt]
[/small]

If the RENAME() & COPY() in CW2 only works with File Labels, then define a dummy DOS driver file like :

DosFileName STRING(12),STATIC

DosFile FILE,DRIVER('DOS'),PRE(DOS),NAME(DosFileName)
Record RECORD
END
END

and ...


DosFileName = 'F2005.tps'

RENAME(DosFile, 'FINANCE.tps')

The same thing can work for your TOPSPEED file, i.e.

TPSFileName STRING(12),STATIC

TPSFile FILE,DRIVER('TOPSPEED'),PRE(TPS),NAME(TPSFileName)
Record RECORD
<your columns here>
END
END

So, if you want to use F2005.tps, set TPSFileName = 'F2005.tps' before Opening the file. Similarily it will work for any Topspeed file providing they have the same file structure.

HTH
 
Hi Shankar: Sorry for the delay...I have been sick with a cold. I tried:


DosFileName STRING(12),STATIC

DosFile FILE,DRIVER('DOS'),PRE(DOS),NAME(DosFileName)
Record RECORD
END
END

I assume that this is to be part of the Procedure that uses it. When I try to compile it, I get:

Link Error: Unresolved External DOS in (My procedure's name)

I wondered about declaring the DOS file in my dictionary, but ran into a "File Not Found" error.

Thanks again for you help and patience.

Serge
 
Serge,

If you are defining the file in a DATA embed as shown below :

[tt][small]
DosFileName STRING(12),STATIC

DosFile FILE,DRIVER('DOS'),PRE(DOS),NAME(DosFileName)
Record RECORD
Data STRING(256)
END
END
[/small][/tt]

you need to click on Project in the application and add the DOS driver under Database Drivers before compiling. That's the reason of the "Unresolved External DOS" error.

And, if you are planning to define the file in the Dictionary, you need to put [red]!DosFileName[/red] (note the exclamation before the variable name) in the Full Pathname of the file and define DosFileName under Global Data.

Regards

 
Hi Shankar: Works like a charm. Thanks so much. Tell me, where have you picked up all your knowledge for Clarion? I live too far from Toronto to meet with other programmers, so I am on my own.

It is gratifying and so supportive to have people like you willing to answer questions.

God bless

Serge
 
Serge,

My pleasure. Glad I could help. The best part of answering other's questions is that you tend to learn something in the process.

I am from India and live in Dubai, United Arab Emirates i.e. in the Middle East and am possibly the only Clarion programmer in the country and maybe the region and I have been using Clarion since 1989. If you want to keep in touch with other Clarion programmers in Canada (quite a few of them) and other parts of the world go to the comp.lang.clarion newsgroup.

Since you are using CW2.0 (I think the last version patch was v2.003) was the last version, check for the latest news on the product. The current shipping version is v6.3 with v7 and .NET on the way. You can also go to and log in as Guest to check all the other Clarion newsgroups. The official Clarion Blog/Forums is at
Regards
 
Serge,

No Problem.

You can contact me at

j s h a n k a r AT e m i r a t e s DOT n e t DOT a e

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top