Daqarta
Data AcQuisition And Real-Time Analysis
Scope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
The following is from the Daqarta Help system:

Features:

Oscilloscope

Spectrum Analyzer

Signal Generator
(Absolutely FREE!)

Spectrogram

Pitch Tracker

Pitch-to-MIDI

DaqMusic
(Free Music... Forever!)

Remote Operation

DC Measurements

True RMS Voltmeter

Sound Level Meter

Frequency Counter
    Period
    Event
    Spectral Event

    Temperature
    Pressure
    MHz Frequencies

Data Logger

Waveform Averager

Histogram

Post-Stimulus Time
Histogram (PSTH)

Macro System

Multi-Trace Arrays

Trigger Controls

Auto-Calibration

Spectral Peak Track

Spectrum Limit Testing

Direct-to-Disk Recording

Accessibility

Applications:

Frequency response

Distortion measurement

Speech and music

Microphone calibration

Loudspeaker test

Musical instrument tuning

Animal sound

Evoked potentials

Rotating machinery

Automotive

Product test

Contact us about
your application!

Macro IF Statements

A control that sets a value or state (not text entry) can be tested in a macro IF statement to determine if it is equal to, greater than, or less than a specified constant.

An IF statment always starts with an IF. prefix (note the period after any prefix) before the command to be tested, then a list of commands to perform if that statement is true. An optional ELSE. branch lists commands to be performed if the IF statement was false. There is no "Else If" equivalent, so only a single ELSE. may be used per IF statement. An ENDIF. must be used to close each IF structure:

 
 IF.L.0.ToneFreq=1000
     Msg="1 kHz"
 ELSE.
     Msg="Not 1 kHz"
 ENDIF.
 

The above example shows the "true" and "false" branches indented for clarity. Indenting is not required, but it is strongly recommended. (You can use CTRL+Tab in the Macro Definition editor to move to the next 4-character tab stop.)

To test for greater than or less than, use > or < after the equal sign. Note that the = sign is always required, so that => means "Greater Than", not "Greater Than or Equal To":

 
 IF.L.0.ToneFreq=1000
     Msg="Exactly 1 kHz"
 ELSE.
     IF.L.0.ToneFreq=>1000
         Msg="Above 1 kHz"
     ELSE.
         Msg="Below 1 kHz"
     ENDIF.
 ENDIF.
 

Note: Use caution with IF test values that include decimal places. Due to rounding in binary-to-decimal conversion for value entry and display, there may be differences in the last decimal place between the internal representation of the value being tested, the displayed version of that value shown in a control, and the internal and entered versions in the IF statement. Instead of testing for exact equality, you should test if the value is above or below specified limits.

The above shows a single nested IF. IF statements can contain nests up to 4 levels deeper (more indented) than the main IF. You can have an arbitrary number of IF statements at each level.

Instead of value comparisons, as shown in the preceding examples, you can use logical bit field tests by putting an & after the equal sign. Then the IF will pass if any bits that are set in test value are also set in the tested variable.

To make it easier to work with bit fields, the test value can be given in hexadecimal by preceding it with an h. For example, IF.VarA=&h80000001 will be true if VarA has either its most-significant or least-significant bit set. This type of test is particularly useful for Limits tests, where 4 different Pass/Fail test results are present in a single variable.

See Macro Variables for an example that uses IF statements to provide a system of prompts for novice users, which can be toggled off by experienced users.


Control Enable Tests:

Use E.IF instead of IF to test if a control is enabled. You don't need a value after the equal sign. For example, to test if the Trigger Level control is enabled, use:

 
 E.IF.TrigLevel=
     Msg="Enabled"
 ELSE.
     Msg="Disabled"
 ENDIF.
 

Trigger Level is disabled during Gen Sync trigger mode. (In this particular case you could have simply tested for Gen Sync mode with a normal IF, using IF.TrigMode=GenSync.)

If a macro tries to set a disabled control, the macro aborts with the message "Control disabled. Aborting macro". By testing first, you can take other action.


See also Macro Overview

GO:

Questions? Comments? Contact us!

We respond to ALL inquiries, typically within 24 hrs.
INTERSTELLAR RESEARCH:
Over 25 Years of Innovative Instrumentation
© Copyright 2007 - 2011 by Interstellar Research
All rights reserved