cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Append a Time Stamp and the Windows Username to Reports
Byron_JMP
Staff

This is a basic script utility that appends a the date and the windows username to the bottom of all the open reports.

 

 

Only works on Windows OS: Calls a windows specific .dll

//Stamp all report windows with the user windows user name and date.
//
//note this only work on Windows operating systems, not OSX
//the dll read came from John Ponte (Thanks) https://community.jmp.com/t5/Discussions/computer-name/td-p/3464
//This is intended packaged in an add-in or as a custom script in the menu bar.
//Byron Wingerd, Aug 18, 2018
//

dll = Load DLL( "mpr.dll" );
dll << DeclareFunction(
     "WNetGetUserA",
      Convention( STDCALL ),
      Alias ( "GetUserName" ),
      Arg( UInt8, "format", input ),
      Arg( AnsiString, "username", output ),
      Arg( UInt64, "length", update ),
      Returns( UInt32 )
);
username = "                                                  ";
unlen = length(username);
result = dll << GetUserName(0, username, unlen);
show(username);
dll << UnloadDLL();
datenow=Long Date( Today() );
note="This Report was Generated by "||username||" on "||datenow;

reportlist= Get Window List(type("Reports")) << Get Window Title() ;
show(reportlist);

for (i=1 , i <= nitems(reportlist), i++,
	cr=window(reportlist[i] ) ;
	show(reportlist[i]);show(cr);
	cr<< bring window to front;
	cr << append( Text Box( note) );
);

 

@JohnPonte  Thanks for the username tips.

https://community.jmp.com/t5/Discussions/computer-name/m-p/3469#M3469

Recommended Articles