4D Write v14

WR INSERT HYPERLINK

Home

 
4D Write v14
WR INSERT HYPERLINK

WR INSERT HYPERLINK 


 

WR INSERT HYPERLINK ( area ; linkType ; urlStyle ; linkLabel ; linkContent ; methodRef ) 
Parameter Type   Description
area  Longint in 4D Write area
linkType  Integer in Hyperlink type: 0 = Method, 1 = URL, 2 = 4D Write Document
urlStyle  Integer in URL appearance: 1 = Default style, 0 = Custom style
linkLabel  Text in Link’s visible text (View/Values mode)
linkContent  Text in Hyperlink value
methodRef  Longint in Value for $3, 3rd parameter of the method (if the link type is Method)

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:

 WR INSERT HYPERLINK(area;wr URL type link;wr default link appearance;"Visit that great site";"http:/www.MySite.com/")

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:

  `Hyperlink_Method
 C_LONGINT($1;$3)
 C_TEXT($2)
 Case of
    :($3=1)
       WR INSERT TEXT($1;Request("Enter your first name"))
    :($3=2)
       WR INSERT TEXT($1;Request("Enter your last name"))
 End case
 WR GET SELECTION($1;$deb;$end)
 WR SET SELECTION($1;$deb;$end+1)
 WR EXECUTE COMMAND($1;wr cmd clear)

Inserting the method type hyperlink in the 4D Write area:

 $title:="Click to enter"
 $method:="Hyperlink_Method"
 WR INSERT TEXT(Area;"Last name: ")
 WR INSERT HYPERLINK(Area;wr method type link;wr default link appearance;$title;$method;1)
 WR INSERT TEXT(Area;Char(Carriage return)+"First name: ")
 WR INSERT HYPERLINK(Area;wr method type link;wr default link appearance;"Click to enter";"Hyperlink_Method";2)

 
PROPERTIES 

Product: 4D Write
Theme: WR Database Objects
Number: 89430

 
HISTORY 

Created: 4D Write 6.7

 
SEE ALSO 

WR GET HYPERLINK

 
ARTICLE USAGE

4D Write Language ( 4D Write v11.6)
4D Write Language ( 4D Write v12)
4D Write Language ( 4D Write v14)
4D Write Language ( 4D v13)
4D Write Language ( 4D Write v14 R2)
4D Write Language ( 4D Write v14 R3)
4D Write Language ( 4D Write v14 R4)