Misc questions


Recommended Posts

1) In the button action sequence below:

private string strFileName = File.FileOpenDialog("c:\DAQfiles\*.csv")




private Handle = File.Open(strFileName,1,0,0,1)

strProfile = File.GetFileName(Handle) <<<<<<

Profile = File.ReadDelim(Handle,-1,",", chr(10),0)


I have tried both 'GetFileName' and 'GetFileTitle' in line 6. Both return the file with the .csv extension. Is there a way to get the file without the extension? I can use string functions but would like to keep things simpler.

2) How do you create a new file (new profile) from a sequence? It would be saved to the same directory as above, but I need to create a new profile name (file title) from a button quick sequence.

3) Is it possible to set component action variables programmatically? For example, the setChannel and range of the 'Set To' action.

4) Is it possible to run multiple versions of DAQfactory simultaneously on the same PC? Each version would have different settings for addressing the I/O boards. We have three vacuum drying kilns that run independantly, but are fundamentally the same for operating characteristics. I'm thinking of having duplicate DAQfactory files named like Kiln1, kiln2, and kiln3 and then setting each file for addressing the different I/O boards.

Link to comment
Share on other sites

1) that appears to be a bug in the Windows API.  Most of the simple File. functions are simply wrappers for lower level Windows functions, this one included, and it appears to be doing the wrong thing, at least on my Win 10 installation and whatever you are using.  I looked into our source code and verified that GetFileName and GetFileTitle are in fact calling their corresponding Win API function.  It is funny, because GetFileTitleList() works just fine.  But, unfortunately you are probably going to have to strip the extension yourself.

2) you can create a new file by just setting the third parameter of the file.open() function.  The first parameter is the file name, the second a flag for if you are reading from the file, the third, a flag whether you are writing or not.  If the file does not exist and you open it with the write flag enabled, it will create it.  The 4th flag determines whether it will overwrite an existing file if you open it for writing.  Setting that one to 1 causes new write()s to append to the end of an existing file.  But even with that set at 1, if the file you specify doesn't exist, it will create a new one for you.

3) yes, just use a Quick Sequence action instead, or better, have that quick sequence action call a sequence function.  The Set to action is easily replaced with the system.entryDialog() function with the general pattern of:

private string datain = system.entryDialog("Enter a new Value:", 0, 100, 50)
if (!isEmpty(datain))
   myVariable = strToDouble(datain)

where 0 is the min, 100 the max, and 50 the default.  Replace those with variables if you want.

4) Yes you can run multiple instances of DAQFactory, but I generally recommend against it except when you are just trying to copy something over from another file.  It would be best to create your application so it runs all three kilns, but I can see how that adds some complexity.  The correct way to do it would be using objects, but that can be a big step.  So, I can see it working, but I definitely recommend against creating three different files that are essentially the same.  That will be a maintenance nightmare.  Instead create one file, then use startup flags to tell your script what the addressing should be.  

Also note that many hardware devices do not like being accessed from multiple pieces of software at once.  This is especially true with serial devices as only one tool can open a serial port at once, but also others.  Usually you can access different devices of the same brand from multiple tools, but not the exact same device.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.