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 Variables


Macros : Var0-VarZ, VarClr

Macro variables are unsigned integer values named Var0 through Var9 and VarA through VarZ. They can be used to keep track of internal macro states or counts. They are set or tested just like main Daqarta variables.

Var0=1 sets Var0 to 1.

Var0=x toggles Var0 between 0 and 1.

Var0=>1 increments Var0, and Var0=>-1 decrements it.

Macro variables can be used as string variables in Labels, Fields, file names, Notes, or log text. By default, the value is shown with a minimum width of 3 digits, with leading zeroes shown as needed. So if Var0 has a value of 12, then Field1="Test"+Var0 would set Field1 to Test012.

You can specify a different width via a single digit in parentheses. Continuing with the above example, Field1="Test"+Var0(2) would set Test12, and Field1="Test"+Var0(5) would set Test00012. You can specify 10 digits with (0).

Alternatively, you can specify a hexadecimal string via (h). Hexadecimal strings are 8 characters long, so Field1="Test"+Var0(h) would set Test0000000C.

Instead of a simple integer, you can set a macro varible with a string of up to 4 text characters, as in Var0="PASS". To specify the text format when using this as a string variable, use (A). Then Field1="Test"+Var0(A) would set TestPASS.

The text is stored as four ASCII bytes, with the right-most character as the lowest byte. This allows NumA to be incremented to NumB using Var0=>1 just as for a normal integer. ASCII characters below 0x20 (space) or above 0x7E (tilde) are skipped during conversion to text.

Note that macro variables are retained across sessions by default, independent of any .MAC file. You can use this property to set persistent macro preferences. But this also means you may need to explicitly clear some variables at the start of a session. For a single variable, you can just use Var0=0. The VarClr command allows you to clear a range of variables, or all variables:

VarClr=AD sets VarA through VarD to zero.

VarClr= sets all variables to zero.

You can use IF statements such as IF.VarN=100 to test macro variables just like Daqarta control variables.

Professional (and trial) users can send a macro variable value to a Remote Control client via VarN=>>.

You can preset Fields to display macro variables when they are changed. For example Field1=?VarN will cause the value of VarN to be shown in Field 1 whenever VarN is modified. Use VarN=>0 to force the Field to show the current value without changing it.


Example - Operator Prompts:

Suppose you have a complicated test suite, all run by macros, and want to provide a series of prompt messages to help train new operators. You can use VarA to tell if the prompts will be shown, so that they can be turned off when they are not needed. A macro called PromptTog will simply toggle VarA: VarA=x.

A macro called Prompt will be called at various points in the test sequence, indicating what to do next. Each stage of the series will be run by its own macro, which will set VarB to a unique value before calling the Prompt macro via @Prompt.

The Prompt macro will test VarA and show no message if VarA is zero. Otherwise, it will test VarB and show the appropriate message.

  IF.VarA=0
     Msg=
 ELSE.
     IF.VarB=0
         Msg="Hit Test1 to start 1st test."
     ENDIF.
     IF.VarB=1
         Msg="Hit Stop1 to halt 1st test."
     ENDIF.
     IF.VarB=2
         Msg="Hit Save1 to save Test1 results."
     ENDIF.
     IF.VarB=3
         Msg="Hit Test2 to start 2nd test."
     ENDIF.
 ENDIF.

Example - File Name Auto-Increment:

If your test suite saves a lot of different files that are all derived from the same subject or device under test, you will probably want to use the Auto-Increment Filenames option. You need to provide an initial base name for the first file saved, but not for subsequent saves which will append an incrementing value to the base name.

The initial setup macro (typically the ' !' automatic startup macro) can prompt the operator to enter a subject ID to a Field before starting the test, by including the following commands:

  VarC=0
 Msg="Enter Subject ID"
 WaitChange=Field5
 Msg=

You may want to precede this by a MsgPosFix command set to show the Msg right over Field5.

The contents of Field5 (such as "Rat123") can then be used as the base file name. The following file save macro uses VarC as a flag, so that the base name will only be entered on the first save of the session:

  AutoInc=1
 IF.VarC=0
     A.SaveDQA=Field5
     VarC=1
 ELSE.
     A.SaveDQA=
 ENDIF.

The first time this is run, it will save Rat123-000.DQA and set VarC to 1. The next time, it will save Rat123-001.DQA, incrementing on each subsequent save. (The A. prefix means that SaveDQA won't show a Save As dialog, it will just save the file directly.)

Since macro variables are saved across sessions, VarC is set to 0 in the start-up macro. This insures that the initial save always sets the subject ID as the base name. If multiple subjects are tested in one session, VarC should be cleared each time a new subject ID is entered.


Example - Initial Msg Position:

Suppose you want to set a particular default position for a draggable Msg, but once the user drags it, that new position should be used in future sessions. You can use an IF statement like this:

  IF.VarD=12345
     ;Do nothing
 ELSE.
     MsgPos="100,200"
     VarD=12345
 ENDIF.

The first time the macro runs, VarD will be 0 so the position will be set. Later in this session or future sessions, VarD will be 12345 so the MsgPos will not be run. If you have different .MAC files for different applications, you can use specific values to tell which .MAC set ran last, to have different positions for each.


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