Convert TXT (String) To Int (Value) Nextion

 


To  convert TXT from edit text to Variable value on nextion . you need command on nextion editor

Covx

Convert variable from numeric type to text, or text to numeric type

– text must be text ASCII representation of an integer value.
– source and destination types must not be of the same type
– when source is numeric, hex format and length not 0 and <4.
ie: (len 2) positive significant (byte 0 to 3), 123 = 0000007B = 007B
ie: (len 2) negative significant (byte 3 to 0), -123 = FFFFFF85 = FF85
– value is more than allowed space results in a truncation
– it is recommended to ensure handling source length in user code before covx
– in v0.53, covx is deemed undefined if source is larger than length or
dest txt_maxl is smaller than requested length.
(some of these undefines, can be exploited)
ie: src numeric value of 123 with length 0, result is dest text “123”
– when length is fixed and value is less, leading zeros will be added
ie: src numeric value of 123 with length 4, result is dest text “0123”
– when value is larger than length, .txt truncated to least significant digits
ie: src numeric value of 23425 with length 4 result is dest text “3425”
usage: covx <src>,<dest>,<length>,<format>
    <src> is text attribute (or numeric attribute when <dest> is text)
    <dest> is numeric attribute (or text attribute when <src> is numeric)
    <length> will determine if leading zeros added to conversion to text
    <format> 0: integer, 1: Comma separated 1,000s, 2: Hex
    covx h0.val,t0.txt,0,0 // convert value of h0 into t0.txt without leading zeros
    covx t0.txt,h0.val,0,0 // convert t0.txt into integer in h0.val <length> ignored.
    covx h0.val,t0.txt,4,0 // convert value of h0 into t0.txt with exactly 4 digits
    covx h0.val,t0.txt,4,1 // convert value of h0 into t0.txt with commas
    covx h0.val,t0.txt,4,2 // convert value of h0 into t0.txt in 2 bytes of hex digits
    Invalid: covx h0.val,va0.val,0,0 or covx t0.txt,va0.txt,0,0 // src & dest same type.

Cov  

Depreciated. Convert from numeric type to text, or text to numeric type


– text must be text ASCII representation of an integer value.
– source and destination types must not be of the same type
– when length is fixed and value is less, leading zeros will be added
ie: src numeric value of 123 with length 4, result is dest text “0123”
– dest txt_maxl and length needs be large enough to accommodate conversion.
ie: src numeric value of 123 with length 0, result is dest text “123”
– when value is larger than length, .txt results in a truncation
– it is recommended to handle source length in user code before cov
    Note:v0.53 changed behaviour from previous pre/post v0.53 behaviours.
    cov is deemed undefined if source is larger than length or the dest txt_maxl is
    smaller than the requested length. Some undefines are exploitable.
    usage: cov <src>,<dest>,<length>
    <src> is text attribute (or numeric attribute when <dest> is text)
    <dest> is numeric attribute (or text attribute when <src> is numeric)
    <length> will determine if leading zeros added to conversion to text
    cov h0.val,t0.txt,0 // convert value of h0 into t0.txt without leading zeros
    cov t0.txt,h0.val,0 // convert integer into t0.txt from h0.val <length> ignored.
    cov h0.val,t0.txt,4 // convert value of h0 into t0.txt with exactly 4 digits
    Invalid: cov h0.val,va0.val,0 or cov t0.txt,va0.txt,0 // src & dest same type.

Example HMI File Nextion here 

Video Example Here 




0 Comments