3.2.3. Real Number Entry Example

This example shows how the cx-create-real-entry, cx-set-real-entry and cx-show-real-entry macros work. Once the real number entry field has been created, the initial value of the field is set to 0.7 via the statement (cx-set-real-entry realField 0.7). Next, the value of that integer entry field is increased to 1.2 using another cx-set-real-entry statement. This statement also has a cx-show-real-entry statement nested in it in order to get the value already in the integer entry field and add 0.5.

By the time the cx-show-panel statement is read, the value of realField is now 1.2, so the number 1.2 appears in the real number entry field when the dialog box is opened. This dialog box does not do anything when the OK button is clicked because we have substituted boolean values for the apply-cb and update-cb arguments, which would normally be function calls. For more information on the apply-cb and update-cb functions, see cx-create-panel.

(define apply-cb #t)
(define update-cb #f)

(define table)
(define realField)

(define my-dialog-box (cx-create-panel "My Dialog Box" apply-cb update-cb))

(set! table (cx-create-table my-dialog-box "This is an example Dialog Box"))

(set! realField (cx-create-real-entry table "Real Entry Field"))

(cx-set-real-entry realField 0.7)

(cx-set-real-entry realField (+ 0.5 (cx-show-real-entry realField)))

(cx-show-panel my-dialog-box)

To view additional examples of real number entry fields, see Comprehensive Examples.


Release 18.2 - © ANSYS, Inc. All rights reserved.