Omnimaga

Calculator Community => Major Community Projects => The Axe Parser Project => Topic started by: neuronix on September 10, 2016, 10:44:54 am

Title: Lenght string function in pixel
Post by: neuronix 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 :(
Title: Re: Lenght string function in pixel
Post by: jacobly 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
Title: Re: Lenght string function in pixel
Post by: neuronix on September 10, 2016, 01:36:58 pm
Ok,
Very thanks jacobly  :thumbsup: