Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Example: Importing Functions from a Shared Library File (Windows Only)

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

Complete the following steps to create and update a library of VIs based on the functions in a regular expression DLL (regexpr.dll) using the Import Shared Library wizard. Refer to Importing Functions from a Shared Library File to create or update wrapper VIs for functions in any shared library file.

  1. Select Tools»Import»Shared Library (.dll) to launch the Import Shared Library wizard. The Specify Create or Update Mode page appears.
  2. Select Create VIs for a shared library, and click the Next button to display the Select Shared Library and Header File page of the wizard.
  3. Click the Browse button next to the Shared Library (.dll) File text box to navigate to and select labview\examples\dll\regexpr\regexpr.dll. After you select this file, LabVIEW designates labview\examples\dll\regexpr\regexpr.h as the default header file.
  4. If a checkmark appears in the Shared library file is not on the local machine checkbox, remove it.
  5. Click the Next button to display the Configure Include Paths and Preprocessor Definitions page. You do not need to add any additional include paths or preprocessor definitions for this DLL.
  6. Click the Next button to display the Select Functions to Convert page. A dialog box appears to notify you that LabVIEW is parsing the specified header file.
  7. Select the functions for which you want to create wrapper VIs by placing a checkmark in the checkbox next to each function. The six functions that appear contain checkmarks by default. LabVIEW creates VIs for each of the functions you select.
  8. Click the Next button to display the Configure Project Library Settings page.
  9. By default, regexpr appears in the Project Library Name (.lvlib) field. LabVIEW automatically includes all generated VIs within this project library file and gives it a .lvlib file extension. Also by default, labview\user.lib\regexpr appears in the Project Library Path field, and the Copy the shared library file to the destination directory checkbox contains a checkmark.
  10. Click the Next button to display the Select Error Handling Mode page.
  11. Select Function Returns Error Code/Status from the Error Handling Mode pull-down menu. Use this error mode because the regular expression library functions return an error status that you can pass to the RegExpr_GetErrorString() function to get a description of the error. When an error occurs, you can use this error description to form the error cluster information in LabVIEW.
  12. Click the Next button to display the Configure VIs and Controls page.
  13. Review the configuration for the VIs and controls you want to create. Select a VI or a control on the left and then use the fields on the Settings and Name and Description tabs to review and edit specific information. Make the following changes to the default configuration settings:
    • RegExpr_FindPatternInText()
      1. Change the Control Type of caseSens to Boolean.
      2. Change the Control Type of direction to Boolean.
      3. Change the Control Type of matchPolicy to Boolean.
      4. Change the Control Type of matched to Boolean.
      5. Change Input/Output for matched to Output.
      6. Change Input/Output for matchPosition to Output.
      7. Change Input/Output for matchLen to Output.
    • RegExpr_MatchText()
      1. Change the Control Type of matchPolicy to Boolean.
      2. Change Input/Output for matchLen to Output.
    • RegExpr_Parse()
      1. Change the Control Type of caseSensitive to Boolean.
    , because all of the VIs are part of a project library called regexpr, the prefix for each VI name is redundant. Similarly, control names in LabVIEW can include spaces to improve readability.
  14. Click the Next button to display the Generation Summary page, and review the Generation Summary to determine if you are ready to generate VIs. If you want to make any changes, click the Back button.
  15. Click the Next button to create wrapper VIs for the functions you selected in the specified shared library. The Generation Progress page shows the progress of the wizard as it generates the wrapper VIs. When the generation completes, the Finish page appears.
  16. Place checkmarks in the Open the generated library and View the report checkboxes, and click the Finish button to close the wizard, open the project library file, and view the report in the default browser.
  17. Review the report. The report indicates that no errors or warnings occurred.
  18. Review the project library file and the generated VIs within it. After you initially generate the VIs, you can make changes to the VIs individually within the block diagram or front panel of each VI. Then you can re-run the wizard to update the VIs within the library.
  19. From the Project Explorer window, open Reg Expr Find Pattern In Text.vi. This VI is executable as is, but you can make some manual improvements to enhance the usability of the VI. Make the following edits to the VI:
    1. On the block diagram, replace the txtLen control with a String Length function.
    2. Wire the text control to the string input of the String Length function.
    3. Wire the length output of the String Length function to the Call Library Function Node. The VI then can calculate the string length automatically based on the specified text entries.
    4. Delete the function return indicator and remove any broken wires. LabVIEW uses the return value to create error cluster information, but you do not need the indicator on the front panel of the VI.
    5. Save and close the VI.
  20. Close the regexpr.lvlib project library file.

Update the Generated Project Library VIs with Custom Controls

The generated library is complete and usable as is. However, you might want to make changes to several VIs within the library. To do this, you can re-launch the wizard and select the Update VIs for a shared library option on the Specify Create or Update Mode page. With this option, you can update and overwrite specific VIs that you generated previously. Complete the following steps to update a subset of the VIs within regexpr.lvlib with custom controls:

  1. Select Tools»Import»Shared Library (.dll) to launch the Import Shared Library wizard. The Specify Create or Update Mode page appears.
  2. Select Update VIs for a shared library and select regexpr.lvlib from the list of projects.
  3. Click the Next button to display the Select Shared Library and Header File page of the wizard. The Shared Library (.dll) File text box contains the path labview\examples\dll\regexpr\regexpr.dll, and the Header (.h) File text box contains labview\examples\dll\regexpr\regexpr.h as the default header file.
  4. Click the Next button to display the Configure Include Paths and Preprocessor Definitions page. You do not need to add any additional include paths or preprocessor definitions for this DLL.
  5. Click the Next button to display the Select Functions to Convert page. A dialog box appears to notify you that LabVIEW is parsing the specified header file.
  6. Select the functions you want to convert by placing a checkmark in the checkbox next to each function. The six functions that appear contain checkmarks by default. Click the Uncheck All button to remove the checkmarks.
  7. Place checkmarks in the checkboxes next to RegExpr_FindPatterninText() and RegExpr_MatchText() to select them as the functions to update.
  8. Click the Next button to display the Configure Project Library Settings page. You do not need to change any of the settings on this page.
  9. Click the Next button to display the Select Error Handling Mode page. LabVIEW prompts you to confirm whether you want to overwrite the specified files. Click the OK button.
  10. On the Select Error Handling Mode page, select Function Returns Error Code/Status from the Error Handling Mode pull-down menu.
  11. Click the Next button to display the Configure VIs and Controls page.
  12. Make the following changes to the default configuration settings:
    • RegExpr_FindPatternInText()
      1. Change the Control Type of matchPolicy to Custom Control.
      2. Click the Browse button next to the Path to Custom Control field to navigate to and select labview\examples\dll\regexpr\custom controls\Search Direction.ctl as the custom control.
    • RegExpr_MatchText()
      1. Change the Control Type of matchPolicy to Custom Control.
      2. Click the Browse button next to the Path to Custom Control field to navigate to and select labview\examples\dll\regexpr\custom controls\Match Policy.ctl as the custom control.
  13. Click the Next button to display the Generation Summary page.
  14. Click the Next button to update the VIs.
  15. On the Finish page, select the Open the generated library option and click the Finish button to close the wizard and open the project library file.
  16. From the Project Explorer window, open Reg Expr Find Pattern In Text.vi. Notice that the previous changes you made to the block diagram of this VI no longer appear. You must make them again. Make the following edits to the VI:
    1. On the block diagram, replace the txtLen control with a String Length function.
    2. Wire the text control to the string input of the String Length function.
    3. Wire the length output of the String Length function to the Call Library Function Node. The VI then can calculate the string length automatically based on the specified text entries.
    4. Delete the function return indicator and remove any broken wires. LabVIEW uses the return value to create error cluster information, but you do not need the indicator on the front panel of the VI.
    5. Save and close the VI.
  17. Close the regexpr.lvlib project library file.

Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit