|GSAK (Geocaching Swiss Army Knife)|
This function is to facilitate the generation of CSV and TAB delimited text files, and is the most versatile way to do so. However, for simple CSV and TAB delimited text file generation please see File=>Export=>CSV
The usage of this function is a tad quirky, but after a description and example I hope macro users will see the power of this function.
sFile = The fully qualified path and file name of the csv/text file being created
sEnclose = Specify if each field will be enclosed with double quotes or not. This value can be "quotes" or "none". Use "quotes" to enclose every field in double quotes. This is usually required for most programs that want CSV files. Use "none" to have each field exported as is without any surrounding quotes.
sDelimiter = Field delimiter. This value can be "comma" or "tab". Each exported field will have either a comma or tab after it
In order to actually generate output through this function you must first assign values to the special system variables $_txt1 through to $_txt99. It doesn't matter what order you allocate the values but the order that goes out to the file will always be $_txt1 first, $_txt2 second, etc. After using this command all the special $_txt variables are deleted from the macro variable stack so you must make sure you set every variable again if you are looping through the file to generate the text file. This is because if you firstly created a file of 5 fields, you wouldn't want the next file you create of only 2 fields having left over data from the first generation (in effect you would get 5 fields in the second file even though you only allocated values to $_txt1 and $_txt2 for the second file)
If the file does not exist it will be created. If the file does exist, the data will be appended to the file
For example, we want to create a CSV file that has Latitude, Longitude, Cache name, and only the first character of the container size
As this function can be a bit CPU and disk intensive you might want to add in the SHOWSTATUS command in the loop to show feedback on where the macro is up to for large databases.
however there are some situations where some of the numeric fields need to be output without quotes where as the string fields must be output with quotes. Using the same example as before, let us say you wanted the Longitude and Latitude output without surrounding them in double quotes you would use the following code:
The use of none in the second parameter stops all fields from having double quotes. So for the string fields we do want surrounded by double quotes we use the Quote function.
Alpha List Category List
Copyright 2004-2015 CWE Computer Services |