# 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 DimStr0→r₃For(r₂,0,longueur(r₁)-1If dansChaîne("abcdeghjknopqruvxy?0123456789­-+/^{}θ…_%↑↓×\ABCDEFGHIJKLMNOPQRSTUVWXYZθ"[00],{r₁+r₂})r₃+4→r₃EndIf 32={r₁+r₂}r₃++EndIf dansChaîne("i.:!"[00],{r₁+r₂})r₃+2→r₃EndIf dansChaîne("flst()[],;"[00],{r₁+r₂})r₃+3→r₃EndIf dansChaîne("z&~"[00],{r₁+r₂})r₃+5→r₃EndIf dansChaîne("mw*π\$#@"[00],{r₁+r₂})r₃+6→r₃EndEndr₃Return`Help me please.

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: