azmanmtm
12th September 2011, 03:34
I use the function available in the system to convert numbers into word. Now I have problem to print the string since it is 65 chars long and my cheque can only accomodate 45 chars. Is there any idea to wrap up the string into 2 lines without having to cut in the middle of the work such as hund and red in onother line.
Reply With Quote
mark_h
12th September 2011, 14:27
Wondering if you can use something like the pos function to find "and" or "hundred". Then you could break the line into two lines after than. Of course I do not know what the string looks like, so just pondering here.
Grace Cheong
13th September 2011, 09:10
Hi azmanmtm,
There is no text wrapping function to split a line string into two lines.
I did the text wrapping to split the item description (string) into two lines when the string is more than 30 characters.
You can refer to below sample by using POS & LEN functions:
function GetItemDesc()
{
item_desc1 = " "
item_desc2 = " "
select tcibd001.*
from tcibd001
where tcibd001.item =:item
selectdo
item_desc = tcibd001.dsca
if len(item_desc) > 30 then
Desc_TextWrapping()
else
item_desc1 = item_desc
item_desc2 = " "
endif
endselect
}
function Desc_TextWrapping()
{
|------------------------ Text Wrapping -------------------------
LeftStr = item_desc
Len_LeftStr = Len(LeftStr)
for i=1 to Len_LeftStr
pos_space = pos(LeftStr, " ") |--- count the 'space' position
if pos_space > 1 then
LenTemp = len(LeftStr) - (pos_space - 1)
Len1 = len(LeftStr) - LenTemp
T_Str = LeftStr(1 ; Len1)
LeftStr = LeftStr(pos_space + 1 ; Len_LeftStr - pos_space)
LenT_Str = Len(T_Str)
Else
T_Str = LeftStr
LenT_Str = Len(T_str)
endif
If (Len(item_desc1)+LenT_Str+1) < 41 then
if item_desc1 <> "" then
item_desc1 = item_desc1 & " " & T_str
else
item_desc1 = item_desc1 & T_str
endif
Else
if item_desc2 <> "" then
item_desc2 = item_desc2 & " " & T_str
else
item_desc2 = item_desc2 & T_str
endif
Endif
i = i + LenT_Str
endfor
}
Hopefully this can help u.
--- Grace ---
azmanmtm
14th September 2011, 05:41
Hi Grace Cheong
Thank you your feedback solve my headace.