Creating files with long file names

In this category you can exchange your programming questions and solutions.
Post Reply
NewCastleUSA
Posts: 2
Joined: Tue Nov 08, 2005 3:00 pm

Creating files with long file names

Post: # 488Post NewCastleUSA
Fri Aug 14, 2009 5:47 pm

Hello,
I`m a Cobol programmer using an old dos level compiler. ?I have a situation where I need to create a file with a long file name. ? I want to write a basic program to read the short named file (created by the cobol program) and copy it to a long named file. ?

What I was thinking of doing is have my cobol program create a big data file called CLAIMS.TXT ?(may be 1mg) and a ?CLAIMS.cfg file with 2 records. ?The first record would be ?the input filename "CLAIMS.TXT" ?and the second record would be the output file name UPLOADFOLDERCLAIMS_YYMMDD_LOCATION.TXT.

The Basic program would read the claims.cfg to get the shortinput and longoutput file names , then do a copy , or a read and write until EOF.

This would run on an XP workstation on a microsoft server.

Sounds simple, ? can fnxBasic write long file names ?

Thanks

fred
Posts: 54
Joined: Thu Apr 23, 2009 10:08 am

Creating files with long file names

Post: # 489Post fred
Fri Aug 14, 2009 7:40 pm

I think it can write long filenames since it is a Windows complier.
To get you started i wrote a little code, no error checking on config parameters and no main window but it works, try this:


` use the Windows CopyFile function
Declare CopyFile as "CopyFileA" of "kernel32.dll"
 lpExistingFileName as string byaddress
 lpNewFileName  as string byaddress
 bFailIfExists as integer
 result as integer
End Declare

dim f as FileStream

` setup the copy parameters

` open config file
f.Open("claims.cfg")
` read filenames
CopyFile.lpExistingFileName=f.ReadLine
CopyFile.lpNewFileName=f.ReadLine
` close config file
f.Close
CopyFile.bFailIfExists=1 ` 1=do not overwrite existing file, 0=overwrite existing file

` copy the file
CopyFile

` check if it did go ok or not
if CopyFile.result=0 then
 Showmessage "copy failed"
else
 Showmessage "file copied"
end if


Information about the CopyFile function can be found here: http://msdn.microsoft.com/en-us/library/aa363851(VS.85).aspx
I hope this helps you.

NewCastleUSA
Posts: 2
Joined: Tue Nov 08, 2005 3:00 pm

Creating files with long file names

Post: # 490Post NewCastleUSA
Sat Aug 15, 2009 4:29 pm

Thanks Fred,    it`s been 25 years since I`ve looked at a basic program.    You saved me a couple of weeks of head scratching.

Post Reply