Start a new topic

String float split

just try it !

HMI
(19.6 KB)

can also send as

float*=1000;

send float:

sys0=123456ÿÿÿ

click function containing:

n0.val=sys0/1000

n1.val=sys0%1000

or


 

 

caracter.txt=""
sys0=0
cov t0.txt,n0.val,0
while(caracter.txt!=".")
{
  substr t0.txt,caracter.txt,sys0,1
  sys0++
  if(sys0>t0.txt_maxl)
  {
    caracter.txt="."
  }
}
substr t0.txt,t1.txt,sys0,100
cov t1.txt,n1.val,0

 

 

or

send as whole number milliunits

n0.val=123456ÿÿÿ

and just put decimal as fixed background.


Painted on like the old pumps at fuel station did.


image


All make assumptions that

programmer has forward knowledge of the format used.


It wouldn't be very purposeful in programming

to not have and exploit such forward knowledge


Sending as integer is much fewer calculations

but in the example t0.txt="123456"

your example fails to produce a result.

One might consider in your function:

 - "123456" did not produce a result.

 - "123456." also did not produce a result.

 - "123.456" produces 123 and 456 but then ...

   "123.00456" also produces 123 and 456


When "123.007" "123.07" produce the same results

  there should perhaps be a distinction.


So try this modified run code


 

strlen t0.txt,sys1
caracter.txt=""
sys0=0
cov t0.txt,n0.val,0
while(caracter.txt!=".")
{
  substr t0.txt,caracter.txt,sys0,1
  sys0++
  if(sys0>sys1)
  {
    caracter.txt="."
  }
}
if(sys0<sys1)
{
  n1.lenth=sys1-sys0
  substr t0.txt,t1.txt,sys0,sys1
  cov t1.txt,n1.val,0
}else
{
  n1.lenth=0
  n1.val=0
}

 


1 person likes this