Fastest way to figure out whether a letter is upper case - Forum - OpenEdge Development - Progress Community

Fastest way to figure out whether a letter is upper case

 Forum

Fastest way to figure out whether a letter is upper case

This question has suggested answer(s)

What's the fastest way to figure out whether a given letter is upper-case or not in ABL?

 I want to turn something like OpenEdge.Net.DataObject.DataObjectHandler  into a string like

              OE.N.DO.DataObjectHandler    

It has to be as fast as possible so , um, creative code will be considered .

All Replies
  • @scott_auge

    Perhaps, you would need to make the variable case-sensitive.

    define variable vChar as character case-sensitive no-undo.

    vChar = "A".

    /* Test if string is lowercase */

    if LC(vChar) = vChar then

       message "Equal".

    else

       message "Not equal".

  • Peter, I have noticed that you used for every literal the ":u" attribute. Has this attribute a huge performance impact?

    @Creative

    DEFINE VARIABLE cClassName  AS CHARACTER NO-UNDO CASE-SENSITIVE.
    DEFINE VARIABLE cBeforeTrim AS CHARACTER NO-UNDO CASE-SENSITIVE.
    DEFINE VARIABLE cAfterTrim  AS CHARACTER NO-UNDO CASE-SENSITIVE.
    DEFINE VARIABLE cResult     AS CHARACTER NO-UNDO.
    
    DEFINE VARIABLE iLength AS INTEGER NO-UNDO.
    DEFINE VARIABLE iCount  AS INTEGER NO-UNDO.
    
    ASSIGN
      cClassName = "OpenEdge.Net.DataObject.DataObjectHandler"
      iLength    = LENGTH(cClassName)
    iCount     = 1 . DO WHILE TRUE: IF iCount >= iLength THEN LEAVE. ASSIGN cBeforeTrim = SUBSTRING(cClassName, iCount) cAfterTrim = LEFT-TRIM(cBeforeTrim, "abcdefghijklmnopqrstuvwxyz") iCount = iCount + LENGTH(cBeforeTrim) - LENGTH(cAfterTrim) + 1 cResult = cResult + SUBSTRING(cAfterTrim, 1, 1) . END.
    /* cResult = OE.N.DO.DOH - ASSIGN Statement: 12times called 0.000075 avg. per call 0.000006 */
  • I would hope that :U only makes difference at compile time. At runtime that _has_ to be transparent.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • :U marks the string as not-translatable - this has the compile time-effect of enabling the compiler to concatenate a series of strings together. Without :U, the string is considered translatable which means it can't be concatenated at compile time.

    "string1":U + "string2":U <- concatenated once at compile time

    "string1"     + "string2"    <- concatenated at run time each time this line of code is executed

  • That aside, in this thread there are no concatenated strings. But I guess we agree that :U should have no runtime impact on the code samples discussed in this thread.
     
    Von: Tim Kuehn [mailto:bounce-timk519@community.progress.com]
    Gesendet: Donnerstag, 12. Januar 2017 06:40
    An: TU.OE.Development@community.progress.com
    Betreff: RE: [Technical Users - OE Development] Fastest way to figure out whether a letter is upper case
     
    Update from Progress Community
     

    :U marks the string as not-translatable - this has the compile time-effect of enabling the compiler to concatenate a series of strings together. Without :U, the string is considered translatable which means it can't be concatenated at compile time.

    "string1":U + "string2":U <- concatenated once at compile time

    "string1"     + "string2"    <- concatenated at run time each time this line of code is executed

    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.

     

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.