1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Strange subroutine output

Discussion in 'Bug Reports' started by petrbury, Jan 31, 2008.

  1. petrbury

    petrbury Member Licensed User

    sometimes I need to fill in a string with a character to achieve a concrete length of this string. So I've written a simple subroutine, which is working for me for a quite long time. Now I found a problem when I use optimized compilation. You can see it on attached example.

    Try to write for example number 1 to Input textbox and click on OK button. On the Result textbox should appear 00001 (subroutine fills it in 5 character length).
    From IDE and from non optimized compilation it works. But if I use optimized compilation in the Result textbox is 001. Strange.

    Has anybody some idea, please ?
  2. agraham

    agraham Expert Licensed User

    It's because you have StrLength(inp) in your For condition. In the IDE it is calculated once at the start of the loop, in the compiler it is calculated each pass round the loop. This works

    i = length - StrLength(inp)
    For sdi = 1 To i
  3. petrbury

    petrbury Member Licensed User

    You're very fast and you're right.
    I didn't know about this. It means I must check all my old programs for it.
    Thank you very much Agraham.
  4. Erel

    Erel Administrator Staff Member Licensed User

    This will be fixed in the next release.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice