Thanks Penn,
I was able to come up with an (albeit slow and convoluted yet more thorough) solution. I bet the char finding/inserting could be written in Origin C and run faster and have cleaner LT code.
----------------
StringArray saTest;
// Loop over every workbook in project
doc -e W {
// Put page.longname$ into a string
string strPLN$ = page.longname$;
// Is there a % char in string?
if (strPLN.Find("%"))
{
// Loop through string from end to beginning looking for % characters. We can ignore last char.
int nLen = strPLN.GetLength();
for (int ii = nLen - 1; ii > 0; ii--)
{
// Get current char as ASCII
int nCurrChar = strPLN.GetAt(ii);
// ASCII codes for relevant chars- % = 37, A-Z = 65-90, a-z = 97-122
// Is current = %?
if (nCurrChar == 37)
{
// Get next char as ASCII
int nNextChar = strPLN.GetAt(ii + 1);
// Is next char in A-Z or a-z?
if (
( (nNextChar >= 65) && (nNextChar <= 90) )
||
( (nNextChar >= 97) && (nNextChar <= 122) )
)
{
// Insert another % char after found % char
strPLN.Insert(ii + 1, "%");
}
}
}
}
// Create string as link whose display is strPLN$
string strLink$ = "range://[%(page.name$)] %(strPLN$)";
// Add to string array
saTest.Add(strLink$);
}
// Create a basic workbook
newbook;
// Assign string array to column 1
range rngCol1 = col(1);
saTest.CopyTo(rngCol1);