# How to print a Dotted or Dashed LINE on a Report?

**URL:** <https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022>\
**Category:** questions\
**Tags:** report\
**Created:** [March 4, 2024, 4:07pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022 "2024-03-04T16:07:58Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [March 4, 2024, 4:07pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/1 "2024-03-04T16:07:58Z")

</div>

Hi ! Is it possible to print different dotted lines in reports? Thanks !

 ![ChromePDF](https://clarionhub-uploads.s3.dualstack.eu-north-1.amazonaws.com/original/2X/1/1576d042a3ce8efd5363ab34d5c8a75653a232eb.png)

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [March 4, 2024, 4:20pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/2 "2024-03-04T16:20:53Z")

</div>

See LINE in the help and SETPENSTYLE. This is not the line control but the LINE drawing command. There maybe more options in Capesoft’s Draw. I haven’t investigated to see.

---

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [March 4, 2024, 4:39pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/3 "2024-03-04T16:39:34Z")

</div>

> [@Rick\_UpperPark](#):
>
> SETPENSTYLE

Thanks ! This is already a good solution. 🙂

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [March 4, 2024, 9:41pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/4 "2024-03-04T21:41:49Z")

</div>

> [@Rick\_UpperPark](#):
>
> See LINE in the help and SETPENSTYLE. This is not the LINE control but the LINE(x,y,w,h) drawing command.

Ahhhh… this is where you use `SETTARGET( Report , Band ) ` to specify the Report Detail Band onto which you draw with graphics Line(), Ellipse(), Box(), etc.

What I would do is put a normal LINE control on the Report. Then use code like below to put the Graphic Line() in the Position of the Line Control, which you hide:

```Clarion
    SETTARGET(Report,?DetailWithLine) !Must have , ?Detail Band FEQ
    GETPOSITION(?Line1,X#,Y#,W#,H#) !Line1 Control Position
    HIDE(?Line1) !Hide to put Dotted line on top
    SETPENSTYLE(PEN:dot)     
    Line(X#,Y# + 0,W#,H#) !on top of Line 1
    PRINT(Rpt:DetailWithLine)

```

Here’s the output of my test showing the Detail with LINE, then the same with Dot, Dash and Dot+Dash lines:

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/a/a3961448b5a740b49cc6c3788ce48726eb1f0756.png)

Test Report Project Code:

```Clarion
    PROGRAM !Report Test Framework. Get more tests from https://gist.github.com/CarlTBarnes/29f78a2ca43813e83489dc62a4d5e0c0
    MAP
    END

PreviewQ QUEUE,PRE(PreQ)
FileName STRING(260)
    END

    !>>>--Define your Report with ,PREVIEW(PreviewQ) attribute
Report REPORT,AT(1000,2000,6000,7000),FONT('Arial',10),PRE(RPT),PREVIEW(PreviewQ), |
            THOUS
        HEADER,AT(1000,1000,6000,1000),USE(?HEADER1)
            STRING('Report Test for LINE SetPenStype'),AT(208,94),USE(?STRING1),TRN
        END
DetailWithLine DETAIL,AT(0,0,6000,800),USE(?DetailWithLine)
            STRING('Detail with LINE'),AT(83,10,1229,146),USE(?DetailIsWhat),TRN,FONT(,8)
            LINE,AT(1094,83,4000,0),USE(?LINE1),LINEWIDTH(3)
        END
        FOOTER,AT(1000,9000,6000,1000),USE(?unnamed)
        END
    END

    CODE
    OPEN(Report)
    PRINT(Rpt:DetailWithLine) !Print without drawing 
    
    SETTARGET(Report,?DetailWithLine) !Must have , ?Detail Band FEQ
    GETPOSITION(?Line1,X#,Y#,W#,H#) !Line1 Control Position
    ?DetailIsWhat{PROP:Text}='Graphic Line()'
    HIDE(?Line1) !Hide to put Dotted line on top
    SETPENCOLOR(Color:Red) ; SETPENSTYLE(PEN:dot) ; Line(X#,Y# + 0,W#,H#)
    SETPENCOLOR(Color:Blue) ; SETPENSTYLE(PEN:dash) ; Line(X#,Y# + 100,W#,H#)
    SETPENCOLOR(Color:Green) ; SETPENSTYLE(PEN:DashDot) ; Line(X#,Y# + 200,W#,H#)

!Edit 3/5/24 with 2 other styles
    SETPENCOLOR(Color:Orange) ; SETPENSTYLE(PEN:dashdotdot) ; Line(X#,Y# + 350,W#,H#) !New 
    SETPENCOLOR(Color:Olive) ; SETPENSTYLE(PEN:solid) ; Line(X#,Y# + 450,W#,H#) !New 
    
    SETPENWIDTH(10) ! PenWidth >=10 sets back to Solid PenStyle, no way to do thick dash lines, maybe with multiple adjusting Y a little
    SETPENCOLOR(Color:Purple) ; SETPENSTYLE(PEN:Dash) ; Line(X#,Y# + 700,W#,H#)
    
    PRINT(Rpt:DetailWithLine)
    
    ENDPAGE(Report)

    !--Preview the report
    DO ReportPreviewRtn
    CLOSE(Report)

!----------------- Open Preview Window and display --------------------------
ReportPreviewRtn ROUTINE     
    DATA
PreviewWindow WINDOW('Preview'),AT(,,495,332),FONT('MS Sans Serif',8,,FONT:regular),SYSTEM,MAX,RESIZE
       LIST,AT(1,2,245,11),USE(?List:PreviewQ),DROP(10),FROM(PreviewQ),VScroll,FONT(,10)
       IMAGE,AT(1,15),USE(?Image1),FULL ,hvscroll
     END
    CODE
    
    OPEN(PreviewWindow)
    ?List:PreviewQ{PROP:Selected}=1
    ACCEPT
        IF ACCEPTED()=?List:PreviewQ OR EVENT()=Event:OpenWindow
           GET(PreviewQ,CHOICE(?List:PreviewQ))
           ?Image1{PROP:Text}=PreviewQ
           DISPLAY
        END
    END
    CLOSE(PreviewWindow)

```

SETPENWIDTH() seems to prevent Pen Style.

---

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [March 5, 2024, 5:55am UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/5 "2024-03-05T05:55:44Z")

</div>

Thanks ! This method also works in windows. 🙂

 ![1](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/b/b1fae39d1a4e420a2e40f6a8523bd52bb946d79b.jpeg)

---

<div class="post-metadata">

**Author:** ![Flavio\_Suarez](https://clarionhub.com/user_avatar/clarionhub.com/flavio_suarez/32/1347_2.png) [@Flavio\_Suarez](https://clarionhub.com/u/Flavio_Suarez)\
**Post date:** [March 5, 2024, 12:28pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/6 "2024-03-05T12:28:07Z")

</div>

20+ years using Clarion and still learning something new!!  
I’d like to have found ClarionHub before!

Thanks Carl and all the community!

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [March 5, 2024, 4:42pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/7 "2024-03-05T16:42:20Z")

</div>

Depending on what you’re doing, maybe the api call DrawFocusRect() could be useful (on windows only, probably). [DrawFocusRect function (winuser.h) - Win32 apps | Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-drawfocusrect)

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [March 5, 2024, 5:00pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/8 "2024-03-05T17:00:11Z")

</div>

2 styles that I missed in my example … “Dash Dot Dot” was not in the Help for SetPenStyle(), maybe it was not in Win 3.1. Also Solid that is a Normal line, so that’s a way to change back to Solid after using Dot or Dash:

```Clarion
PEN:solid EQUATE (0)
PEN:dashdotdot EQUATE (4)    

    SETPENCOLOR(Color:Orange) ; SETPENSTYLE(PEN:dashdotdot) ; Line(X#,Y# + 350,W#,H#) !New 
    SETPENCOLOR(Color:Olive) ; SETPENSTYLE(PEN:solid) ; Line(X#,Y# + 450,W#,H#) !New 

```

This screen shot the bottom 2 are Dash Dot Dot colored Orange and Solid in Olive:

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/3/369cfee2ebf96ce6ca053991ed7458fd072d1696.png)

I’ll adjust my original code above.

* * *

I am troubled that SETPENWIDTH(10) changes Dot Style to a Solid line. I tested further and found widths 1 to 9 did not change Style, but also did not make it any thicker.

Looking at Windows API [CreatePen()](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createpen) on MSDN it says the below which concurs that Width greater than 1 will reset Dots / Dashes to Solid.

> **CreatePen** returns a pen with the specified width but with the PS\_SOLID style if you specify a width greater than one for the following styles: PS\_DASH, PS\_DOT, PS\_DASHDOT, PS\_DASHDOTDOT.

So it seems you cannot have thicker width Dashed Lines. Maybe you could lay down multiple Dashed Lines with the Y value adjusted down a little.

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [March 5, 2024, 9:02pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/9 "2024-03-05T21:02:32Z")

</div>

> [@CarlBarnes](#):
>
> So it seems you cannot have thicker width Dashed Lines. Maybe you could lay down multiple Dashed Lines with the Y value adjusted down a little.

I tested this code that prints 5 Dash / Dot lines spaced 10 THOUS to make it look like one thick line on the Report:

```Clarion
    ?DetailIsWhat{PROP:Text}='Thick Dashed'
    SETPENCOLOR(Color:Blue) ; SETPENSTYLE(PEN:dash)    
    Line(X#,Y# + 000,W#,H#) !Normal Dashed line, not thick
    LOOP I#=0 TO 40 BY 10 !I# writes 5 spaced 10 on Y axis
        SETPENCOLOR(Color:Red) ; SETPENSTYLE(PEN:dash)
        Line(X#,Y# + 100 + I#,W#,H#) 
        SETPENCOLOR(Color:Orange) ; SETPENSTYLE(PEN:dot) 
        Line(X#,Y# + 200 + I#,W#,H#)
    END
    PRINT(Rpt:DetailWithLine)

```

![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/d/d68ce5941ca660f0f78b2782f7d6173839fe1e62.png)

The above is 5 lines, below is 3 lines (`LOOP I#=0 TO 20 BY 10 `) which seems thick enough to me:

![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/1/1a97963c35269df2e825970f18ea1e27e36c9a99.png)

---

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [March 6, 2024, 5:07am UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/10 "2024-03-06T05:07:22Z")

</div>

Interesting effects when drawing on the screen. 🙂

 ![1](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/c/c81a6526fd4513535833e3430e9ab76224306462.jpeg)

---

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [March 6, 2024, 6:19am UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/11 "2024-03-06T06:19:18Z")

</div>

I looked at Carl’s algorithm carefully. 😉 Screen:

 ![1](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/d/d6c8ef251f810ce6706a8a336b3e7b17e2800bb7.jpeg)

Report:

 ![2](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/c/c38b739d359dfcf2d43b1ed19838cac9b1b25468.jpeg)

Thanks for the help ! 🙂

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [March 25, 2024, 10:43pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/12 "2024-03-25T22:43:33Z")

</div>

I made a Procedure to wrap making a Report Line output as a Dot / Dash Line. It makes it easy to do before printing one Detail with a Line like this with one call:

```clarion
 ReportLineSetAsDots(Report, ?CheckTotalLine, ?CheckTotal_UnderLine, PEN:dot) !<-- this
 Print(RPT:CheckTotalLine) 
 Report$?CheckTotal_UnderLine{PROP:Hide}=False !Optional if want to use LINE control

```

For a Report Detail like below with a LINE:

```clarion
CheckTotalLine DETAIL,AT(0,0,7500,187),USE(?CheckTotalLine)
   STRING('CHECK TOTAL:'),AT(4625,0),USE(?TotalCheckLit),TRN
   LINE,AT(0,167,7500,0),USE(?CheckTotal_UnderLine),COLOR(COLOR:Black)

```

Report preview showing Dotted Lines under CHECK TOTAL:

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/3/30ee699fb340d8a51ce1a5b368d26d143c928e7d.png)

* * *

The procedures that wrap creating a Dot or Dash line:

```clarion
 MAP
   ReportLineSetAsDots (*REPORT RptRef, LONG DetailFEQ, LONG LineFEQ, LONG PEN_Style=PEN:Dot , LONG PEN_Color=-1)
   ReportLineSetAsDashed(*REPORT RptRef, LONG DetailFEQ, LONG LineFEQ, LONG PEN_Style=PEN:Dash, LONG PEN_Color=-1)

```

```clarion
ReportLineSetAsDashed PROCEDURE(*REPORT RptRef, LONG DetailFEQ, LONG LineFEQ, LONG PEN_Style=PEN:Dash, LONG PEN_Color=-1)
    CODE !FYI :the PEN Style Prototype Default is PEN:Dash
    ReportLineSetAsDots(RptRef, DetailFEQ, LineFEQ, PEN_Style,PEN_Color)  
    RETURN
!------------------
ReportLineSetAsDots PROCEDURE(*REPORT RptRef, LONG DetailFEQ, LONG LineFEQ, LONG PEN_Style=PEN:Dot, LONG PEN_Color=-1)
XLn LONG,AUTO
YLn LONG,AUTO
WLn LONG,AUTO
HLn LONG,AUTO
Orig_Target_Prop LONG,AUTO !Original SetTarget()
Orig_Target_Ref &WINDOW !Also a &REPORT
    CODE 
    IF PEN_Style = PEN:Solid THEN !Passing SOLID Pen means to Unhide the Line
       RptRef$(LineFEQ){PROP:Hide} = FALSE !Unhide the LINE
       RETURN 
    END

    Orig_Target_Prop = SYSTEM{PROP:Target}
    IF Orig_Target_Prop THEN !I would expect this to always be <> Zero 
       Orig_Target_Ref &= (Orig_Target_Prop)
    END

    SETTARGET(RptRef,DetailFEQ) !To Draw Line must SetTarget(Report,Band)
    GETPOSITION(LineFEQ,XLn,YLn,WLn,HLn) !Original Line Control Position
    HIDE(LineFEQ) !Hide to put Dashed line on top
    SETPENSTYLE(PEN_Style) !Set to passed Dash Dot etc 
    IF PEN_Color <> COLOR:None THEN 
       SETPENCOLOR(PEN_Color)
    END
    Line(XLn,YLn + 0,WLn,HLn) !Draw Line on top of existing Line Control
    
    IF Orig_Target_Prop THEN !Restore to TARGET() before called
       SETTARGET(Orig_Target_Ref) !bug that does not restore (Rpt,?Band)
    ELSE 
       SETTARGET() !Should never happen, if it does restore to WINDOW 
    END
    RETURN 

!How this works:
! A Report LINE,AT(x,y) Control can only be Solid. 
! A Draw LINE(x,y,..) Graphic can use any PENSTYLE Dot Dash DashDot DashDotDot.
! This works by HIDE() the LINE Control, then draws a graphic LINE() at the X,Y,W,H of the LINE control GetPosition
! You must Unhide the LINE Control if you want to use it normally i.e. not Dotted. You can call this with Style as SOLID to do that
! The graphic LINE() only exists for one PRINT() then is cleared AFAIK
! This code is careful to try to preserve if there's a SetTarget(Report) current

```

---

<div class="post-metadata">

**Author:** ![Genricke](https://clarionhub.com/user_avatar/clarionhub.com/genricke/32/5271_2.png) [@Genricke](https://clarionhub.com/u/Genricke)\
**Post date:** [March 26, 2024, 5:21am UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/13 "2024-03-26T05:21:15Z")

</div>

Interestingly, the lines made by Line(…) they are always drawn on top of objects made by Create(…), including Create(0,Create:Line) …

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [March 26, 2024, 3:50pm UTC](https://clarionhub.com/t/how-to-print-a-dotted-or-dashed-line-on-a-report/7022/14 "2024-03-26T15:50:59Z")

</div>

I just noticed in the Help there are functions to get the current PEN values so they can be saved and restored as shown in this help code:

```auto
ColorNow LONG
StyleNow LONG
WidthNow LONG
  CODE
  ColorNow = PENCOLOR() !Get current pen color
  StyleNow = PENSTYLE() !Get current pen style
  WidthNow = PENWIDTH() !Get current pen width
  OPEN(MDIChild2)
  SETPENCOLOR(ColorNow) !Set same pen color
  SETPENSTYLE(StyleNow) !Set same pen style
  SETPENWIDTH(WidthNow) !Set same pen width

```

I’ll add this to my Dotted Line procedure to so the possible side effects are zero.
