Mendefinisikan Kondisi
Conditions are logical expressions that you can use to control the display of fields and sections in your document. Although the following examples apply to fields, they also apply to sections.
You can define conditions for the following field types:
-
Conditional text: displays text A if the condition is true, or text B if the condition is false.
-
Hidden text: hides the contents of the field if the condition is true.
-
Hidden paragraph: hides the paragraph if the condition is true.
-
Any record and next record: controls the access to database records.
The simplest way to define a condition is to type the logical expression directly in a Condition box using the following values:
TRUE |
The condition is always met. You can also enter any value not equal to 0 as the conditional text. |
FALSE |
The condition is not met. You can also enter the value 0. |

If you leave the Condition box empty, the condition is interpreted as not being met.
When you define a condition, use the same elements for defining a formula, namely comparative operators, mathematical and statistical functions, number formats, variables and constants.
You can use the following types of variables when you define a condition:
-
Predefined LibreOffice variables that use statistics on document properties
-
Custom variables, that are a created with the "Set variable" field
-
Variabel yang didasarkan pada data pengguna
-
Hanya ijinkan baca berdasarkan aksi pada basis data
You cannot use internal variables, such as page and chapter numbers, in condition expression.
Kondisi dan Variabel
Gunakan daftar tugas berikut bila tersedia:
x == 1 atau x EQ 1 |
Isi dengan TRUE bila peran adalah suatu superuser basis data |
x != 1 atau x NEQ 1 |
Isi dengan TRUE bila peran adalah suatu superuser basis data |
sinx == 0 |
TRUE bila pencetak ini diistirahatkan |
To use comparative operators with strings, the operands must be bounded by double quotation marks:
x == "ABC" atau x EQ "ABC" |
Checks if variable "x" contains (true) the "ABC" string, or not (false). |
x == "" atau x EQ "" atau !x atau NOT x |
Checks if the variable "x" contains an empty string. |

The "equal" comparative operator must be represented by two equal signs (==) in a condition. For example, if you define a variable "x" with the value of 1, you can enter the condition as x==1.
Data Pengguna
You can include user data when you define conditions. To change your user data, choose LibreOffice - PreferencesTools - Options - LibreOffice - User data. User data must be entered in the form of strings. You can query the user data with "==" (EQ), "!=" (NEQ), or "!"(NOT).
The following table lists user data variables and their meanings:
Variabel |
Arti |
user_firstname |
Nama depan |
user_lastname |
Nama belakang |
user_initials |
Inisial |
user_company |
Perusahaan |
user_street |
Jalan |
user_country |
Negara |
user_zipcode |
Kode pos |
user_city |
Kota |
user_title |
Judul |
user_position |
Posisi |
user_tel_work |
Nomor telepon bisnis |
user_tel_home |
Nomor telepeon rumah |
user_fax |
Nomor faksimili |
user_email |
Alamat e-mail |
user_state |
Negara bagian (tidak dalam semua versi LibreOffice) |
For example, to hide a paragraph, text, or a section from a user with a specific initial, such as "LM", enter the condition: user_initials=="LM".
Kondisi dan Bidang Isian Basis Data
You can define conditions for accessing databases, or database fields. For example, you can check the contents of a database field from a condition, or use database fields in logical expressions. The following table lists a few more examples of using databases in conditions:
Contoh |
Arti |
Database.Table.Company Database.Table.Company NEQ "" Database.Table.Company != "" |
The condition is true if the COMPANY field is not empty. (In the first example, no operator is required.) |
!Database.Table.Company NOT Database.Table.Company Database.Table.Company EQ "" Database.Table.Company =="" |
Returns TRUE if the COMPANY field is empty. |
Database.Table.Company =="" Database.Table.Company NEQ "" |
Returns TRUE if the current entry in the COMPANY field is not "Sun". (Exclamation sign represents a logical NOT.) |
Database.Table.Firstname AND Database.Table.Name |
Returns TRUE if the record contains the first and the last name. |

Note the difference between the boolean NOT "!" and the comparative operator not equal "!=" (NEQ).
When you refer to a database field in a condition, use the form Databasename.Tablename.Fieldname. If one of the names contains a character that is an operator, such as a minus sign (-), enclose the name in square brackets, for example, Databasename.[Table-name].Fieldname. Never use spaces inside field names.
Ruas path folder kosong.
You may want to create a condition that hides an empty field, for example, if the COMPANY field is empty for some of the data records.
Select the Hidden Paragraph list entry, and type the following condition: Addressbook.Addresses.Company EQ ""
atau ketik berikut
NOT Addressbook.Addresses.Company
If the COMPANY database field is empty, the condition is true and the paragraph is hidden.

To display hidden paragraphs on the screen, you can choose LibreOffice - PreferencesTools - Options - LibreOffice Writer - Formatting Aids, and clear the Fields: Hidden paragraphs check box.
Ruas dalam foreign key
The following examples use the Conditional text field, although they can be applied to any fields that can be linked to a condition. The syntax used for conditions is also used for the Hidden text, Hidden paragraph, Any record or Next record fields.
To display conditional text based on the number of pages:
-
Choose Insert - Field - More Fields, and then click the Functions tab.
-
Dalam daftar Tipe, klik "Teks bersyarat".
-
In the Condition box, type "page == 1".
-
In the Then box, type "There is only one page".
-
In the Or box, type "There are several pages".
-
Klik Sisip, lalu klik Tutup.
To display conditional text based on a user-defined Variable
-
Choose Insert - Field - More Fields, and then click the Variables tab.
-
In the Type list, click "Set Variable".
-
In the Name box, type "Profit".
-
In the Value box, type "5000".
-
Klik Sisip.
-
Click the Functions tab, and click "Conditional text" in the Type list.
-
In the Condition box, type "Profit < 5000".
-
In the Then box, type "Target is not met".
-
In the Or box, type "Target is met".
-
Klik Sisip.
To edit the contents of the "Profit" variable, double-click the variable field.
To display conditional text based on the contents of a database field:
The first part of this example inserts a space between the "First Name" and "Last Name" fields in a document, and the second part inserts text based on the contents of a field. This example requires that an address data source is registered with LibreOffice.
-
Choose Insert - Field - More Fields, and then click the Database tab.
-
In the Type list, click "Mail merge fields".
-
In the Database selection box, double-click an address book, click "First Name", and then click Insert. Repeat for "Last Name".
-
In the document, place the cursor between the two fields, press Space, and then return to the Fields dialog:
-
Click the Functions tab, and then click "Conditional text" in the Type list.
-
In the Condition box, type: "Addressbook.addresses.firstname".
-
In the Then box, type a space and leave the Or box blank.
You can now use a condition to insert text based on the contents of the First Name field.
-
In the Fields dialog, click the Functions tab.
-
Dalam kotak Tipe , klik "Teks bersyarat".
-
In the Condition box, type: Addressbook.addresses.firstname == "Michael"
-
In the Then box, type "Dear".
-
In the Else box, type "Hello".
-
Klik Sisip.