Skip to content
82 changes: 81 additions & 1 deletion docs/FormObjects/properties_Text.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ This property enables the possibility of using [specific styles](https://doc.4d.

By default, this option is not enabled.


#### JSON Grammar

|Name|Data Type|Possible Values|
Expand All @@ -439,7 +440,86 @@ By default, this option is not enabled.

#### Commands

[LISTBOX Get property](../commands/listbox-get-property) - [LISTBOX SET PROPERTY](../commands/listbox-set-property) - [OBJECT Is styled text](../commands/object-is-styled-text) -
[LISTBOX Get property](../commands/listbox-get-property) - [LISTBOX SET PROPERTY](../commands/listbox-set-property) - [OBJECT Is styled text](../commands/object-is-styled-text)

### Supported tags

You can use the following tags in 4D multi-style text areas.

#### 4D Expression

```html
<span style="-d4-ref:'expression'"> </span>
```

This tag inserts a 4D expression (expression, method, field, variable, command, etc.) in the text. The expression is tokenized and evaluated:

- when the expression is inserted
- when the object is loaded
- when the `computeExpressions` standard action is called from an interface object or by the [`INVOKE ACTION`](../commands/invoke-action) command
- when the [`ST COMPUTE EXPRESSIONS`](../commands/st-compute-expressions) command is executed
- when the [`ST FREEZE EXPRESSIONS`](../commands/st-freeze-expressions) command is executed, if the second `*` parameter is passed.

The evaluated value of the expression is not saved in the `<span>` tag, only its reference is.

Note: To ensure that expressions will be evaluated correctly regardless of the 4D language or version used, we recommend using the token syntax for elements whose name might vary between different versions (commands, tables, fields, constants). For example, to insert the `Current time` command, enter `Current time:C178`. For more information about this, refer to *Using tokens in formulas*.

#### URL

```html
<span><a href="url">Visible label</a></span>
```

This tag inserts a URL in the text. Example:

```html
<span><a href="http://www.4d.com/">4D Web Site</a></span>
```

#### User link

```html
<span style="-d4-ref-user:'myUserLink'">Click here</span>
```

"User links" look the same as URLs, but when you click them, they do not automatically open the source. You can pass any string you want as reference, and it is up to the developer to program any custom actions that occur when it is clicked. This means you can create links which are not URLs but references to files, 4D methods, and so on, that you can open or execute when they are clicked. The [`ST Get content type`](../commands/st-get-content-type) command detects if a user link has been clicked.

User links are defined using the [`ST SET TEXT`](../commands/st-set-text) command. For example:

```4d
ST SET TEXT(txtVar;"This is a user link: <span style=\"-d4-ref-user:'UserLink'\">User Label</span>";$start;$end)
```

#### Custom tags

You can insert any tag in plain text, for example `<img src="http://doc.4d.com/pictures/ja.png">`. It is stored in the code of the plain text without being interpreted or displayed. This is particularly useful in the context of e-mails in HTML format and including pictures for example.

#### Style tags

This paragraph lists the attributes of \<SPAN> tags that are supported by 4D in rich text areas. You can use these tags to implement custom style handling. Only the tags listed below are supported by 4D for style variations.

- Font name: `<SPAN STYLE="font-family: DESDEMONA"> ... </SPAN>`
- Font size: `<SPAN STYLE="font-size: 20pt"> ... </SPAN>`
- Font style:
- Bold `<SPAN STYLE="font-weight: bold"> ... </SPAN>`
- Italic `<SPAN STYLE="font-style: italic"> ... </SPAN>`
- Normal `<SPAN STYLE="font-style: normal"> ... </SPAN>`
- Underline `<SPAN STYLE="text-decoration: underline"> ... </SPAN>`
- Strikethrough `<SPAN STYLE="text-decoration:line-through">...</SPAN>`

*Note: The "strikethrough" style is not supported under macOS, but this tag can still be managed by programming.*

- Font colors: `<SPAN STYLE="color:green"> ... </SPAN>` or `<SPAN STYLE="color:#006CCC">...</SPAN>`
- Background colors: `<SPAN STYLE="background-color:green"> ... </SPAN>` or `<SPAN STYLE="background-color:#006CCC">...</SPAN>`

#### Color values

For font color and background color attributes, the color value can be either the hexadecimal code for an RGB color, or the name of one of the 16 HTML colors defined for standard CSS by the W3C:

![](../assets/en/FormObjects/colors1.png)
![](../assets/en/FormObjects/colors2.png)




---
Expand Down
Binary file added docs/assets/en/FormObjects/colors1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/en/FormObjects/colors2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/en/FormObjects/multistyle-ex1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/en/FormObjects/multistyle-ex2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/commands-legacy/on-web-connection-database-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You must declare these parameters as shown below:
```4d
  // On Web Connection Database Method

#DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ;\ $user : Text ; $pw : Text)
#DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ; $user : Text ; $pw : Text)

  // Code for the method
```
Expand Down
93 changes: 93 additions & 0 deletions docs/commands/theme/Styled_Text.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,96 @@ slug: /commands/theme/Styled-Text
|[<!-- INCLUDE #_command_.ST SET OPTIONS.Syntax -->](../../commands/st-set-options)<br/>|
|[<!-- INCLUDE #_command_.ST SET PLAIN TEXT.Syntax -->](../../commands/st-set-plain-text)<br/>|
|[<!-- INCLUDE #_command_.ST SET TEXT.Syntax -->](../../commands/st-set-text)<br/>|


## Working with text handling commands

### User interface

The commands that can be used to manipulate text objects by programming do not take any style tags integrated into the text into account. They act upon displayed text only. This concerns the following commands:

- [User Interface](./User_Interface.md) theme commands
- [`HIGHLIGHT TEXT`](../../commands/highlight-text)
- [`GET HIGHLIGHT`](../../commands/get-highlight)

When you use these commands with commands that manipulate character strings, it is necessary to filter the formatting characters using the [`ST Get plain text`](../../commands/st-get-plain-text) command:

```4d
HIGHLIGHT TEXT([Products]Notes;1;Length(ST Get plain text([Products]Notes))+1)
```

### Objects (Forms)

The commands that can be used to modify the style of objects (for example, [`OBJECT SET FONT`](../../commands/object-set-font)) apply to the whole object and not to the selection.

If the object does not have the focus when the command is executed, the modification is applied simultaneously to the object (the text area) and to its associated variable. If the object does have the focus, the modification is carried out on the object but not on the associated variable. The modification is only applied to the variable when the object loses the focus. Keep this principle in mind when programming text areas.

:::note

If the [**Store with default style tags**](../../FormObjects/properties_Text.md#store-with-default-style-tags) option is checked for the object, the use of these commands will cause a modification of the tags saved with each object.

:::


Note also that only default properties are affected by these commands (as well as any properties saved by means of default tags). Custom style tags remain as they are. For example, given a multi-style area where default tags were saved:

![](../../assets/en/FormObjects/multistyle-ex1.png)

The plain text of the area is as follows:

```html
<span style="text-align:left;font-family:'Segoe UI';font-size:9pt;color:#009900">This is the word <span style="color:#D81E05">red</span></span>
```

If you execute the following code:

```4d
OBJECT SET COLOR(*;"myArea";-(Blue+(256*Yellow)))
```

The red color remains:

![](../../assets/en/FormObjects/multistyle-ex2.png)

and code is:

```html
<span style="text-align:left;font-family:'Segoe UI';font-size:9pt;color:#0000FF">This is the word <span style="color:#D81E05">red</span></span>
```

The following commands are concerned:

- [`OBJECT SET RGB COLORS`](../../commands/object-set-rgb-colors)
- [`OBJECT SET FONT`](../../commands/object-set-font)
- [`OBJECT SET FONT STYLE`](../../commands/object-set-font-style)
- [`OBJECT SET FONT SIZE`](../../commands/object-set-font-size)

In the context of multi-style areas, such commands should be used to set default styles only. To manage styles during database execution, we recommend using the commands of the "Styled Text" theme.

### Get edited text

When it is used with a rich text area, the [`Get edited text`](../../commands/get-edited-text) command returns the text of the current area including any style tags.

To retrieve the "plain" text (text without tags) being edited, you must use the [`ST Get plain text`](../../commands/st-get-plain-text) command:

```4d
ST Get plain text(Get edited text)
```

### Query and order by commands

Queries and sorts carried out among multi-style objects take into account any style tags saved in the object. If a style modification has been made within a word, searching for the word will not be successful.

To be able to carry out valid searches and sorts, you must use the [`ST Get plain text`](../../commands/st-get-plain-text) command. For example:

```4d
QUERY BY FORMULA([MyTable];ST Get plain text([MyTable]MyFieldStyle)="very well")
```

## Automatic normalization of line endings

In order to ensure multi-platform compatibility of texts handled in the database, 4D automatically normalizes line endings so that they occupy a single character: `\r` (carriage return). This normalization is carried out at the level of form objects (variables or fields) hosting plain or multi-style text. Line endings that are not native, or that use a mix of several characters (for example `\r\n`), are considered as a single `\r`.

Note that in compliance with the XML standard (multi-style text format), the multi-style text commands also normalize line endings for text variables that are not associated with objects.

This principle makes it easier to use multi-style text commands or commands such as [`HIGHLIGHT TEXT`](../../commands/highlight-text) in a multi-platform context. However, you must take this into account in your processing when you work with texts from heterogeneous sources.
56 changes: 37 additions & 19 deletions docs/commands/theme/System_Documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,48 +67,66 @@ When it is called from a [preemptive process](../../Develop/preemptive.md), a *D

## The Document system variable

`Open document`, `Create document`, `Append document` and `Select document` enable you to access a document using the standard Open or Save file dialog boxes. When you access a document through a standard dialog, 4D returns the full pathname of the document in the [`Document` system variable](../../Concepts/variables.md#system-variables). This system variable has to be distinguished from the *document* parameter that appears in the parameter list of the commands.
[`Open document`](../../commands/open-document), [`Create document`](../../commands/create-document), [`Append document`](../../commands/append-document`) and [`Select document`](../../commands/select-document) commands enable you to access a document using the standard Open or Save file dialog boxes. When you access a document through a standard dialog, 4D returns the full pathname of the document in the [`Document` system variable](../../Concepts/variables.md#system-variables). This system variable has to be distinguished from the *document* parameter that appears in the parameter list of the commands.



## Absolute or relative pathname

Most of the routines of this section accept document names, relative pathnames or absolute pathnames:
Most of the routines of this section accept **document names**, **relative pathnames** or **absolute pathnames**.

- **Relative pathnames** define a location with respect to a folder located on disk. Passing only a document name is considered as using a relative pathname. In 4D, a relative pathname is usually expressed with respect to the [project folder](../../Project/architecture.md#project-folder), i.e. the folder containing the .project file. Relative pathnames are especially useful when deploying applications in heterogenous environments.
- **Absolute pathnames** define a location with respect to the root of the volume and so they do not depend on the current location of the project folder.

Relative pathnames define a location with respect to a folder located on disk. Passing only a document name is considered as using a relative pathname. In 4D, a relative pathname is usually expressed with respect to the database folder, i.e. the folder containing the structure file. Relative pathnames are especially useful when deploying applications in heterogenous environments.
Absolute pathnames define a location with respect to the root of the volume and so they do not depend on the current location of the database folder.
To determine whether a pathname passed to a command must be interpreted as absolute or relative, 4D applies a specific algorithm on each platform.

Windows
If the parameter contains only two characters and if the second one is a ':',
or if the text contains ':' and '\' as the second and third character,
or if the text starts with "\\",
then the pathname is absolute.
### Windows

- If the parameter contains only two characters and if the second one is a ':'
- or if the text contains ':' and '\' as the second and third character,
- or if the text starts with "\\",
- then the pathname is absolute.

In all other cases, the pathname is relative.

Examples with the CREATE FOLDER command:
Examples with the [`CREATE FOLDER`](../../commands/create-folder) command:

```4d
CREATE FOLDER("lundi") // relative path
CREATE FOLDER("\Monday") // relative path
CREATE FOLDER("\Monday\Tuesday") // relative path
CREATE FOLDER("c:") // absolute path
CREATE FOLDER("d:\Monday") // absolute path
CREATE FOLDER("\\srv-Internal\temp") // absolute path
```

:::note

The code editor of 4D allows the use of [escape sequences](../../Concepts/quick-tour.md#escape-sequences). An escape sequence begins with a backslash `\`, followed by a character. For example, `\t` is the escape sequence for the Tab character.

The `\` character is also used as the separator in pathnames in Windows. In general, 4D will correctly interpret Windows pathnames that are entered in the method editor by replacing single backslashes `\` with double backslashes `\\`. For example, `C:\Folder` will become `C:\\Folder`.

macOS
If the text starts with a folder separator ':',
or if does not contain any,
then the path is relative.
However, if you write `C:\MyDocuments\New`, 4D will display `C:\\MyDocuments\New`. In this case, the second `\` is incorrectly interpreted as `\N` (an existing escape sequence). You must therefore enter a double `\\` when you want to insert a backslash before a character that is used in one of the escape sequences recognized by 4D.

:::

### macOS

- If the text starts with a folder separator ':',
- or if does not contain any,
- then the path is relative.

In all other cases, it is absolute.

Examples with the CREATE FOLDER command:
Examples with the [`CREATE FOLDER`](../../commands/create-folder) command:

```4d

CREATE FOLDER("Monday") // relative path
CREATE FOLDER("macintosh hd:") // absolute path
CREATE FOLDER("Monday:Tuesday") // absolute path (a volume must be called Monday)
CREATE FOLDER(":Monday:Tuesday") // relative path
```

:::note

Expand All @@ -118,8 +136,8 @@ See also [**Absolute and relative pathnames** in the Concepts section](../../Con

## Extracting pathname contents

You can handle pathname contents using the Path to object and Object to path commands. In particular, using these commands, you can extract from a pathname:
You can handle pathname contents using the [`Path to object`](../../commands/path-to-object) and [`Object to path`](../../commands/object-to-path) commands. In particular, using these commands, you can extract from a pathname:

a file name,
the parent folder path,
the file or folder extension.
- a file name,
- the parent folder path,
- the file or folder extension.
7 changes: 7 additions & 0 deletions docs/commands/theme/Web_Services_Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ slug: /commands/theme/Web-Services-Client
|[<!-- INCLUDE #_command_.WEB SERVICE GET RESULT.Syntax -->](../../commands/web-service-get-result)<br/>|
|[<!-- INCLUDE #_command_.WEB SERVICE SET OPTION.Syntax -->](../../commands/web-service-set-option)<br/>|
|[<!-- INCLUDE #_command_.WEB SERVICE SET PARAMETER.Syntax -->](../../commands/web-service-set-parameter)<br/>|


A Web Service is a set of functions published on a network. These functions can be called and used by any application compatible with Web Services and connected to the network. Web Services can carry out all types of tasks, such as supervising the routing of packages at a transporter’s, e-commerce, monitoring market values, etc.

Subscription to Web Services with 4D is easy to carry out using the [Web Services Wizard](https://doc.4d.com/4Dv21/4D/21/Subscribing-to-a-Web-Service-in-4D.300-7676804.en.html). In most cases, this Wizard will be sufficient for you to be able to use Web Services. However, if you want to customize certain mechanisms, you must use the client SOAP commands of 4D.

Note: By convention, the terms “SOAP” and “Web Service” have been used to differentiate between command (and constant) names on the server and client side, respectively. These two concepts refer to the same technology.
5 changes: 5 additions & 0 deletions docs/commands/theme/Web_Services_Server.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ slug: /commands/theme/Web-Services-Server
|[<!-- INCLUDE #_command_.SOAP REJECT NEW REQUESTS.Syntax -->](../../commands/soap-reject-new-requests)<br/>|
|[<!-- INCLUDE #_command_.SOAP Request.Syntax -->](../../commands/soap-request)<br/>|
|[<!-- INCLUDE #_command_.SOAP SEND FAULT.Syntax -->](../../commands/soap-send-fault)<br/>|


Publication of Web Services with 4D is carried out easily using [options in the method properties](../../Project/project-method-properties.md#web-services). In most cases, this operation will be sufficient to enable you to publish Web Services. However, if you want to customize certain mechanisms, use data arrays, etc., you must use the server SOAP commands of 4D.

Note: By convention, the terms “SOAP” and “Web Service” have been used to differentiate between command (and constant) names on the server and client side, respectively. These two concepts refer to the same technology.
2 changes: 1 addition & 1 deletion docs/language-legacy/Web Server/web-validate-digest.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Example using *On Web Authentication Database Method* in Digest mode:

```4d
  // On Web Authentication Database Method
 #DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ;\ $user : Text ; $pw : Text) -> $result : Boolean
 #DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ; $user : Text ; $pw : Text) -> $result : Boolean
 $result:=False
 $user:=$5
  //For security reasons, refuse names containing @
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Debe declarar estos seis parámetros de esta manera:
```4d
  // Método de base On Web Connection

#DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ;\ $user : Text ; $pw : Text) -> $result : Boolean
#DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ; $user : Text ; $pw : Text) -> $result : Boolean

  // Código para el método
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Ejemplo de método de base On Web Authentication en modo Digest:

```4d
  // Método de base On Web Authentication
 #DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ;\ $user : Text ; $pw : Text) -> $result : Boolean
 #DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ; $user : Text ; $pw : Text) -> $result : Boolean

 var $usuario : Text
 var $0 : Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Debe declarar estos seis parámetros de esta manera:
```4d
  // Método de base On Web Connection

#DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ;\ $user : Text ; $pw : Text) -> $result : Boolean
#DECLARE($url : Text ; $http : Text ; $ipBrowser : Text ; $ipServer : Text ; $user : Text ; $pw : Text) -> $result : Boolean

  // Código para el método
```
Expand Down
Loading
Loading