10-04-2011 08:06 AM - edited 10-04-2011 08:06 AM
Hi!
I'm writing a script which asks the user where to save an auto generated Report-File. The suggested folder is always G:\TSM:
FileNameGet("REPORT", "FileWrite", "G:\TSM\" & Filename & ".TDR"
I want the dialog to suggest the folder where the loaded TDM file is stored, something like "DataFileFolder":
FileNameGet("REPORT", "FileWrite", DataFileFolder?! & Filename & ".TDR"
Is there a method to get the folder of the loaded data?
Regards,
Sascha Zimmer
Solved! Go to Solution.
10-04-2011 09:04 AM
Hi Sascha,
every channel in the DIAdem data portal has a property named sourcedatafilepath.
For Example:
Dim SourcePath
SourcePath = Data.Root.ChannelGroups(1).Channels(1).Properties("sourcedatafilepath").Value
Call FileNameGet("REPORT", "FileWrite", SourcePath & Filename & ".TDR")
Regards,
Hans Beckers
10-05-2011 12:23 AM
Works perfect! Thanks for your help!
10-05-2011 12:39 AM
Hello,
after i implemented the code an error occures if i have no data loaded in the data portal.
It says "Index 1 is not an element of the listing" - logically if theres no channel and no group.
How can i check if any data is loaded in the portal?
Something like
If Data.Root.ChannelGroups(1).Channels(1).Exists = true then...
Regards
Sascha Zimmer
10-05-2011 01:42 AM
Hi Sascha,
you can check the number of channels in the first group:
Dim NoOfChannels
NoOfChannels = Data.Root.ChannelGroups(1).Channels.Count
if noOfChannels > 0 then
...
Regards
Hans Beckers
10-05-2011 04:16 AM
Hi Hans!
Thanks for your reply! Your code does the right thing if any data is loaded.I got the same error than before because the Index 1 from ChannelGroups(1) doesnt exist.
My problem is that if there is no data loaded at all, there are also no channels and no channel groups. What can I do to check if the whole Data Portal is empty or not?
Regards
Sascha Zimmer
10-05-2011 04:22 AM
Hi Sascha,
you can count the channelgroups, which are loaded to the data portal:
Dim NoOfChannelGroups
NoOfChannelGroups = data.root.channelgroups.count
If NoOfChannelGroups > 0 then
...
Regards
Hans Beckers
10-05-2011 04:23 AM
I found a solution by myself:
If Data.Root.ChannelGroups.Count > 0 then
...
Works fine even theres no ChannelGroup defined.
Regards
Sascha Zimmer