From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

AsciiLoad function corrupts DataSetComment variables

Hi,

 

if you import an Ascii file with the AsciiLoad function, all DataSetComment variables are cut to 73 characters and concat in a weird way.

 

Can someone please verify this? I'm really clueless.

 

Please just try this code:

 

Call ScriptCmdReset() 
Call UserVarFreeAll() 
Call DataDelAll(1) 

DATASETCOMMENT(52) = "2222222222222 - abcdefghijklmnopqrstuvwxyz-aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz"
DATASETCOMMENT(53) = "111111111111111 - abcdefghijklmnopqrstuvwxyz-aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz"
DATASETCOMMENT(54) = "1818181818181818 - abcdefghijklmnopqrstuvwxyz-aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz"
' DATASETCOMMENT(5) = "262626262626262626 - abcdefghijklmnopqrstuvwxyz-aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz"
' DATASETCOMMENT(6) = "30303030303030303030 - abcdefghijklmnopqrstuvwxyz-aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz"

msgbox Len(DATASETCOMMENT(52)) & vbCrLf & vbCrLf & DATASETCOMMENT(52)
msgbox Len(DATASETCOMMENT(53)) & vbCrLf & vbCrLf & DATASETCOMMENT(53)
msgbox Len(DATASETCOMMENT(54)) & vbCrLf & vbCrLf & DATASETCOMMENT(54)
msgbox Len(DATASETCOMMENT(5)) & vbCrLf & vbCrLf & DATASETCOMMENT(5)
msgbox Len(DATASETCOMMENT(6)) & vbCrLf & vbCrLf & DATASETCOMMENT(6)



Call AsciiLoad("C:\tmp\test.txt", 0)


msgbox Len(DATASETCOMMENT(52)) & vbCrLf & vbCrLf & DATASETCOMMENT(52)
msgbox Len(DATASETCOMMENT(53)) & vbCrLf & vbCrLf & DATASETCOMMENT(53)
msgbox Len(DATASETCOMMENT(54)) & vbCrLf & vbCrLf & DATASETCOMMENT(54)
msgbox Len(DATASETCOMMENT(5)) & vbCrLf & vbCrLf & DATASETCOMMENT(5)
msgbox Len(DATASETCOMMENT(6)) & vbCrLf & vbCrLf & DATASETCOMMENT(6)

 

My test.txt just contains the following:

 

fafasdf;adfasdf;adfadsf
341234;12341234;12341234

 

It is imported correctly into 3 channels with 2 entries each.

 

Just my DataSetComments, which I want to export to Excel later, are corrupted.

 

I don't want to use DataPlugins, because I work on many different txt files with completly different content. That's why I want to keep using stp files.

 

Anyone any idea what is happening here and how to work arrounf this?

 

Thanks a million in advance!

 

 

EDIT: Oh, I forgot, I'm using Diadem 2010 (11.2 SP1)

0 Kudos
Message 1 of 5
(5,425 Views)

Hi NaniB,

 

The DataSetComments array was built to work with the old DIAdem DAT files, which could store 100 string name-values pairs.  The contents of that array were automatically written to any DAT file you created with DIAdem, and it was also automatically filled with the values from any DAT file you loaded.  Prior to DIAdem 9.0, this array was still a useful tool to store string information and was used in a variety of situations, including in some cases ASCII import.  Over a decade ago DIAdem 9.0 added the Data Portal, and Channel Groups, and custom properties on all 3 levels, and since then there has been less and less interest in the DataSetComments, as well as the RegisterAttr... Channel properties that also worked with DAT files.

 

The DataSetComments were not removed, but eventually they were hidden from the user interface.  My recommendation is to not use them any more.  R&D is very unlikely to revisit code from a DIAdem version 4 years ago for a feature that was the best option 10 years ago, even if it does have this odd behavior.

 

So let's talk options.  Can you send me a couple of examples of the ASCII files you need to load?  Since DIAdem 9.1 we've had a vastly superior method of loading ASCII data files than the AsciiLoad() command.  I would be happy to help you create a DataPlugin to load your ASCII data files, and the DataPlugin can create all the custom properties you need and actually name them with relevant text, instead of DataSetComment1, DataSetComment2, etc.  We will likely also need to make other changes in your layouts and possibly scripts, but I believe that will be worth the effort, and I'm willing to help.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 5
(5,396 Views)

Hi Brad,

 

thank you very much for your reply!

 

Okay, to the DataPlugin. I see the potential of DataPlugins and created and even modified them by hand myself. They are great and I'm absolutely fine with them. But the situation is this: The Ascii files I'm working on have the ending .trx. In my company/department, I'm doing this vbs script for, already a DataPlugin for .trx files, which have a completely different content, exists and is registered on all stations/Diadem installations. I really really don't want to break something here. I have no access to this plugin, can not change it. My script should just allow the users to chose one of "my" .trx files and load (and analyze) it. And live in peaceful coexistens with this existing .trx DataPlugin..... 🙂 Yes, I was considering to register "my" .trx DataPlugin on script start end unregister it at the end to leave no "traces", but if my script crashes now, or something, ahh, no, please, I just wanna load my file and that's it..... 😃

 

But maybe you have a hint for me at the other end of this story. I use the DataSetComment to export some meta information, like error messages during processing of the script and so on to an extra Sheet in the excel file which contains the results of my script. It is very convinient, as the excel export function basically does the job itself.

 

What else can I do tho bring some "log-info" to an extra excel sheet? (Without starting to handle all the excel export via OLE) If I store this info in channels, instead of the DataSetComment variables, it is only very little extra effort, but the excel export can handle only one sheet for channel data, right?

 

Thank you very much for your help!

NaniB

0 Kudos
Message 3 of 5
(5,391 Views)

Hi NaniB,

 

Well, we could always create a DataPlugin that is assigned to a dummy file extension such as "*.abc123" so that it can never conflict with the existing one.  You could still call that DataPlugin with DataFileLoad() for a particular *.trx file, so that's an option.

 

The Excel Export is a more ticklish issue.  The Excel Export Wizard is an ancient feature that has also been removed from the user interface of modern DIAdem versions, largely because of all its limitations.  In addition to making ActiveX/OLE calls from a VBScript, the other options for sending data to Excel are to use the "CSV" DataPlugin to create an ASCII file that loads into Excel, or to export to a TDM file and use the Excel TDM Addin to load the TDM file into Excel.

 

Have you looked at the TDM Excel Addin approach?  It automatically lists all the custom properties you write to the TDM file at the top of the Excel sheet...

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 5
(5,386 Views)

Ah, okay, I never understood entirely the [FileImportFilter] parameter of DataFileLoad. So I can use it to load a file with a DataPlugin not matching the file extension. I see now. That is really an option, I will think about it.

 

Thank you very much!

 

So, what you say is, I'm working with Diadem now for just a few months but I already picked two ancient features... XD

 

The nice thing with the Excel export is that it "hides" the additional info on an extra sheet. I actually don't want it to be present on the first view for the user of my script and the resulting excel.

 

But anyway, I will go for the DataPlugin variant now with a dummy file extension, like you described. Thanks again for that!

 

Kind Regards,

Daniel

0 Kudos
Message 5 of 5
(5,383 Views)