Complete the following steps to write a script:
  1. Call the niFgen Configure Output Mode VI or the niFgen_ConfigureOutputMode function to switch to script mode.
  2. Write all waveforms that are referenced in the script by calling the niFgen Write Named Waveform VI or one of the niFgen Write Named Waveform functions and associate the proper names to them.
  3. After your waveforms are written to your instrument, call the niFgen Write Script VI or the niFgen_WriteScript function to write the scripts containing the generation instructions to execute.
    The script you write can manage waveform generation based on multiple waveforms and triggers. The following code example instructs to download waveforms A, B, C, and D into instrument memory, and then write a script that waits for a trigger to initiate generation and, when receiving this trigger, generates waveform A three times with a marker at position 16 each time and finally generates waveforms B, C, and D twice (BCDBCD).
    script myFirstScript
      wait until scriptTrigger0
      repeat 3 
        generate waveformA marker0(16)
      end repeat
      repeat 2
        generate waveformB
        generate waveformC
        generate waveformD
      end repeat
    end script
  4. You can write multiple scripts that exist simultaneously on your instrument. If you write multiple scripts to your instrument, you must select the one you want to execute by setting the Script to Generate property or the NIFGEN_ATTR_SCRIPT_TO_GENERATE attribute.
  5. Call the niFgen Initiate Generation VI or the niFgen_InitiateGeneration function to execute the selected script.
Note Internally, the script stores physical instrument memory locations to refer to the named waveforms. Thus, you must write all waveforms to the instrument before writing the script, or the instrument does not know where the waveform is located. The niFgen Initiate Generation VI or the niFgen_InitiateGeneration function returns an error if this rule is violated. If you delete waveforms and rewrite them, rewrite the script to update it with the new locations even if the script text has not changed.

In some cases at high sample clock rates, your script may result in an underflow error. Underflow errors in a script can be created by waveform size, marker placement, and specific script instructions. To avoid underflow errors, refer to the minimum waveform size in PXIe-5413 Specifications.