Hi -
We've been using WriteExtFile and AppendExtFile to store data in a CSV text file in a data folder in the same location as our Authorware executable file.
WriteExtFile("data\\"^"Variable_Names.txt", Survey_Variable_Names)
AppendExtFile("data\\Survey_DATA.txt", Survey_Data)
As a rule, we've always put our executable files on the hard drive of the computer (C:) because of some problems we have had with an inconsistent network drive in the past. Having the files on the C: drive eliminated any network issues. Our accumulating data would always be stored to the C: drive as well.
We now need to store a backup copy of the data on a server, in addition to the C: drive.
My question is: Is there is a maximum file size that can be 'read in' and then 'written' using Authorware?
My thought was to use ReadExtFile to read in the contents of the "Survey_DATA.txt" file and then use WriteExtFile to write out that same data to a drive on the network, appending the date and time to the end of the file name to serve as a backup file.
I've used this logic, which is working to write to the network drive "P":
WriteExtFile("P:\\Survey_Project\\BackupData\\DATA_BACKUP_"^Backup_Da te^"_"^Backup_Time^".txt", Survey_Backup_Data)
Naturally, the size of the original data text file on the C: drive is going to continue to grow since we are using 'AppendExtFile' to add the data from each survey record to the data file (CSV, each record on it's own line). So the size of the file that we are going to read back in (using ReadExtFile) will also continue to grow.
Is there a limit to what we can read in, and then write back out?
Thanks!
Scott
Limit on the text file? I seem to remember that XP had a 64k limit on txt
files, but that was years ago, and I would have tought it had been
inclreased by now. Definitely Vista and Windows 7 don't have that same
limit.
As for Authorware variables, theres the old 32k limit stuill hanging
around. You can store up to 512 k of data in an Authorware 7 variable, but
ReadExtFile only supports 32k.
There's various ways that you can read in the text in chunks, but I think,
ultimately, it is easier to use a database if you want to store and
retrieve a lot of text.
Steve
Thanks Steve, especially for the fast reply!
Is there any limit when using AppendExtFile?
I just put data from one record in a blank text file and it was 13KB, then I copied the same text 10 times and it went to 129KB, quickly exceeding the ReadExtFile 32K limit you mention. So ReadExtFile won't be a solution...thanks for saving time with that!
I wish there were a way to copy and move a file. I'll check with a coworker that may have a way to build a small program outside of Authorware that will copy a file and see if that may be a solution for the backup portion of this project.
Thanks again!
Scott
Hi Steve -
I see a function for CopyIcons and CopyList, but I don't see a function for CopyFile. I'm using Authorware 7.02.
Should I be looking somewhere else?
If the possibility of copying a larger file (thank 32K) exists, this may be the solution I need.
Thanks!
Scott
My apologies, it's been a few years ...
CopyFile is a function that you can load from the WinAPI.u32
Once loaded, you use it like this
Success:= CopyFile(FileLocation^"Sourcefile.txt",
Destination^"DestinationFilename.txt")
just remember you need to include WinAPI.u32 with your packaged file(s).
Steve
Hi Steve -
Great! I was able to load the function and copy a file locally.
Do you know if there is a limit to the size of the file that can be copied?
I also checked with a coworker who said that I could use a .bat file to copy a file. If we ever went that route (which I don't think we need to do now since if CopyFile works with a large data file), is there a way to have an Authorware button that could open/run a .bat file?
Thanks -
Scott
I don't believe there is a practical limit. If you have the fun(!) od
supporting XP, you might encounter a 2Gb limit, but if your file is ever
that big, you have other issues ...
JumpOutReturn(FileLoction, "FileName.bat")
should run the Bat file. many system security settings will prevent you
running a Bat file.
Steve
Hi Steve -
Once again, THANKS a bunch for your detailed help!
I was able to run the .bat file from an Authorware button, and I was also able to use the CopyFile function.
For anyone that may be interested, I also set up the backup copy to have the computer date and time appended to the file name. Code below:
Backup_YYYY:= Year
Backup_MM := Month
if Month <10 then
Backup_MM := String("0"^Month)
end if
Backup_DD:= Day
if Day <10 then
Backup_DD := String("0"^Day)
end if
Backup_Hour:= Hour
if Hour <10 then
Backup_Hour := String("0"^Hour)
end if
Backup_Minute:= Minute
if Minute <10 then
Backup_Minute := String("0"^Minute)
end if
Backup_Sec := Sec
if Sec <10 then
Backup_Sec := String("0"^Sec)
end if
Backup_Time := Backup_Hour^Backup_Minute^Backup_Sec
Backup_Date := Backup_YYYY^Backup_MM^Backup_DD
-- This uses Computer Date
Temp_BackupPath := "p:\\test\\DATA_BACKUP_"^Backup_Date^"_"^Backup_Time^".txt"
Success:= CopyFile(FileLocation^"\\data\\DATA.txt", Temp_BackupPath)
Thanks -
Scott
Hi Steve -
I've been using the CopyFile function successfully to copy a specific file to a backup location. Thanks again for your help with that.
Is there an easy way that I can copy an entire folder to a backup location? I won't know how many separate text records will be in the folder at any particular time since it will vary.
Thanks!
Scott
I don't have Authorware handy - is there a CopyFolder function? I don;t
think so.
I'm pretty sure BudAPI has a CopyFolder function
http://www.mods.com.au/budapi/
If, like me, you prefer native only functions, you can use Catalog to get a
list of files in a folder, then iterate through the list of returned files
and copy them in turn. Since you are only taking about text files, this
should be pretty quick.
Steve
North America
Europe, Middle East and Africa
Asia Pacific