The WR INSERT HYPERLINK command inserts a “hyperlink” reference within area, at the current cursor location or in place of the current text selection.
linkType
The linkType parameter defines the type of hypertext link to insert. 4D Write allows for three types of hypertext links: Method type links, URL type links, and Document type links.
- A Method type link executes a 4D method once the reference has been clicked. The method cannot be a function and it is not possible to pass parameters. However, it can receive two or three values in $1, $2, and, optionally $3:
- $1 (Longint) contains the 4D Write area reference,
- $2 (Text) contains the link label,
- $3 (Longint) contains an arbitrary numeric value that you can associate with a link using the methodRef parameter or via the user interface of the database.
In light of the database compiling, it is necessary to declare $1 and $3 as Longints and $2 as Text even if you do not use them.
To insert a Method type link, put 0 in linkType.
- A URL type link opens the default browser and accesses a specific URL defined within the linkContent parameter. To insert a URL type link, put 1 in linkType.
- A Document type link replaces, once the link has been clicked, the current document by another document whose path was set in the linkContent parameter. Of course, the format of the document to be opened must be recognized by 4D Write. To insert a Document type link, put 2 in linkType.
In the linkType parameter, pass one of the following constants, found in the "WR Parameters" theme:
Constant |
Type |
Value |
Comment |
wr method type link |
Longint |
0 |
Inserts a Method type link |
wr URL type link |
Longint |
1 |
Inserts a URL type link |
wr document type link |
Longint |
2 |
Inserts a Document type link |
urlStyle:
The urlStyle parameter allows you to define the appearance of the inserted hypertext link. In this parameter, you can pass one of the following constants, found in the "WR Parameters" theme:
Constant |
Type |
Value |
Comment |
wr custom link appearance |
Longint |
0 |
Allows the use of a customized appearance. In this case, you can select the link and define the style using the WR SET TEXT PROPERTY command. |
wr default link appearance |
Longint |
1 |
Keeps the default hyperlink appearance (blue and underlined). Default colors can be modified programmatically, using the WR SET DOC PROPERTY command. |
If you use the constant wr custom link appearance and do not set any link style, the link will appear as current text (it will not be graphicallymaterialised).
linkLabel:
The linkLabel parameter sets the link’s visible text (in View/Values mode).
linkContent:
The linkContent parameter contains the hypertext link value. The nature of this value depends on the type of link:
- For a 4D Method type link, put the name of the method (for example “Order_Clients”),
- For an URL type link, put the complete URL (for example “http://www.4D.com/”)
- For a Document type link, put the full path to the document (for example, “C:\MyFolder\MyDoc.4w7” under Windows, or “HardDrive:MyFolder:MyDoc” under Mac OS).
methodRef:
The methodRef parameter allows you, when the link is a 4D method type, to add a supplementary value to the called method. The method will receive this value in the $3 parameter (Longint type).
You want to insert the URL of your Web site in the 4D Write area:
In your 4D Write documents, you want to provide hypertext navigation based on document type links. The following method manages pathnames dynamically, whatever the platform:
$Doc:=Structure file
Doc:=$Doc
While(Position(":";$Doc)#0)
$Doc:=Substring($Doc;1+Position(":";$Doc);Length($Doc))
$Long:=Length($Doc)
End while
Doc:=Substring(Doc;1;Length(Doc)-$Long)
PLATFORM PROPERTIES($Platf;$Syst;$Computer)
If($Platf=Windows)
$name:=Doc+"Documentation"+"/"+"01_Introduction.4W7"
Else
$name:=Doc+"Documentation"+":"+"01_Introduction.4W7"
End if
$title:="See Documentation"
WR INSERT HYPERLINK(Writearea;wr document type link;wr default link appearance;$title;$name)
This example illustrates method type links. In your document, you want the user to be able to enter information, for example his/her name and first name in a particular place. You will insert a hyperlink calling a method named Hyperlink_Method. This method asks the user to enter either her/his name or first name, depending on the value passed in $3. The entered data will then replace the link:
Inserting the method type hyperlink in the 4D Write area: