I am trying to distribute custom maps via a JMP Add-in. I have created an add-in which copies the map files from the add-in directory to the custom maps directory when JMP is launched (using the startup script), then deletes them when JMP is closed (via the exit script). However, this leads to an issue when multiple instances of JMP are opened (sometimes accidentally) and one is closed. When the second instance of JMP is closed, the exit script runs, deleting the maps from the custom map folder and JMP must be fully close (all instances close) and then reopened to re-add the graphs.
Is there a way to have the exit script run only when the add-in is uninstalled, but not when JMP is closed? Or is there a better way to distribute custom maps?
Startup Script:
Names Default To Here( 1 );
//Create Custom Map Path
homePath = Convert File Path( "$HOME", absolute );//get home path
mapPath = Substr( homePath, 1, Length( homePath ) - Length( Word( -1, homePath, "/\" ) ) - 1 ) || "Maps/";
//Create map path if it doesn't exits
If( !Directory Exists( mapPath ),
Create Directory( mapPath )
);
//copy files from addin map folder to JMP map folder
mapFiles = Files In Directory( "$ADDIN_HOME(com.hp.G5iTools)" || "/Maps" );
For( i = 1, i <= N Items( mapFiles ), i++,
newMapFilePath = "$ADDIN_HOME(com.hp.G5iTools)" || "/Maps/" || mapFiles[i];
If( !File Exists( mapPath || mapFiles[i] ),
Copy File( newMapFilePath, mapPath || mapFiles[i] )
);
);
Exit Script:
Names Default To Here( 1 );
//delete map files
homePath = Convert File Path( "$HOME", absolute );//get home path
mapPath = Substr( homePath, 1, Length( homePath ) - Length( Word( -1, homePath, "/\" ) ) - 1 ) || "Maps/";
mapFiles = Files In Directory( "$ADDIN_HOME(com.hp.G5iTools)" || "/Maps" );
For( i = 1, i <= N Items( mapFiles ), i++,
Delete File( mapPath || mapFiles[i] )
);