GSAK (Geocaching Swiss Army Knife)
Contents - Index

Quote (function)

Quote(sData) : string

Use to output a string with double quotes

As double quotes are used to denote a string literal, you can't explicitly have them inside a string literal. This function will help overcome situations where you need to output double quotes via a GSAK variable. The primary use is for the creation of variables to be used in the PutFile, AppendFile, and TextOut functions. The Quote function and $_Quote system variable both output chr(34) [the ascii character value for the double quote].  This is all done for you under the covers, so you shouldn't have to worry about it. For example the TextOut command allows output of CSV files, however there are some situations where some of the numeric fields need to be output without quotes where and the string fields must be output with quotes. Let us say you wanted the Longitude and Latitude output without surrounding them in double quotes you would use the following code:

Goto Position=Top
while not($_eol)
  $_txt1 = $d_latitude
  $_txt2 = $d_longitude
  $_txt3 = Quote($d_name)
  $_txt4 = Quote(left($d_container,1))
  $result = TextOut("c:\temp\data.csv","none","comma")
  # Just in case file permission error or something test for error
  IF Left($result,7) = "*Error*"
    Pause Msg=$result
  Goto position=next

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. 

Related: Putfile() AppendFile() TextOut()

Alpha List         Category List

Copyright 2004-2016 CWE Computer Services  
Privacy Policy Contact