cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
RM2241
Level I

Add-in to distribute custom maps, removes maps when a 2nd instance of JMP is closed.

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] )
);

 

4 REPLIES 4

Re: Add-in to distribute custom maps, removes maps when a 2nd instance of JMP is closed.

Hi @RM2241 ,

 

When you mention multiple of instances of JMP being open, do you mean where there are multiple 'home screens' or just multiple platforms open? If the latter then that is a known bug (see here for more details).

 

Why do you need to delete the custom map files on close? Would it work instead to have the script just check on new instances if the map files already exist and use them? 

 

Thanks,

Ben

“All models are wrong, but some are useful”
RM2241
Level I

Re: Add-in to distribute custom maps, removes maps when a 2nd instance of JMP is closed.

For new instances, I mean multiple home screens.  

 

I don't need to delete the custom maps on close, in fact, I don't want them to be deleted on close.  But I would like them to be deleted if the add-in uninstalled and the exit script was the only way I could figure out how to do that.

jthi
Super User

Re: Add-in to distribute custom maps, removes maps when a 2nd instance of JMP is closed.

You can use exit script while checking if the addin still exists.

 

Example:

Create addin with com.mycompany.myaddin as ID

jthi_0-1747992260425.png

Somehow make add-in create some files (I used startup script)

jthi_1-1747992296168.png

And in exit script check for the addin using Get Addin + << ID + Try-catch

jthi_2-1747992319735.png

 

 

Names Default To Here(1);
Try(
	Get Addin("com.mycompany.myaddin") << id
, // if this fails add-in has been removed
	Delete File("$DOCUMENTS/test.txt");
);

Now when you close JMP the file should still be there but when you remove the add-in from View menu it will remove the file (at least did for me).

 

-Jarmo

Re: Add-in to distribute custom maps, removes maps when a 2nd instance of JMP is closed.

Hi @RM2241 ,

 

Could you add a button within the add-in for 'uninstall' for the users to click to run that script solely prior to uninstallation? If you have multiple instances (home screen) then I would try to resolve that too looking at the link I sent below.  I don't think there's a way to actively track when the uninstall is triggered with Add-ins.

 

Thanks,

Ben

“All models are wrong, but some are useful”

Recommended Articles