4D v13

Inserting dynamic references

Home

 
4D Chart v13
Inserting dynamic references

Inserting dynamic references  


 

 

You can add dynamic references to field values or to 4D expressions by inserting expressions into text objects.

Using field references and 4D expressions, you can create 4D Chart documents that incorporate information from your database. For example, you can use field information from the records to make graph titles. You can use 4D expressions to perform tasks such as computing numeric values or concatenating text information.

You can display the information from 4D as either values or references. A value is the actual information stored in a field or calculated from an expression. A reference is the name of the field or the text of the expression.

When expressions and fields are displayed as references, they are surrounded by the following symbols: « and ». For example, a reference to the First Name field in the [Stationery Order] table would appear as:

«[Stationery Order]First Name»

4D Chart inserts these symbols when a field is inserted into a text object. When you insert any other type of reference, such as a 4D function or variable, you must indicate that it is a reference.

4D Chart will then add the « and » symbols to differentiate the reference from normal text. For more information on referencing expressions, see the Inserting 4D expressions section below.

When references are displayed as values, the « and » symbols do not appear; for example, a field value for First Name might be:

James

The field value appears as standard text.

Field references and 4D expressions always refer to the current record and are updated whenever the current record changes. If there is no current record, no value is displayed.

By inserting a field reference in a 4D Chart document, you add dynamic information to the document. As the field is updated, so is the value in 4D Chart. You can use fields from any table in the database.

The field reference or value appears in a text object, except for references to picture fields. The text object containing a reference acts as any other text object; you can change its attributes, move it, and so on.

When you insert a field reference in a 4D Chart plug-in window, the value that is displayed when you choose Show Values from the Database menu is the field’s value for the current record. If no record is currently loaded there will be no value displayed in the 4D Chart plug-in window. 

In order to show the value stored in a field for a particular record, make sure that the record is loaded — by displaying the record in an input form, for instance. If the current record changes, the value displayed in the field changes.

When you insert a field reference in a 4D Chart area on an input form, the value that is displayed when you choose Show Values from the Database menu is the field’s value for the current record.

To paste a field reference into a 4D Chart document, you have two tools available:

  • The Paste Field dialog box.
  • The Tables and Field pop up menu. 

To paste a field reference into a 4D Chart document using the dialog box:

  1. Click the mouse button where you want to insert the reference.
    If you click inside a text object, you cannot insert a Picture field.
  2. Choose Paste Field from the Database menu.
    The Paste Field dialog box appears. All tables in the database are listed in the Tables drop-down list. The fields for the selected table are displayed in the Fields list.
  3. Select the table from which you wish to paste a field reference from the Tables drop-down list.
    The fields in the selected table are displayed in the Fields list.
  4. Select the field you wish to paste from the Fields list and click OK.
    A reference to the field is pasted into the document in a text object.

To insert a field into a 4D Chart document using the pop-up menu:

  1. Create a text object where you want to paste the field.
    If you need information about creating text objects, see Adding text.
  2. Position the I-beam pointer ( I ) over the text object.
    Make sure that the insertion point is in the text object.
  3. To choose a field from the same table as the form, hold down the Alt key (Windows) or Option key (Macintosh) as you press the mouse button.
    A pop-up menu of fields for the table in which you are working appears. If you are working in a plug-in window, the pop-up menu contains both tables and fields.
  4. To choose a field from another table, hold down the Shift+Alt (Windows) or Shift+Option (Macintosh) keys while you press the mouse button.
    If you are working in a plug-in window, you do not need to hold down the Shift key.
    4D Chart displays a hierarchical pop-up menu of the tables in the database. Each table has a submenu containing its fields:
  5. Select a field.
    A reference to the selected field is pasted into a text object in the 4D Chart document at the insertion point location.

You cannot paste references to Picture fields when you select a field from a drop-down list. When you are working in a form, you can choose fields from a drop-down list that displays the fields in the current table, or from a drop-down list of fields for all tables in the database. When you use 4D Chart in a plug-in window, the drop-down list always contains both tables and fields.

You can insert any valid 4D expression into a document. The expression can be a 4D variable, a 4D function, a plug-in function, or a method that returns a value.

With expressions you can use the power of 4D’s language within 4D Chart documents. You can perform calculations, concatenate information from several fields, and so on.

The following table contains some examples of expressions:

ExpressionComment
vDateVariable containing a date
Current date4D function
Current date-vDateStatement that performs a calculation
DateCalcProject method that returns a value

An expression is evaluated only when you perform one of the following actions:

  • Open the document,
  • Choose Show Values from the Database menu,
  • Print the document.

To insert a 4D expression into a 4D Chart document:

  1. Create a text object where you want to place the expression.
    Since the expression is created from text, you must first create the text object.
  2. Enter the expression text and then select it.
  3. Choose Reference from the Database menu.
    The text is now enclosed in the « and » symbols, which indicate that it is an expression:
    «Current date»
  4. When you have finished, select the Arrow tool.
    To display the value of the reference, choose Show Values from the Database menu.

When you display values, you show the actual values stored in referenced fields and the values calculated by referenced 4D expressions. For example, if the reference is «Current date», today’s date is displayed.

  • To display values, choose Show Values from the Database menu. The value of each reference is displayed. The values of all references are displayed, regardless of the selected reference.
  • To display references, choose Show References from the Database menu. The reference for each value is displayed.

You can change the value in a dynamic reference into static text that will not be updated when the value changes. For instance, you can use the 4D expression «Current date» to display the date you created a graph, and then change that date to a static text object. No matter what the current date is, the text object will always display the creation date of the graph.

Changing a value to text is called unreferencing the value, because the value no longer has a dynamic reference to the database. Once you have unreferenced a value, you cannot change it back to a reference. 

To change a value in a field reference or expression to text:

  1. Choose Show Values from the Database menu to display all values.
  2. Select the text block containing the value you want to unreference.
    If the text block contains more than one field or expression, select only the value you want to change.
  3. Choose Unreference from the Database menu .
    The value becomes text.

You can change a reference into text by unreferencing it. When you change a reference to text, you change the words of the reference, not the value to which the reference refers. For instance, if you change the reference «Current date» to text, the text object displays the following:

Current date

When you choose Show Values from the Database menu, this text does not change, and the current date is not displayed, because the text no longer refers to a 4D expression.

You may want to edit a reference or permanently change it to standard text. If you want to edit a reference, you must unreference it, edit it, and then reference it again. 

To unreference a field reference or expression:

  1. Choose Show References from the Database menu to display all references.
  2. Select the text block containing the reference you want to unreference.
    If the text block contains more than one field or expression, select only the reference you want to change.
  3. Choose Unreference from the Database menu.
    The « and » symbols are removed, and the reference becomes text.

You can use a display format for the value of any numeric, date, or time field, or expression in 4D Chart. For instance, you can use a display format to display dollar amounts using the dollar sign ($), commas, and decimals. The following table shows some examples of display formats:

Data in Default FormatDisplay FormatData in Display Format
3400$###,##.00$3,400.00
3/4/07Month Date, YearMarch 4, 2007

To format a reference:

  1. Select the reference.
    Since the entire expression is a single value, you can select it by clicking it with the Text tool.
  2. Choose Format from the Database menu.
    The Field Format dialog box appears:
  3. Select an appropriate format from the list.
    The format appears in the text box below the list of formats.
    If you want, you can edit a number format or enter a new number format in the Format text box. You cannot edit date or time formats.
    For more information about display formats, refer to GET LIST ITEM PARAMETER.
  4. Click OK.
    The format is listed after the reference. For instance:
    «Current date; Abbr.: Month Day, Year»
    When you choose Show Values, the value of the reference is displayed using the format.

 
PROPERTIES 

Product: 4D
Theme: Using 4D Chart