4D Write Pro Programmable Margins?

I’m perplexed by the behavior of margins in Write Pro 17R4 and 17R5.

If I display a Write Pro document in a form and set the margins under program control (i.e. in a button object method WP SET ATTRIBUTES(MyWPArea;wk page margin left;".75in")) the ruler will change, as expected, to show the left margin at .75 inches.

I can then adjust the margins manually, by dragging them in either the horizontal or vertical ruler. However, if I try to to “Reset” the left margin back to .75in by executing the button object method again, there is no effect. The margins do not change. It is as if adjusting the margin manually causes the rulers to be ‘locked’ from being set by code.

Is this expected behavior?

Thanks,

Tom Benedict

Hello Tom

When you write the following code, you define the default value for margins of all sections of your document (only one section at this point)

<code 4D>
WParea:=WP New
WP SET ATTRIBUTES(WParea;wk page margin left;".75in")

</code 4D>
If you adjust the margin(s) manually, you adjust the margin(s) of section one (unless you have created more sections and the cursor is located in another one)

So, if you want to modify the margins again, you have to specify the section “1” and apply margins to it.

<code 4D>
$section:=WP Get section(WParea;1)
WP SET ATTRIBUTES($section;wk page margin left;".75in")

</code 4D>

If you want to modify the margins of all sections by code you have to loop

<code 4D>
C_COLLECTION($sections)
C_OBJECT($section)

$sections:=WP Get sections(WParea)
For each ($section;$sections)
WP SET ATTRIBUTES($section;wk page margin left;".75in")
End for each

</code 4D>

Try the following code to init your area and look what happens…

<code 4D>
WParea:=WP New
WP SET ATTRIBUTES(WParea;wk page margin left;".75in")
WP INSERT BREAK(WParea;wk section break;wk append)
WP INSERT BREAK(WParea;wk section break;wk append)
WP INSERT BREAK(WParea;wk section break;wk append)

</code 4D>
Three sections will be created; all of them will have “.75in” margins. When you will modify the margins manually, only one of the will be modified (even if you select all the document before modification)

Hope this helps !

Roland Lannuzel

Thanks for the response Roland.

I have to start thinking more in ranges and sections.

This resolves my issue.

Tom Benedict