clear if file('transform_string.dbf') drop table transform_string endif if not file('transform_string.dbf') create table transform_string (numStr character(15),numStr1 character(15),nNum int) use transform_string generate 30 replace all numStr with str(nNum,10,0) //Saves value with leading spaces use delete from transform_string where nNum = 0 or nNum > 900000 update transform_string set numStr1 = cast(nNum as char(10)) //Saves values without leading spaces alter table transform_string drop nNum //Code above is used to create a test table with a field containing //integers as strings in two fields. One field with leading spaces and //the other with trailing spaces endif //The code below adds two new character fields to the table and then //populates the new fields from the original two fields with commas //inserted to mark thousands. set procedure to insert_k_marker.prg //Only necessary if .prg is not in the same folder as the .wfm file //Add a path or sourcecode alias try alter table transform_string drop NewNumStr alter table transform_string drop NewNumStr1 catch( exception e ) endtry alter table transform_string add NewNumStr char(12) //extra spaces to allow for comas alter table transform_string add NewNumStr1 char(12) use transform_string scan cStr = insert_k_marker(numStr) //Process field with leading spaces replace NewNumStr with right(space(12)+cStr,12) cStr = insert_k_marker(numStr1) //Process field with trailing spaces replace NewNumStr1 with right(space(12)+cStr,12) endscan use close procedure insert_k_marker.prg ** END HEADER -- do not remove this line // // Generated on 2023-11-14 // parameter bModal local f f = new transform_stringForm() if (bModal) f.mdi = false // ensure not MDI f.readModal() else f.open() endif class transform_stringForm of FORM with (this) onClose = class::FORM_ONCLOSE height = 22.8636 left = 0.1429 top = 0.0455 width = 95.0 text = "" endwith this.TRANSFORM_STRING1 = new QUERY(this) with (this.TRANSFORM_STRING1) left = 33.0 width = 14.0 height = 1.0 sql = 'select * from "transform_string.DBF"' active = true endwith this.GRID1 = new GRID(this) with (this.GRID1) fontName = "Consolas" dataLink = form.transform_string1.rowset height = 16.0455 left = 6.8571 top = 3.5 width = 81.1429 endwith this.TEXT1 = new TEXT(this) with (this.TEXT1) height = 2.2727 left = 54.0 top = 0.6364 width = 34.0 text = "Uses leading spaces to display the string right justified. A monospaced font must be used." endwith this.rowset = this.transform_string1.rowset function form_onClose() form.transform_string1.active = false alter table transform_string drop NewNumStr //Remove temp field alter table transform_string drop NewNumStr1 //Remove temp field return endclass