Is it possible to replace symbol characters in dxl?

I am exporting objects from DOORS into a tex file. Things work fine, however, any special symbols like arrows, #, or degree symbols do not export. Since I am making this for LaTeX, I need the symbols to translate into syntax like \rightarrow for a symbol like -> or \greaterthan for >. Is this possible with regular expressions?
mirlo - Thu Mar 04 16:58:19 EST 2010

Re: Is it possible to replace symbol characters in dxl?
Mathias Mamsch - Fri Mar 05 02:02:10 EST 2010

Checkout the search function of the forum. I remember reading at least one code example for a replace. Regards, Mathias

Re: Is it possible to replace symbol characters in dxl?
mirlo - Fri Mar 05 14:56:40 EST 2010

I couldn't find the posting referred. I somewhat got the results I wanted however, I'm basically building a new string buffer, looping through the Object Text and applying a pattern match. On each successive loop, I shorten the string with a range of i:string length. Perhaps there is a better way, I'll have to try it out later when i get to the office. Basically, all I am trying to do is get the following effect, given the following string:

"the temperature is 15ยบ"

I want to replace the degrees symbol with something like:

\degrees

so in my resulting text file I would have:

the temperature is 15\degrees

Re: Is it possible to replace symbol characters in dxl?
llandale - Sun Mar 07 14:33:46 EST 2010

Regular expressions and matching strings is very ineffecient. Here's my replace character function:
Buffer gl_fReplace_ToStngBuff = create(1024) // allows quick Combine

//***********************
void fReplaceChar(Buffer &InBuffer, char FromChar, string ToString)
{ // Change all occurrences of "FromChar" to "ToString" in the input Buffer.
// If ToString is null then FromChar is deleted instead of replaced.
// print "...fReplaceChar(Buffer)...\n"
if (fIsEmptyBuf(InBuffer) or
null FromChar or
FromChar "" == ToString)
return() // Nothing to do, Don't change anything

int iPrev, iCurr, Count, LenIn
bool Done
Buffer bufReplace = create()

gl_fReplace_ToStngBuff = ""
gl_fReplace_ToStngBuff += ToString // Combining Buffers is more efficient than appending Strings.
LenIn = length(InBuffer)
Count = 0
Done = false
iCurr = -1
iPrev = -1
bufReplace = ""
while (!Done)
{ iCurr = contains(InBuffer, FromChar, iPrev+1)
if (iCurr == -1 or iCurr >= LenIn)
{ // Not found (or out-of-bounds??)
Done = true
combine(bufReplace, InBuffer, iPrev+1) // Add rest of InBuffer to bufReplace
}
else
{ // Found:
combine(bufReplace, InBuffer, iPrev+1, iCurr-1) // Add portion before it was found
combine(bufReplace, gl_fReplace_ToStngBuff, 0) // Insert ToString
iPrev = iCurr // Update Pointer
Count++
}
} // end while looking for the InChar

// print "**fReplaceChar; InBuffer = " InBuffer "\n"
// print "**fReplaceChar; changed; TempBuff = " Count " " tempStringOf(bufReplace) "\n"
delete(InBuffer)
InBuffer = bufReplace // Make Alias.
return()
} // end fReplaceChar(Buffer)

I think you can change 'degrees' as follows: fReplaceChar(bufText, charOf(160), "\\degrees")

  • Louie

Re: Is it possible to replace symbol characters in dxl?
mirlo - Sun Mar 21 10:53:38 EDT 2010

That function works great, thanks, I can now replace characters just fine.

Re: Is it possible to replace symbol characters in dxl?
witthoft_carl - Mon Sep 26 15:41:46 EDT 2016

llandale - Sun Mar 07 14:33:46 EST 2010
Regular expressions and matching strings is very ineffecient. Here's my replace character function:
Buffer gl_fReplace_ToStngBuff = create(1024) // allows quick Combine

//***********************
void fReplaceChar(Buffer &InBuffer, char FromChar, string ToString)
{ // Change all occurrences of "FromChar" to "ToString" in the input Buffer.
// If ToString is null then FromChar is deleted instead of replaced.
// print "...fReplaceChar(Buffer)...\n"
if (fIsEmptyBuf(InBuffer) or
null FromChar or
FromChar "" == ToString)
return() // Nothing to do, Don't change anything

int iPrev, iCurr, Count, LenIn
bool Done
Buffer bufReplace = create()

gl_fReplace_ToStngBuff = ""
gl_fReplace_ToStngBuff += ToString // Combining Buffers is more efficient than appending Strings.
LenIn = length(InBuffer)
Count = 0
Done = false
iCurr = -1
iPrev = -1
bufReplace = ""
while (!Done)
{ iCurr = contains(InBuffer, FromChar, iPrev+1)
if (iCurr == -1 or iCurr >= LenIn)
{ // Not found (or out-of-bounds??)
Done = true
combine(bufReplace, InBuffer, iPrev+1) // Add rest of InBuffer to bufReplace
}
else
{ // Found:
combine(bufReplace, InBuffer, iPrev+1, iCurr-1) // Add portion before it was found
combine(bufReplace, gl_fReplace_ToStngBuff, 0) // Insert ToString
iPrev = iCurr // Update Pointer
Count++
}
} // end while looking for the InChar

// print "**fReplaceChar; InBuffer = " InBuffer "\n"
// print "**fReplaceChar; changed; TempBuff = " Count " " tempStringOf(bufReplace) "\n"
delete(InBuffer)
InBuffer = bufReplace // Make Alias.
return()
} // end fReplaceChar(Buffer)

I think you can change 'degrees' as follows: fReplaceChar(bufText, charOf(160), "\\degrees")

  • Louie

The unicode for the degree sign is decimal 176 .  decimal 160 so far as I can tell is a nonbreaking space.