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
Creating files with long file names
Creating files with long file names
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.
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.
-
- Posts: 2
- Joined: Tue Nov 08, 2005 3:00 pm
Creating files with long file names
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.