// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // Description: This procedure is called when you have a string S // which has quotation mark (") in it, and you want to put this // string inside of two quotation marks "....." in order to // pass it into a function, then you need // to put a backslash (\) in front of the quotation mark in S. // // For example, S is // print("foo") // and you want to end up with // "print(\"foo\")" // global proc string portableString( string $str ) { string $res = ""; int $i; for( $i = 1; $i <= size($str); $i++ ) { string $src = `substring $str $i $i`; if( $src == "\"" ) { $res += "\\\""; } else if ( $src == "\\" ) { $res += "\\\\"; } else { $res += $src; } } return ("\"" + $res + "\""); }