WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Boxes Functions
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

BoxDrawText Wrap

 Keywords: BoxDrawText Wrap BoxDrawText Wrap Long Lines Length Text Alignment 16 Coordinate Dimensions Bounding Rectangle

Question:

I have tried to use the BoxDrawText Wrap Long Lines (alignment(16)). It only seems to wrap line which have spaces in them. Is there a way to change this to another character or a list of characters?

I am temporarily, I hope, adding a space in about the middle of a list of comma separated File Extensions.

Answer:

Yes it appears to need some type of white space marker (Space or tab) for the box function to decide where to wrap the data. You have a few options, your choice depends on the format of the data and how exactly you would like it displayed.

If you don't care about the commas, you can simply StrReplace all commas with space or tab in order to display easily. The coordinates of the bounding text box define where the data wraps.

*Or *

If you need to maintain the commas, you will need to format the comma delimited text to a specified record length.

Here is some sample code that will help with wrapping to specific line length

#DefineFunction StrWrap(Text,Wrap)
Offset = 1
While Offset + Wrap<=StrCharCount(Text)
   If StrCharCount(Text)<Offset + Wrap
      Offset = Offset + StrCharCount(Text)
   Else
      TmpStr = StrSub(Text,Offset,Wrap)
      FindLF = StrIndex(TmpStr,@LF,Wrap,@BACKSCAN)
      FindSpace = StrIndex(TmpStr," ",0,@BACKSCAN)
      If FindLF>0
         Offset = Offset + FindLF
      Else
         If FindSpace==0 Then FindSpace = Wrap
         TmpStr1 = StrSub(Text,1,Offset + FindSpace - 1)
         TmpStr2 = StrSub(Text,StrCharCount(TmpStr1) + 1,StrCharCount(Text) + 1 - StrCharCount(TmpStr1))
         TmpStr2 = StrTrim(TmpStr2)
         Text = StrCat(TmpStr1,@LF,TmpStr2)
         Drop(TmpStr1,TmpStr2)
         Offset = Offset + FindSpace + 2
      EndIf
   EndIf
EndWhile
Return Text
#EndFunction

hexdel=StrCat("01,02,03,04,05,06,07,08,09,0a,0b,0c,0d,0e,0f,10")
hexdel=StrCat(hexdel,"10,11,12,13,14,15,16,17,18,19,1a,1b,1c,1d,1e,1f")
hexdel=StrCat(hexdel,"20,21,22,23,24,25,26,27,28,29,2a,2b,2c,2d,2e,2f")
hexdel=StrCat(hexdel,"30,31,32,33,34,35,36,37,38,39,3a,3b,3c,3d,3e,3f")
hexdel=StrCat(hexdel,"40,41,42,43,44,45,46,47,48,49,4a,4b,4c,4d,4e,4f")
hexdel=StrCat(hexdel,"50,51,52,53,54,55,56,57,58,59,5a,5b,5c,5d,5e,5f")
hexdel=StrCat(hexdel,"60,61,62,63,64,65,66,67,68,69,6a,6b,6c,6d,6e,6f")
hexdel=StrCat(hexdel,"70,71,72,73,74,75,76,77,78,79,7a,7b,7c,7d,7e,7f")
hexdel=StrCat(hexdel,"80,81,82,83,84,85,86,87,88,89,8a,8b,8c,8d,8e,8f")
hexdel=StrCat(hexdel,"90,91,92,93,94,95,96,97,98,99,9a,9b,9c,9d,9e,9f")
hexdel=StrCat(hexdel,"a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af")
hexdel=StrCat(hexdel,"b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bb,bc,bd,be,bf")
hexdel=StrCat(hexdel,"c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,ca,cb,cc,cd,ce,cf")
hexdel=StrCat(hexdel,"d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,da,db,dc,dd,de,df")
hexdel=StrCat(hexdel,"e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,ea,eb,ec,ed,ee,ef")
hexdel=StrCat(hexdel,"f0,f1,f2,f3,f4,f5,f6,f7,f8,f9,fa,fb,fc,fd,fe,ff")

;Wrap - record length = 100
hexdel = StrWrap(hexdel,100)


;; Sample for BoxDrawText Wrap
BoxesUp("200,200,800,800", @NORMAL)
BoxCaption(1, "WinBatch BoxDrawText Line Wrap Example")
BoxDrawText(1, "200,150,750,250", "WinBatch Box Example - BoxDrawText Line Wrap ",@TRUE, 0)
coordinates = "100,350,890,900"
BoxDrawText(1, coordinates, hexdel, @TRUE, 16) ;Wrap
TimeDelay(5)
BoxShut()
Exit

NOte: If your data is delimited with space or tabs the wrapping of text has nothing to do with the data format but rather the coordinate dimensions of bounding rectangle for text, in virtual units in virtual units (upper-x upper-y lower-x lower-y). You must make absolutely sure that you are specifying the appropriate coordinates.

Here is a code sample that should help:

hexdel=StrCat("01",@TAB,"02",@TAB,"03",@TAB,"04",@TAB,"05",@TAB,"06",@TAB,"07",@TAB,"08",@TAB,"09",@TAB,"0a",@TAB,"0b",@TAB,"0c",@TAB,"0d",@TAB,"0e",@TAB,"0f",@TAB,"10",@TAB)
hexdel=StrCat(hexdel,"10",@TAB,"11",@TAB,"12",@TAB,"13",@TAB,"14",@TAB,"15",@TAB,"16",@TAB,"17",@TAB,"18",@TAB,"19",@TAB,"1a",@TAB,"1b",@TAB,"1c",@TAB,"1d",@TAB,"1e",@TAB,"1f",@TAB)
hexdel=StrCat(hexdel,"20",@TAB,"21",@TAB,"22",@TAB,"23",@TAB,"24",@TAB,"25",@TAB,"26",@TAB,"27",@TAB,"28",@TAB,"29",@TAB,"2a",@TAB,"2b",@TAB,"2c",@TAB,"2d",@TAB,"2e",@TAB,"2f",@TAB)
hexdel=StrCat(hexdel,"30",@TAB,"31",@TAB,"32",@TAB,"33",@TAB,"34",@TAB,"35",@TAB,"36",@TAB,"37",@TAB,"38",@TAB,"39",@TAB,"3a",@TAB,"3b",@TAB,"3c",@TAB,"3d",@TAB,"3e",@TAB,"3f",@TAB)
hexdel=StrCat(hexdel,"40",@TAB,"41",@TAB,"42",@TAB,"43",@TAB,"44",@TAB,"45",@TAB,"46",@TAB,"47",@TAB,"48",@TAB,"49",@TAB,"4a",@TAB,"4b",@TAB,"4c",@TAB,"4d",@TAB,"4e",@TAB,"4f",@TAB)
hexdel=StrCat(hexdel,"50",@TAB,"51",@TAB,"52",@TAB,"53",@TAB,"54",@TAB,"55",@TAB,"56",@TAB,"57",@TAB,"58",@TAB,"59",@TAB,"5a",@TAB,"5b",@TAB,"5c",@TAB,"5d",@TAB,"5e",@TAB,"5f",@TAB)
hexdel=StrCat(hexdel,"60",@TAB,"61",@TAB,"62",@TAB,"63",@TAB,"64",@TAB,"65",@TAB,"66",@TAB,"67",@TAB,"68",@TAB,"69",@TAB,"6a",@TAB,"6b",@TAB,"6c",@TAB,"6d",@TAB,"6e",@TAB,"6f",@TAB)
hexdel=StrCat(hexdel,"70",@TAB,"71",@TAB,"72",@TAB,"73",@TAB,"74",@TAB,"75",@TAB,"76",@TAB,"77",@TAB,"78",@TAB,"79",@TAB,"7a",@TAB,"7b",@TAB,"7c",@TAB,"7d",@TAB,"7e",@TAB,"7f",@TAB)
hexdel=StrCat(hexdel,"80",@TAB,"81",@TAB,"82",@TAB,"83",@TAB,"84",@TAB,"85",@TAB,"86",@TAB,"87",@TAB,"88",@TAB,"89",@TAB,"8a",@TAB,"8b",@TAB,"8c",@TAB,"8d",@TAB,"8e",@TAB,"8f",@TAB)
hexdel=StrCat(hexdel,"90",@TAB,"91",@TAB,"92",@TAB,"93",@TAB,"94",@TAB,"95",@TAB,"96",@TAB,"97",@TAB,"98",@TAB,"99",@TAB,"9a",@TAB,"9b",@TAB,"9c",@TAB,"9d",@TAB,"9e",@TAB,"9f",@TAB)
hexdel=StrCat(hexdel,"a0",@TAB,"a1",@TAB,"a2",@TAB,"a3",@TAB,"a4",@TAB,"a5",@TAB,"a6",@TAB,"a7",@TAB,"a8",@TAB,"a9",@TAB,"aa",@TAB,"ab",@TAB,"ac",@TAB,"ad",@TAB,"ae",@TAB,"af",@TAB)
hexdel=StrCat(hexdel,"b0",@TAB,"b1",@TAB,"b2",@TAB,"b3",@TAB,"b4",@TAB,"b5",@TAB,"b6",@TAB,"b7",@TAB,"b8",@TAB,"b9",@TAB,"ba",@TAB,"bb",@TAB,"bc",@TAB,"bd",@TAB,"be",@TAB,"bf",@TAB)
hexdel=StrCat(hexdel,"c0",@TAB,"c1",@TAB,"c2",@TAB,"c3",@TAB,"c4",@TAB,"c5",@TAB,"c6",@TAB,"c7",@TAB,"c8",@TAB,"c9",@TAB,"ca",@TAB,"cb",@TAB,"cc",@TAB,"cd",@TAB,"ce",@TAB,"cf",@TAB)
hexdel=StrCat(hexdel,"d0",@TAB,"d1",@TAB,"d2",@TAB,"d3",@TAB,"d4",@TAB,"d5",@TAB,"d6",@TAB,"d7",@TAB,"d8",@TAB,"d9",@TAB,"da",@TAB,"db",@TAB,"dc",@TAB,"dd",@TAB,"de",@TAB,"df",@TAB)
hexdel=StrCat(hexdel,"e0",@TAB,"e1",@TAB,"e2",@TAB,"e3",@TAB,"e4",@TAB,"e5",@TAB,"e6",@TAB,"e7",@TAB,"e8",@TAB,"e9",@TAB,"ea",@TAB,"eb",@TAB,"ec",@TAB,"ed",@TAB,"ee",@TAB,"ef",@TAB)
hexdel=StrCat(hexdel,"f0",@TAB,"f1",@TAB,"f2",@TAB,"f3",@TAB,"f4",@TAB,"f5",@TAB,"f6",@TAB,"f7",@TAB,"f8",@TAB,"f9",@TAB,"fa",@TAB,"fb",@TAB,"fc",@TAB,"fd",@TAB,"fe",@TAB,"ff",@TAB)

;; Sample 1 for BoxDrawText NO Wrap
BoxesUp("200,200,800,800", @NORMAL)
BoxCaption(1, "WinBatch BoxDrawText NO Line Wrap Example")
BoxDrawText(1, "200,150,750,250", "WinBatch Box Example - BoxDrawText NO Line Wrap ",@TRUE, 0)
coordinates = "100,350,890,900"
BoxDrawText(1, coordinates, hexdel, @TRUE, 0) ;No Wrap
TimeDelay(5)
BoxShut()

;; Sample 2 for BoxDrawText Wrap
BoxesUp("200,200,800,800", @NORMAL)
BoxCaption(1, "WinBatch BoxDrawText Line Wrap Example")
BoxDrawText(1, "200,150,750,250", "WinBatch Box Example - BoxDrawText Line Wrap ",@TRUE, 0)
coordinates = "100,350,890,900"
BoxDrawText(1, coordinates, hexdel, @TRUE, 16) ;Wrap
TimeDelay(5)
BoxShut()

;; Sample 3 for BoxDrawText Wrap with different dimensions
BoxesUp("200,200,800,800", @NORMAL)
BoxCaption(1, "WinBatch BoxDrawText Line Wrap Example with different dimensions")
BoxDrawText(1, "200,150,750,250", "WinBatch Box Example - BoxDrawText Line Wrap with different dimensions ",@TRUE, 0)
coordinates = "100,250,750,950"
BoxDrawText(1, coordinates, hexdel, @TRUE, 16) ;Wrap
TimeDelay(5)
BoxShut()

Article ID:   W17682
Filename:   BoxDrawText Wrap.txt
File Created: 2014:01:30:12:16:44
Last Updated: 2014:01:30:12:16:44