Author Topic: Lenght string function in pixel  (Read 3704 times)

0 Members and 1 Guest are viewing this topic.

Offline neuronix

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 108
  • Rating: +0/-0
    • View Profile
Lenght string function in pixel
« on: September 10, 2016, 10:44:54 am »
Hi,
I would like to create an lenght string function in Axe that return the lenght in pixel but my function don't work, she returns wrongs value:
Code: [Select]
Lbl DimStr
0→r₃
For(r₂,0,longueur(r₁)-1
If dansChaîne("abcdeghjknopqruvxy?0123456789­-+/^{}θ…_%↑↓×\ABCDEFGHIJKLMNOPQRSTUVWXYZθ"[00],{r₁+r₂})
r₃+4→r₃
End
If 32={r₁+r₂}
r₃++
End
If dansChaîne("i.:!"[00],{r₁+r₂})
r₃+2→r₃
End
If dansChaîne("flst()[],;"[00],{r₁+r₂})
r₃+3→r₃
End
If dansChaîne("z&~"[00],{r₁+r₂})
r₃+5→r₃
End
If dansChaîne("mw*π$#@"[00],{r₁+r₂})
r₃+6→r₃
End
End
r₃
Return
Help me please.
Thank you in advance

P.S:
With a string equal to "Hi!", the function should returns 8 but she returns 0 :(

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: Lenght string function in pixel
« Reply #1 on: September 10, 2016, 11:59:15 am »
If dansChaîne means inString, then you have the arguments in the wrong order.  It should be inData(BYTE,PTR).

Optimized, for fun:
Code: (Axe) [Select]
Lbl DimStr
  0
  While →r₃{r₁++-1}
    !If →r₂ xor ' '
      1
    ElseIf inData(r₂,"i.:!")
      2
    ElseIf inData(r₂,"flst()[],;")
      3
    ElseIf inData(r₂,"z&~")
      5
    ElseIf inData(r₂,"mw*π$#@")
      6
    Else
      4
    End
    +r₃
  End
  r₃
Return

Offline neuronix

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 108
  • Rating: +0/-0
    • View Profile
Re: Lenght string function in pixel
« Reply #2 on: September 10, 2016, 01:36:58 pm »
Ok,
Very thanks jacobly  :thumbsup: