Announcement

Collapse
No announcement yet.

LEFT$ problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • LEFT$ problem

    In trying to track down an intermittent bug, I've narrowed it down to the following tiny point.

    The code is from a small preferences dialog. The failing part has to do with a simple TEXT box which the user can leave blank or enter a single character into.

    Retrieving was not always successful as sometimes, when a character was entered, it did not appear to be detected. So I added some MSGBOX's and ran through it over and over.

    1. ERR is always zero, as expected.
    2. The 1st display of LeftClickChar is ALWAYS correct (what was entered).
    3. The 2nd display of LeftClickChar is blank about 1/2 the time, not always.
    4. LeftClickChar is just a simple dynamic STRING.

    I can't believe LEFT$ is failing, but it sure looks like that.
    EDIT: I switched to MID$(xxx, 1, 1) from LEFT$ but no difference, but what else can alter the string between the MSGBOX's?

    Any other thoughts? I'm tearing my hair out.

    George

    Code:
       CONTROL GET TEXT hMouse, %MOUSE_LEFTCLICK_CHAR TO LeftClickChar
       MSGBOX "Err=" & FORMAT$(ERR)
       MSGBOX LeftClickChar
       LeftClickChar = LEFT$(LeftClickChar, 1)
       MSGBOX LeftClickChar
    Last edited by George Deluca; 1 Apr 2009, 10:58 AM.

  • #2
    There might be a none displaying character in the string. Why not print the Length of the string, which you think will be one, but ???. Also print the Format$(Asc(LeftClickChar)) to see what you really have.

    Chuck

    Comment


    • #3
      Left$ problem - please ignore

      :exactly: Smacking forehead with a large hammer here.

      Guess what a leading blank does.

      Can't believe I've wasted so much time on this.

      Grrrr..


      Many, many thanks,

      George

      Comment


      • #4
        Don't think for a minute you are the only one that's been-there-done-that, George.
        There are no atheists in a fox hole or the morning of a math test.
        If my flag offends you, I'll help you pack.

        Comment


        • #5
          BTW, you can use:

          CONTROL POST hDlg, %IDC_TEXTBOX1, %EM_LIMITTEXT, 1, 0

          to force the textbox to only accept 1 character (thus avoiding the need to use LEFT$). Adjust the %id as necessary of course.
          Bernard Ertl
          InterPlan Systems

          Comment


          • #6
            You can also use the TRIM$ Command -

            LeftClickChar = LEFT$(TRIM$(LeftClickChar), 1)

            Comment


            • #7
              Bern: Thanks a lot. I'd been looking for a way to limit the input in the PB help, but found nothing. I didn't even know messages like this existed.

              As you can guess, this is my 1st go-round at dialogs. Makes me appreciate the enormous grunt-work that must go into the interfaces for some apps, let alone that needed to actually DO the real work.

              I thought retirement was going to be easy; I thought I'd escaped the perpetual learning curve.


              George

              Comment

              Working...
              X