4D v16.3

ST INSERT URL

Home

 
4D v16.3
ST INSERT URL

ST INSERT URL 


 

ST INSERT URL ( {* ;} object ; urlText ; urlAddress {; startSel {; endSel}} ) 
Parameter Type   Description
Operator in If specified, object is an object name (string) If omitted, object is a field or variable
object  Form object in Object name (if * is specified) or Field or variable (if * is omitted)
urlText  Text in Visible text of URL
urlAddress  Text in URL address
startSel  Longint in Start of selection
endSel  Longint in End of selection

The ST INSERT URL command inserts a URL link in the styled text field or variable designated by the object parameter.

Passing the optional * parameter indicates that the object parameter is an object name (string). If you do not pass this parameter, it indicates that the object parameter is a field or variable. In this case, you pass a field or variable reference instead of a string (field or variable object only).

In the urlText parameter, pass the visible text of the URL, as it should appear in the object. For example, text labels such as "4D Web Site" or "Follow this link for more information" can be used. You can also use the address itself, for instance "http://www.4d.com".

In the urlAddress parameter, pass the complete address you want the browser page to connect to, for example "http://www.4D.com".

The optional startSel and endSel parameters designate a selection of text in object. The startSel and endSel values express a plain text selection, without taking into account any style tags that may be present. 

  • If you only pass startSel, urlText is inserted at the specified location.
  • If you omit startSel and endSel, urlText is inserted at the location of the cursor.
  • If you pass startSel and endSel, ST INSERT URL replaces the text in this selection with the urlText. If the value of endSel is greater than the total number of characters in the object, all the characters between startSel and the end of the text are replaced with the urlText.

4D provides predefined constants so that you can designate the selection limits automatically in the startSel and endSel parameters. These constants are found in the "Multistyle Text" theme: 

Constant Type Value Comment
ST End highlight Longint -1001 Designates last character of current text selection in object (*)
ST End text Longint 0 Designates last character of text contained in object
ST Start highlight Longint -1000 Designates first character of current text selection in object (*)
ST Start text Longint 1 Designates first character of text contained in object

(*) You must pass an object name in object to be able to use this constant. If you pass a reference to a field or variable, the command is applied to all the text of the object.

Note: If startSel is greater than endSel (except when endSel is 0), the command does nothing and the OK variable is set to 0.

Once the link is inserted, it is active: using Ctrl+click (Windows) or Command+click (OS X) on its label opens a page of the default browser at the address specified in the urlAddress parameter.

Example  

You want to insert a link to the 4D Web site to replace the text selected in the object:

 vTitle:="4D Web Site"
 vURL:="http://www.4d.com/"
 ST INSERT URL(*;"myText";vTitle;vURL;ST Start highlight;ST End highlight)



See also 

ST GET URL
ST INSERT EXPRESSION

 
PROPERTIES 

Product: 4D
Theme: Styled Text
Number: 1280

The OK variable is changed by the command

 
HISTORY 

Created: 4D v14

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)