6 58 2 C Examples

LANSA Open Guide

6.58.2 C Examples

C Example 1

BOOL fOK;

int  iSession;

 

fOK = LceSetFieldValue(iSession, "EMPNO", "12345");

 

C Example 2

BOOL fOK;

int  iSession;

 

fOK = LceSetFieldValue(iSession, "EMPNO", NULL);

 

C Example 3

strcpy(strField, "EMPNO");

if !LceSetFieldValue(iSession, strField, "12345")

{

         /* return error */

}

 

Note: You are not assigning strField = "12345". You are assigning the field "EMPNO", which happens to be stored in the variable strField, to the value of "12345".

C Example 4

iValue = 12345;

sprintf(strValue, "%ld", iValue);

strcpy(strKey,  "EMPNO");

 

if !LceSetFieldValue(iSession, strKey , strValue)

{

         /* return error */

}

 

Note: The field "EMPNO" may be a numeric value in a file; however, the field must be assigned a string value. If the value entered by a user was an integer, for example iValue, it must be converted to a string before it is used in the LceSetFieldValue function.