Re: [foxboro] String to Real/Float Conversion

This might not be the most efficient script but it works !!

Regards......Jim.

 
VARIABLES {*****************************************}

        batch_size      : S6;
        number     : S6[9]; 
        m_factor           : I[6];
        total      : I;
        var                     : I;
        num                   : I;

STATEMENTS{*****************************************}

FOR var:= 1 TO 9 DO
     number[var]:=var;
ENDFOR;

m_factor[1]:=1;
m_factor[2]:=10;
m_factor[3]:=100;
m_factor[4]:=1000;
m_factor[5]:=10000;
m_factor[6]:=100000;

batch_size:=STRING::UNIT.SN0002;

total:=0;

FOR var:=6 DOWNTO 1 DO
     FOR num:=1 TO 9 DO 
          IF batch_size(var..var)="0" THEN 
               EXITLOOP;
          ELSEIF batch_size(var..var)=number[num] THEN
               total:=total+(num*m_factor[var]); 
          ENDIF;
     ENDFOR;
ENDFOR;

IO0001:=total;

_______________________________________________
JIM GOODGER
Process Applications Engineer

Ondeo Nalco Energy Services Ltd
Cadland Road, Hardley, Hythe, Southampton, SO45 3NP
Tel +44 023 80 883746     Fax +44 023 80 883882
email:  jdgoodger@xxxxxxxxxxxxx


 
 
___________________________________________________________________
This list is neither sponsored nor endorsed by The Foxboro Company.
Use the information obtained here at your own risk. For disclaimer,
see http://www.thecassandraproject.org/disclaimer.html#maillist

list info:   http://www.freelists.org/list/foxboro
subscribe:   mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
unsubscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave

Other related posts: