DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the number of channels available in DIAdem using VBScript?

I want to know the last number of the available channels in DIAdem-DATA using VBScript. If there are not enough channels, I'll allocate new ones using ChnAlloc.

For the first run of the script, I do know there're 60 channels, but in a second run I might have created the additional channels already (if the script didn't fail) and I don't want to do the allocation a second time. So I need to know the number of the last channel. Unfortunatly I didn't find any function in the help providing this number.

Thanks,
Carsten
0 Kudos
Message 1 of 3
(4,864 Views)
Hello Carsten,

The variable "ChnNoMax" contains the currently configured maximum number of channels in the DIAdem data area.

Just query this read-only variable to see how many channels are available.

Otmar
Otmar D. Foehner
Message 2 of 3
(4,864 Views)
Hi Carsten,

I have a few thoughts for you plus some useful code. Bear in mind that you can change the number of static DIAdem channels (by default 60 of length 8192) as well as the number of available dynamic channels (by default 1000) to whatever you want. These memory matrix settings get stored in your Desktop.DDD file (DIAdem's ini file), so that each time you launch DIAdem it will create the channels according to your specifications. The maximum number of channels of all types that DIAdem can have is 65536 (2^16).

Secondly, don't forget that you can address channels by name or by number. If the channels are named distinctly, addressing channels by name is the most reliable method. If you use ChnAlloc() to allocate new channels, and you want to address those new channels by channel number, you MUST use CNo() immediately after creating the new channel in order to find out that channel's number. It will not always be the next available channel number, because the next available channel may not be long enough. ChnAlloc() will latch on to an existing channel if it can find one long enough, and it will create new channels only if it finds none of the existing channels suitable.

In the VBScript I attached to this email you will find all the DIAdem variables which contain information about the maximum available channels and the maximum length of each channel (not its currently set length). Note that DIAdem's data matrix is divided into 8 submatrices, each with 2 GBytes of addressable memory (2^31 Bytes). Each submatrix can have multiple static channels assigned to it. DIAdem's dynamic channels come first from DIAdem's application RAM (Windows allocates no more than 2 GBytes per application) then from the Windows swap file for its virtual memory

Now, in addition to the variables which tell you the maximum possible channel count and lengths, another very useful variable is "GlobUsedChn", which returns the highest channel number currently filled with some amount of data.

Ask if you have additional questions,
Brad Turpin
NI
Message 3 of 3
(4,864 Views)