10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How You Can Manipulate Data in Dynamic FieldsHow You Can Get Values from Unknown FieldsThe previous examples of getting and setting values with dynamic expressionsassume you know the name and data type of the current table field column.Assume instead that you want to get a value from the current cell of a dynamictable field named tbl but you do not know which cell currently has the inputfocus. Assume also that all columns in the table have a data type of integer orvarchar.When you invoke the GetValue method, you must put the value obtained into avariable of the appropriate data type. Therefore, getting the value from thecurrent cell requires using a conditional statement as well as creating adynamic expression and invoking the GetValue method.The following field script performs these operations when the user enters a cellin a table field:declaretxt = varchar(50) not null;dexp = DynExpr default null;errstr = StringObject default null;intvar = integer not null;textvar = varchar(50) not null;status = integer not null;enddeclareon childentry =begintxt = 'tbl[].' + CurFrame.TriggerField.Name;dexp = CurFrame.Scope.CreateDynExpr(string = txt, errors = byref(errstr));if CurFrame.TriggerField.DataType = 'integer'then status = dexp.GetValue(value =byref(intvar));elsestatus = dexp.GetValue(value = byref(textvar));endif;...endAfter declaring the appropriate variables, this code uses the Name attributedefined for the FieldObject system class to create a text string that containsthe full name of the current table field cell.If the expression in the txt variable is valid (that is, points to an existing fieldand performs valid operations), the errstr variable is null after the statementcreating this dynamic expression; otherwise, it contains the text of the errormessage.388 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!