09-17-2013 08:55 AM
Hi,
I am working on a script on diadem for processing of channels (involving Crash module). I have seen some scripts using *.vas and *.lst files for defining variables, and take actions for different cases and all.
I would like to understand further on the said functions to make use of them in my scripts. I looked up in the internet for some explanation regarding the same but did not get anything much useful.
It would really help me if there is some links and/or examples for them.
Thanks in advance,
Regards,
Fazil Shah.
Solved! Go to Solution.
09-18-2013 01:56 PM
Hi Fazil Shah,
Declaring DIAdem global variables with a *.vas file is a very old approach that still works but which we no longer actively promote. The use of these variables is still covered in Appendix B of the DIAdem 2012 Advanced course, and you will still find them in older applications, but I recommend that you consider alternatives for any new application you are developing. In almost all cases we now recommend using the command "GlobalDim" to create global variant variables in DIAdem. If for some reason you need explicitly data typed global variables, I would use the command "OdsValAlloc" before delving into *.vas file variables. There are some advantages to *.vas variables, but in my opinion they are not outweighed by the inherent limitations.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
09-19-2013 12:11 AM
Hi Brad Turpin,
Thanks for the reply. I am using Diadem 12, but have not recieved a manual for Advance course.
1. I have been command 'GlobalDim' for my scripts already, I just wanted to know if the other command was better to be used, and as per your recommendation will continue to use the same.
But if you can send me an example how the *.vas function is used, it would help me in understanding the earlier codes which I am trying to decode. Also what are the advantages and limitations that this function is having comparing to 'GlobalDim' function?
2. I want to know how to move forward for the below mentioned requirement;
Depending on the name of the channel I want to change the criteria for the next step of processing (for e.g. Channel filter class criteria). I cannot make a If Then logic as the no. of criteria is very large. To further understand my requirement please refer below;
I have a two variables defined by - GlobalDim("name, type")
Now what I want is 'If name = "apple" Then
type = "fruit"
'If name = "carrot" Then
type = "veg"'
now for the variable 'type' to be = fruit I have many conditions and similarly for the next type. My thought process is, if I create list containing all the conditions for 'type' to be = fruit and then link the 'name' variable to that list.
And then assign the variable 'type' depending on the list that 'name' variable is lying. Hope this helps.
3. Lastly, with the help of an example, I want to understand *.lst file usage in scripting.
Please let me know if you need any more clarity on the above.
Regards,
Fazil Shah.
09-19-2013 09:42 AM
Hi faz_mah,
The branching you outline above sounds like it would be most efficiently addressed with a dictionary object, where you can submit all [name, type] pairs once to define it, then use it as many times as necessary to look up the type of a given name. The great thing about the dictionary object is that it executes the lookup function with C code speed.
Set Dict = CreateObject("Scripting.Dictionary") Call Dict.Add("carrot", "vegetable") Call Dict.Add("potato", "vegetable") Call Dict.Add("apple", "fruit") Call Dict.Add("pear", "fruit") Name = LCase("apple") Typ = Dict.Item(Name) Select Case Typ Case "vegetable" MsgBox "Code hear for vegetables" Case "fruit" MsgBox "Code hear for fruit" End Select ' Type
If you really don't have THAT many different comparisons, you can just go with the Select Case statement without the dictionary object
Name = LCase("apple") Select Case Name Case "carrot", "potato" MsgBox "Code hear for vegetables" Case "apple", "pear" MsgBox "Code hear for fruit" End Select ' Type
Note that VBScript compares strings with case sensitivity-- that's why I've included the LCase() function above.
Please describe what you wish to accomplish with .lst file programming in DIAdem.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
09-19-2013 11:09 PM
Hi Brad Turpin,
My requirement for .lst is as given below;
name type price ............
apple fruit 25 ............
pear fruit 30 ...........
carrot veg 15 ...........
potato veg 12 ............
I have variables defined 'name', 'category', 'value'.
Now if my 'category ' = "type", then I want to check the 'name' variable and assign the corresponding value under type colum in the table above to the variable 'value'. Similarly, if my 'category ' = "price", then I want to check the 'name' variable and assign the corresponding value under price colum in the table above to the variable 'value'.
Additionally I have another constraint that the list can keep increasing so there should be a easy way to add criteria to it.
Hope my requirement is clear to you.
Regards,
Fazil Shah.
09-20-2013 06:56 AM
Hi faz_mah,
In that case I would recommend that you use two dictionary objects, TypeDict and PriceDict, as I showed you above. Or you coul use just one dictionary object and store and array of values (type, price, etc.) with each lookup name. The 'A' style enumeration variables in the *.vas file have a static list of enumeration values, and the 'G' type enumeration variables in the *.vas file pull their dynamic list of values from the *.lst file-- which means you would have to add lines to the end of the list file to add rows to your table of possibilities above. It would be faster and easier to avoid the hard drive and use a dictionary object or two.
If you are still unconvinced I can send you an example of creating a 'G' type *.vas variable.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
09-22-2013 11:09 PM
Hi Brad Turpin,
I have used dynamic enumeration list to get the solution. But I have used *.asc file instead *.lst file and its working (I have checked only in segments because the whole script is not yet finished).
Do give your thoughts on this if it may lead to other problems.
Regards,
Fazil Shah.
09-23-2013 09:48 AM
HI faz_mah,
I'm sorry, it's been long enough I misremembered the file extension. The G type enumeration variable in the *.vas file pulls its values from the *.asc file you indicate in the *.vas file-- so it sounds like you're already doing it correctly. The *.lst file is for multiple file selection, such as with FileNameGet().
Brad Turpin
DIAdem Product Support Engineer
National Instruments