Silverfrost Logo About Us | Contact Us

Floating point input - %nrf

%rf creates an edit box and displays the value of the corresponding (DOUBLE PRECISION) argument. The number will be updated whenever the edit field is adjusted. The user will be prevented from creating an invalid or out of range number (see Floating point increase/decrease). Numbers are entered in decimal or exponent form. For example: -0.0748 or -7.48e-2.

By default the edit box will be made large enough to hold values in the current range, although the integer parameter n can be used to override this.

A call-back function is supplied using the caret (^) modifier. This function is called immediately a change is made.

For example, suppose you wanted to prompt for a complex number, and the user is allowed to supply this as an (x, y) pair or as an pair. The box should show the current number in both formats and any change in one format should be reflected in the other. Here is some sample code that has the desired effect.

      DOUBLE PRECISION x,y,r,theta
      COMMON x,y,r,theta
      INTEGER i,winio@
      EXTERNAL convert_to_xy,convert_to_polar
      i=winio@('%ca[Polar co-ordinates]%bg[grey]&')
      i= winio@('%3tl&',5,15,21)
      i=winio@('   %itx%`it=%ta&')
      i= winio@('%^rf&',x,convert_to_polar)
      i=winio@('   %ity%`it=%ta&')
      i= winio@('%^rf&',y,convert_to_polar)
      i=winio@('%ff   %itr%`it=%ta&')
      i= winio@('%^rf&',r,convert_to_xy)
      i=winio@('   %fn[Symbol]%itq%sf  =%ta&')
      INTEGER FUNCTION convert_to_polar()
      DOUBLE PRECISION x,y,r,theta,tiny
      COMMON x,y,r,theta
      INTEGER FUNCTION convert_to_xy()
      DOUBLE PRECISION x,y,r,theta
      COMMON x,y,r,theta

A grave accent format modifier (`) is used to make the control read-only. In this form no surrounding box is supplied, and the value displayed can only be changed by the program, using window_update@ to reflect the changes.

The %co format (see Control option format) is used to modify the way that %rf and %rd call-back functions behave.



Copyright © 1999-2018 Silverfrost Limited