10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How You Can Manipulate Data in Dynamic FieldsThe following lines of code perform the same operation as the previous oneline of code:status = efield.GetFieldValue(value =byref(dollars));dollars = dollars * 1.15;status = efield.SetFieldValue(value = dollars);The first statement gets the value in the efield field and loads it into the dollarsvariable. The second line increases the value in the dollars variable by 15percent. The last line sets the value of the efield field with the current value ofthe dollars variable, thus increasing the value of a field (efield) named salaryby 15 percent.The integer variable status in this example is set to ER_OK if the method issuccessful. If not, status contains a value indicating the error condition. Atypical source of error is data type incompatibility between the field and thevariable to which its value is being assigned.You can access other attributes of the dynamic field by using the referencevariable pointing to the field (in the same manner as accessing attributes ofstatically created fields). For example, you can access the character stringdisplayed in an entry field by using the TextValue attribute, which contains thestring representing the characters that the user or program has entered intothe field.In the case of a varchar field, the value of the TextValue attribute is equivalentto the field's value. For any other kind of field, such as an integer or moneyfield, you must use a conversion function to obtain the field's value from theTextValue attribute.For example, the following code converts the value of a TextValue attribute tomoney, multiplies it by 1.5, and puts it into the dollars variable:dollars = money(efield.TextValue) * 1.5;The following code converts the money value stored in the dollars variable tovarchar and puts it into the TextValue attribute of the efield field:efield.TextValue = varchar(dollars);Note: If the user erroneously enters characters that are incompatible with afield's data type, using type conversion functions in this way causes errors thatmay be difficult to trace.Creating Dynamic Frames 383

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!