I have a DXL script that open (read or edit) modules and put them in a skip list (so that I could close them at the end)
The skip list store the module handle of each module read or edit :
if (MODIF_OTHER_MODULES)
{
modSrc = edit(modSrc_Name, false)
} else
{
modSrc = read(modSrc_Name, false)
}
put(skp_openmodule, modSrc, modSrc)
But sometimes modules are already open outside my DXL script so following check is KO :
mvSource = sourceVersion lr
modSrc_data = data mvSource
modSrc_Name = fullName(source lr)
if (null modSrc_data)
"read/edit modSrc_Name module and add module in the skip list" : OK DONE
else
"the module is already open but maybe I don't open it myself"
"so I WANT TO CHECK if module is already in the skiplist and ADD module of modSrc_data in the precedent skip list if it isn't " : I DONT KNOW HOW !
"
Is there a way to get module of modSrc_data so that it could be added in skp_openmodule if it is not already present in the list ?
I don't want to read/edit it again because I don't know in which mode it was open previously and I would prefer to avoid it because I will do it for each objet and each link !
also it would be great if I could also retrieve the information about how the module was open (read or edit)
I tried : module (modSrc_data) and module(modSrc_Name) but it doesn't work.
Not sure if this is due to the excerpt you posted, but you should always turn off the autodeclare option and ensure that you always use the correct types for your variables by either checking the DXL manual or by using alternative sources like the "undocumented perms list" . data
performed on a ModuleVersion
returns type Module
. So you already have what you need. An alternative would be the perm bool open(ModName_ modRef)
. And note that the perm module
does not return a Module
, but a ModName_
.
Also, in addition to bool isRead(Module m)
, bool isEdit(Module m)
and bool isShare(Module m)
(!!) when you really want to close modules that have been opened previously, you might want to check bool unsaved(Module m)
ModuleVersion mvSource = sourceVersion lr
Module modSrc_data = data mvSource
string modSrc_Name = fullName(source lr)
if (null modSrc_data)
print "read/edit modSrc_Name module and add module in the skip list"
else
{
print "the module is already open but maybe I don't open it myself"
if isRead (modSrc_data) then print " - read"
if isEdit (modSrc_data) then print " - edit"
if isShare (modSrc_data) then print " - shared mode"
if unsaved (modSrc_data) then print " - do not silently close me, otherwise the user might be infuriated"
}