Opto 22

43044 Business Park Drive, Temecula, CA 92590 USA
Local & outside the USA:(951) 695-3000
Toll-Free within the USA:(800) 321-6786
Fax: (951) 695-3095
Email: sales@opto22.com
 
KB80115
PAC Control and ioControl NumberToString() results different from OptoControl's NumberToString()
Revision:  2.0
Published:  2/3/2010
Applies To
PAC Control Professional
PAC Control Basic
ioControl Professional
ioControl Basic
Versions
Affected versions beginning with:  
R8.0a PAC Control
R1.0a ioControl

SYMPTOMS

The NumberToString( ) command in PAC Control and ioControl does not produce the same results as NumberToString( ) in OptoControl.

WORKAROUND

Use the following OptoScript code to format the results from PAC Control's NumberToString( ) command to match the results from OptoControl's NumberToString( ) command.

OptoScript sample code:

// For the case of 0, we don't want scientific notation or a decimal point (to match OptoControl)
if (TestFloat== 0) then 
   OptoNumToStr= "0";

else
   // PAC Control Command: NumberToString (Convert, Put Result in
   // The format returned by this command is X.000000e+EE
   // where the X remains the same,
   // the(sign on the exponent could be + or -) 
    
// the EE is not changing unless it's 00; if EE = "00", then "e+EE" is dropped
   // drop up to 6 trailing 0s to the right of the decimal point 

   NumberToString(TestFloat, OptoNumToStr2); 

   // Find 'e' in the string; 'e' = 101 in decimal; split into significand and exponent
   ch_pos = FindCharacterInString(101, 0, OptoNumtoStr2);
   GetSubstring(OptoNumToStr2, 0, ch_pos, OptoNumToStr);
   GetSubstring(OptoNumToStr2,ch_pos, 4, OptoNumToStr2);

   // Remove all '0' from the end of the significand; '0'= 48 in decimal 
   DecrementVariable(ch_pos);
   while (GetNthCharacter(OptoNumToStr, ch_pos) == 48
      GetSubstring(OptoNumToStr, 0, ch_pos, OptoNumToStr); 
      DecrementVariable(ch_pos);
   wend

   // If Exponent not equal to 00, append to output string 
   if (OptoNumToStr2== "e+00") then
   else
      OptoNumToStr += OptoNumToStr2;
   endif

endif 

RESOLUTION

Opto 22 is aware of this issue and recommends using the Workaround.

Relevant Downloads
No relevant downloads have been specified.
Questions? Contact Opto 22 Product Support.
Phone: 800-835-6786 or 951-695-3080
Email: support@opto22.com

DISCLAIMER

This Opto 22 Knowledge Base ('OptoKB') article is intended to provide general technical information on a particular subject or subjects and is not an exhaustive treatment of such subjects. Accordingly, the information in this OptoKB article is not intended to constitute application, design, software, or other professional engineering advice or services. Opto 22 may modify the OptoKB articles at any time. Before making any decision or taking any action which might affect your equipment, you should consult a qualified professional.

OPTO 22 DOES NOT WARRANT THE COMPLETENESS, TIMELINESS, OR ACCURACY OF THE DATA CONTAINED IN THIS OPTOKB ARTICLE AND MAY MAKE CHANGES THERETO AT ANY TIME AT ITS SOLE DISCRETION WITHOUT NOTICE. FURTHER, ALL INFORMATION CONVEYED HEREBY IS PROVIDED TO USERS 'AS IS.' IN NO EVENT SHALL OPTO 22 BE LIABLE FOR ANY DAMAGES OF ANY KIND INCLUDING DIRECT, INDIRECT INCIDENTAL, CONSEQUENTIAL, LOSS PROFIT, OR DAMAGE, EVEN IF OPTO 22 HAS BEEN ADVISED ON THE POSSIBILITY OF SUCH DAMAGES.

OPTO 22 DISCLAIMS ALL WARRANTIES WHETHER EXPRESSED OR IMPLIED WITH RESPECT TO THE INFORMATION (INCLUDING HARDWARE, SOFTWARE, AND/OR FIRMWARE) PROVIDED HEREBY, INCLUDING THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTIBILITY, AND NON-INFRINGEMENT. Note that certain jurisdictions do not sanction the exclusion of implied warranties: thus, this disclaimer may not apply to you.

Copyright © 2016 Opto 22. All rights reserved.

My.Opto22

All Opto22

Request Information
  • FREE Product Brochure
  • Product Demonstration
  • PreSales Engineering Assistance

Opto 22 Product Support

Opto 22 Product Support is FREE Monday through Friday 7 a.m. to 5 p.m. Pacific Time

Product Support Numbers:

Local: (951) 695-3080
Toll-Free: (800) 835-6786
Fax: (951) 695-3017
support@opto22.com

Products

None

Downloads

None

Documents

None