03-07-2019 09:24 AM
Hi All
I wonder if anyone could help me with something I am struggling with? It is something very useful for me that I can complete successfully in CATMAN by HBM but I want / need to do it in DIADEM aswell. I want to be able to use a for loop to do the following with files named Cycle1.csv, Cycle 2,csv, Cycle3.csv etc:-
-Load file cycle1.csv
-Complete a series of operations on channels within file, the results of which are saved in a new group.
-Delete cycle1.csv from data portal
-Load file cycle2.csv
-Complete a series of operations on channels within file, the results of which are saved in new group with cycle1.csv results
-Delete cycle2.csv from data portal
-Load file cycle3.csv
-Complete a series of operations on channels within file, the results of which are saved in new group with cycle1.csv and cycle2.csv results
-Delete cycle3.csv from data portal
etc.
I found the following at this location which I tried to adapt but had no success - http://zone.ni.com/reference/en-XX/help/370858M-01/procscript/procscript/procscript_serial_evaluatio...
Option Explicit Dim i If FileDlgShow(DataReadPath,"TDM Files,*.tdm","DataSelection",True) = "IDOk" Then For i = 0 to UBound(FileDlgNameList) Call Data.Root.Clear() Call DataFileLoad(FileDlgNameList(i),"TDM","Load") Call ChnSmooth("[1]/[2]","/Smoothed",12,"maxNumber") Call DataFileSave("Serie_"&str(i),"TDM") Next End If
Any help would be much apprecieated.
Many thanks
Lloyd James
Delphi Technologies
03-07-2019 10:45 AM
This code can be a starting point for you:
Option Explicit 'Forces the explicit declaration of all the variables in a script. ' Folder with cycles DIM CYCLES_FOLDER: CYCLES_FOLDER = "C:\Users\111660\Desktop\Example Folder\" ' Prepare variables Call Data.Root.Clear() Call Data.Root.ChannelGroups.Add("Result Group") Dim loadedElements, element Dim i: i = 1 Dim cycleFile: cycleFile = CYCLES_FOLDER & "Cycle" & i & ".csv" ' Loop over files Do While FileExist(cycleFile) ' This loop will not execute if "cycleX.csv" doesnt exist ' Load a cycle Set loadedElements = DataFileLoad(CYCLES_FOLDER & "Cycle1.csv","") ' Do stuff and put in the "Resuilts Group" ' Delete the loaded groups For Each element In loadedElements Call Data.Root.ChannelGroups.Remove(element.Name) Next ' Update cycle counter and set up the new file name i = i + 1 cycleFile = CYCLES_FOLDER & "Cycle" & i & ".csv" Loop
I tried to comment but et me know if any part needs explanation.
03-11-2019 03:55 AM
Hi gsklyr
Many thanks for such a quick reply on this, I will have a look and let you know how I get on.
Best regards
Lloyd James