Casting String to Char

Hello, I am very new to the dxl language and need help with casting a string as a char.

I am getting the text from an object, placing it in a string, and parsing the string to get ascii values of each character. I am not sure how to convert texti:i into a character since intOf("a") does not work while intOf('a') does work.

Thanks for the help!
TheDrizzle - Wed Jun 08 14:26:20 EDT 2011

Re: Casting String to Char
llandale - Wed Jun 08 15:07:19 EDT 2011

Double quotes are for "string", single quotes are for 'character'.
Substrings use this: intFrom:intTo; subCharacters use this: intLoc.

Object oCurr = current
string NameAttr = "Object Text"    // Change to your Attribute Name
string Value = probeAttr_(oCurr, NameAttr)
 
char   c
int    i, Ascii
print "Value = " Value "\n"
 
for (i=0; i<length(Value); i++)
{  if (i >= 100) break     // Value far too long for this chore
   c = Value[i]            // <<<--- here you go, get the char
   Ascii = intOf(c)        // <<<--- convert char to Ascii Code
   print "\t" c "\t" Ascii "\n"
}

 

  • Louie

 

Re: Casting String to Char
TheDrizzle - Wed Jun 08 15:19:23 EDT 2011

Thanks for the answer I just assigned the substring to a character variable and it worked. What does "string Value = probeAttr_(oCurr, NameAttr)" mean though? I have no idea what probeAttr_ does and am curious.

Re: Casting String to Char
llandale - Wed Jun 08 15:49:06 EDT 2011

TheDrizzle - Wed Jun 08 15:19:23 EDT 2011
Thanks for the answer I just assigned the substring to a character variable and it worked. What does "string Value = probeAttr_(oCurr, NameAttr)" mean though? I have no idea what probeAttr_ does and am curious.

probeAttr_ is a function written by DXL folks years ago and used internally by many DOORS things. It's not a language perm and will not be in the DXL manual. It retrieves the object-attr value, much like "Value = obj.NameAttr" does. However, it does a lot of checking and will not abort such as when the attribute doesn't exist; and it will retrieve "Object Identifier" as if it were an attribute.

Don't know all the varieties of "probeAttr_" but there is also "probeRichAttr_" which retrieves rich text. There are some "bounded" varieties but they used to not work and I never got around to using them after they were fixed.

Take a peak here: c:\Program files\IBM\Rational\DOORS\9.2\lib\dxl\utils\attrutil.inc

  • Louie