PathToStr(sPath) "^" What is the Caret doing?

I have inherited some Citect code and there is a problem with it...

There is some reports on a report server that is triggered by cicode and there is "a problem" that is causing some kind of crash in the report server that is very elusive to discover. I'm turning over the smallest pebbles now, I'm not the first engineer to be asked to fix this one...

I am not so familiar with Citect and I am trying to understand the syntax, as in some locations a caret is used in strings and not in others...

PathToStr("^"\\PCName\Data\_Mill\DailyReport Yesterday.txt^"");

is used in the code and

PathToStr("[data]:test.txt");

is used in the help file...

What are the carets doing???

  • Hi ,

    This is an extact from the help:

    Using the Caret Escape Sequence Character
    The caret character ( ^ ) signifies a special instruction in Cicode, called an escape sequence, primarily used in the formatting of text strings. Escape sequences include formatting instructions such as new line, form feed, carriage return, backspace, horizontal and vertical tab-spaces, single and double quote characters, the caret character, and hexadecimal numbers.

    Strings are commonly represented in Cicode between double quote characters ( " ) known as delimiters. If you want the string to contain a double quote character itself as part of the string, you need to precede the double quote character with the caret character ( ^" ) so that Cicode doesn't interpret the double quote in the string as the delimiter indicating the end of the string. The caret character is interpreted as a special instruction, and together with the characters immediately following it, are treated as an escape sequence instruction. See the section titled Formatting Text Strings for the list of escape sequences used in Cicode.

    In the following Cicode example, both of these message functions will display the following message.

    Message("Info", "P29 has a ^"thermal overload^".", 0);
    sCurrentAlmText = "Thermal Overload";
    Message("Info", "P29 has a ^""+sCurrentAlmText+"^".", 0);
  • The PathToStr() is used to substitute [Data], [Run],[User] with the parameter setting from the Citect.ini or Profile. The statement :

    sPath = PathToStr("^"\\PCName\Data\_Mill\DailyReport Yesterday.txt^"");

    Can be replaced by:

    sPath = "\\PCName\Data\_Mill\DailyReport Yesterday.txt";

    So no need for carets in this case. You can also use:

    sPath = PathToStr("[DATA]:\_Mill\DailyReport Yesterday.txt");

    In this case you need to define the [CtEdit]Data parameter in the Citect.ini or Profile with value : \\PCName\Data
  • Thanks, as a result of writing this article and actually looking up the name "caret" of this ^ ysmbol i was then able to search the help file for 'caret' and come across this too!
  • Thanks, This really helps, the project has been transferred through multiple versions of citect and there's some things that are inconsistently used, good to know pathtostr is not doing anything too exciting in the background...
  • Worth noting also, that those caret-quotes shouldn't be there either, as your path variable shouldn't (usually) include quotes in it. An exception might be if it's being written into a csv where you do want values surrounded by quotes:
    "this is, a string, value", "I don't want my embedded, commas, to separate my field values"
    I.e. It should be:

    PathToStr("\\PCName\Data\_Mill\DailyReport Yesterday.txt");