Sign in to follow this  
AzeoTech

September 2010

Recommended Posts

Tips and tricks

Here are some lesser known, or often overlooked features and tips for using DAQFactory. Still trying DAQFactory, but your trial ran out? Email us at support@azeotech.com and we'll get your trial reset. For more information, or if you have questions, please visit the DAQFactory forum at www.azeotech.com/board.

Beginner tip:

When creating screens in DAQFactory, being able to drag and drop on screen components with the mouse is very handy. But for more precise control over positioning, consider using the keyboard. If you have components selected you can use the arrow keys to nudge those components one pixel. If you hold down the shift key while pressing the arrows, the components will move by 16 pixels. This is a handy figure because the default font size is 16 points, which gives nice rows when spaced vertically by 16 pixels. When manipulating components that can be resized like graphs and symbols, you can also hold down the ctrl key while using the arrows. This will resize the components by one pixel. Holding the shift key too will resize by 16 pixels.

Intermediate tip:

Each component in DAQFactory has its own custom properties window for changing how the component looks and functions. There is also a common, global, Visual Basic style properties window that is normally not visible, but is handy in certain circumstances. To see this window, go to View -> Properties in the main menu. This window gives access to most of the parameters of the component, but for graphs and some other components you'll still need to use the normal properties window to add things like traces. However, here are two cool things about the general properties window:

1) if you select more than one component, even if they are different types, the general properties window will display all the common properties between the selected components, and, more importantly, any edits you make will apply to all the components. So, if your boss says he wants all the text on a page to be green instead of black, you can simply select all the text components (static text, variable value, etc), then change the ForeColor parameter in the global properties window and it will change the color in all the components in one step!

2) you have access to the exact pixel position of the component and can edit these values to move and resize the component. Usually between the mouse, the keyboard tricks just described, and the Layout menu you can arrange your components the way you want, but sometimes you really just need absolute pixel precision.

Advanced tip:

There are many mentions on the forum of DAQFactory object oriented programming. OOP in DAQFactory is definitely the biggest "hidden" feature, and remains hidden only because it lacks a few debugging features. However, that doesn't mean you can't take advantage of it now. So, as an introduction, here's a simple use for DAQFactory objects: structures. Often times you want to be able to track multiple properties for a single entity. At its simplest, let's say you want to keep a list of valid user name and passwords for some authentication you've added. Without OOP, you'd have to create two string arrays, one to hold the user names, and another to hold the passwords. This works ok, but you have to be extra careful not to add or remove an element from one array and not the other or all the sudden the passwords and user names will no longer line up. With OOP, you can create an object (structure) that holds both the user name and password together, and then create a single array to hold all your users. First you have to define the structure of the object. It might look something like this:

class Users
   local string name
   local string password
endclass

This script would be located in any sequence and when run would create a template for creating objects of type "Users". You have to execute the sequence with this script to create the template though. DAQFactory is not a statically compiled language and so simply writing the code doesn't create the object template. Next, we can create a global variable to hold our list of users:

global myUserList

Note that arrays of objects should be numeric variables, not string. This is because DAQFactory stores references to your objects, and references are just pointers, which are just numbers.

Now we can start to add couple users:

myUserList[0] = new(Users)
myUserList[1] = new(Users)

These two commands create a new Users class and store it in our myUserList array. Now we can set their values:

myUserList[0].name = "my name"
myUserList[0].password = "my password"
myUserList[1].name = "your name"
myUserList[1].password = "your password"

We can access the values the same way. Let's say we want to see if "frank" is in the list:

for (private i = 0, i < numrows(myUserList), i++)
   if (myUserList[i].name == "frank")
	  system.messageBox("Found frank!")
	  break
   endif
endfor
if (i == numrows(myUserList))
   system.messageBox("Frank not found")
endif

The above code is actually not the best way to find out if frank is in the list. One cool part about how DAQFactory does arrays of objects is that you can access them vertically as well as horizontally. So, if you do:

myUserList.name

(i.e. myUserList is not indexed) you will get a simple array of all the names. This is especially handy because then you can use some of the super-fast functions like search() and filter(). So, to find if frank is in the list you can do this:

if (search(myUserList.name == "frank") != -1)
   system.messageBox("frank found!")
else
   system.messageBox("frank not found!")
endif

or to get frank's password:

private index = search(myUserList.name == "frank")
if (index == -1)
   system.messageBox("frank not found!")
else
   system.messageBox("frank's password is: " + myUserList[index].password)
endif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this