Skip to content Skip to navigation Skip to collection information

OpenStax-CNX

You are here: Home » Content » Introduction to G Programming » Functions

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • NSF Partnership display tagshide tags

    This collection is included inLens: NSF Partnership in Signal Processing
    By: Sidney Burrus

    Click the "NSF Partnership" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

  • Featured Content display tagshide tags

    This collection is included inLens: Connexions Featured Content
    By: Connexions

    Click the "Featured Content" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Functions

Module by: Eduardo Perez. E-mail the author

Summary: The creation of this content was supported in some part by NSF grant 0538934.

Any G program can become a function. Three operations must be done:

  1. Edit connecting input and/or output terminals
  2. Edit the icon (optional but recommended)
  3. Save the G program

Connectors

Open the Fibonacci.vi for this example.

On the Front Panel window, right click on the icon located on the right upper corner of the window and select Show Connector.

Figure 1: Show Connector Pane
A screen cap of a windows window with a menu present. The item  'show connector'is highlighted.

This brings up the connector pane as shown in Figure 2.

Figure 2: Connector Pane
A screen cap of a windows window showing a 'connector pane'.

Right click on the connector pane and select Patterns. A menu with connector patterns is presented from which you can select the appropriate pattern. For this example select the pattern highlighted in Figure 3.

Figure 3: Select Connector Pattern
A screen cap of a windows window showing a menu with the item 'patterns' highlighted and a row of icon indicating which patterns can be selected for the Connector Pattern.

Click on the connector terminal followed by a click on the input or output control to which the terminal is to be associated. In Figure 4, the left connector terminal is associated with the numeric input control n.

Figure 4: Associating Terminals
A screen cap with the left side of the Connector pane selected and the left field selected.

Repeat for all the input and output controls that are to be associated to the terminals. For the Fibonacci.vi, Figure 5 shows the right connector terminal associated with the Fib(n) output terminal.

Figure 5: Connected Terminals
A screen cap with the left side of the Connector pane light blue and the right side dark blue.

Icon Editor

Right click on the connector pane and select Edit Icon… from the pop-up menu. This will bring the icon editor (Figure 7).

Edit the icon for black and white, 16-color and 256-color displays and click OK when completed.

Save the G program to complete the function.

Figure 6: Selecting Icon Editor
A screen cap of a windows window with a menu on top. The item 'edit icon' is highlighted in the menu.
Figure 7: Icon Editor
An icon editor window.

Invoking Functions

To invoke functions, right click on the Block Diagram window and select Select a VI… from the pop-up menu. This will bring a file dialog box. Find the desired function to be part of the program and click OK.

Figure 8: Invoking Functions
A screencap of the 'Functions' window.

In the example shown in Figure 9, the Fibonacci series of the first 20 Fibonacci numbers is stored in an array. The numbers are computed by invoking the Fibonacci.vi function.

Figure 9: Fibonacci Series
A screencap of the 'Fibonacci Series' function.

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks