Add Leading Characters to a Value or Field
2009-07-27 13:10
369 查看
A function to facilitate the addition of a leading character to a field value. The function takes three parameters:
- &LEADCHAR: The character you want to append to your value.
- &FIELDZISE: The over all size of your value after appending your desired character.
- &FIELDVALUE: The value you want to append the character to.
Function add_leading_char(&LEADCHAR, &FIELDSIZE, &FIELDVALUE, &RESULTFIELD);
/*this function accepts a character value, fieldsize parameter, and a field value parameter and adds a leading character up to the size of the field. The result is passed back in a result field.*/
&LEADCHAR = Left(&LEADCHAR, 1);
&FIELDVALUE = String(&FIELDVALUE);
&FIELDLEN = Len(&FIELDVALUE);
&FIELDFILL = &FIELDSIZE - &FIELDLEN;
&LEFT_HALF = Rept(&LEADCHAR, &FIELDFILL);
&RESULTFIELD = &LEFT_HALF | &FIELDVALUE;
End-Function;
/*Example calling the above function*/
&CHAR = "0";
&FIELDSIZE = 5;
&FIELDVALUE = 7;
add_leading_char(&CHAR, &FIELDSIZE, &FIELDVALUE, &RESULTFIELD);
/*after execution, the &RESULTFIELD value would be equal to 00007*/
- &LEADCHAR: The character you want to append to your value.
- &FIELDZISE: The over all size of your value after appending your desired character.
- &FIELDVALUE: The value you want to append the character to.
Function add_leading_char(&LEADCHAR, &FIELDSIZE, &FIELDVALUE, &RESULTFIELD);
/*this function accepts a character value, fieldsize parameter, and a field value parameter and adds a leading character up to the size of the field. The result is passed back in a result field.*/
&LEADCHAR = Left(&LEADCHAR, 1);
&FIELDVALUE = String(&FIELDVALUE);
&FIELDLEN = Len(&FIELDVALUE);
&FIELDFILL = &FIELDSIZE - &FIELDLEN;
&LEFT_HALF = Rept(&LEADCHAR, &FIELDFILL);
&RESULTFIELD = &LEFT_HALF | &FIELDVALUE;
End-Function;
/*Example calling the above function*/
&CHAR = "0";
&FIELDSIZE = 5;
&FIELDVALUE = 7;
add_leading_char(&CHAR, &FIELDSIZE, &FIELDVALUE, &RESULTFIELD);
/*after execution, the &RESULTFIELD value would be equal to 00007*/
相关文章推荐
- can't get git rev, you should add git to system path or just input test value, such as 'testTinkerId
- How to Add Custom Field Type (in SPFieldType Enum) Programatically or any other way
- According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- Failed to convert value of type...no matching editors or conversion strategy found
- How To determine DDIC Check Table, Domain and Get Table Field Text Data For Value?
- According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- Magento addFieldToFilter和addAttributeToFilter用法整理
- <c:set var="root" value="${pageContext.request.contextPath}"></c:set>According to TLD or attribute d
- swift - use backslash to add the value in the string
- struts2.x 的提交表单出现 Could not create and/or set value back on to object
- According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces
- warning C4800: 'VARIANT_BOOL' : forcing value to bool 'true' or 'false' (performance warning)
- 重构的小故事 Change Value to Reference or Vice Verse
- 解决:According to TLD or attribute directive in tag file, attribute value does not accept any express。
- 六、ERROR - Could not create and/or set value back on to object
- Add an UIProgressView or UIActivityIndicatorView to your UIAlertView
- According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- Err:The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array