Page Index Toggle Pages: 1 [2]  Send Topic Send Topic Print Print
Very Hot Topic (More than 25 Replies) [Solved] UserID attached to report filenames? (Read 3117 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #15 - Feb 5th, 2008 at 3:07pm
Print Post Print Post  
This code works beautifully in the element programming:
Code
Select All
// Prints the Over 30 Days by Customer report

var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int


IF NOT @Mode() = 0
THEN
	{
	vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
	}
ELSE @MSGBOX("This Report can only be run in Update mode",
		"Please switch to Search/Update and try again",
		"")


// File rename procedure
	// Get just the filename off the full path
	vTemp = @ReplLas(vPrintTheReport, "\", "^")
	vPos = @Instr(vTemp, "^")
	vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)

	// Make the new filename
	vNewFilename = @UserID + "_" + vFilename

	// Issue the rename command
	vShell = @Shell("REN " + @Chr(34) + vPrintTheReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34)) 



I've messed around with numerous permutations, but what I started with was putting this in Global code:
Code
Select All
SUBROUTINE ChangeReportFilename()
var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int

	// Get just the filename off the full path
	vTemp = @ReplLas(vPrintTheReport, "\", "^")
	vPos = @Instr(vTemp, "^")
	vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)

	// Make the new filename
	vNewFilename = @UserID + "_" + vFilename

	// Issue the rename command
	vShell = @Shell("REN " + @Chr(34) + vPrintTheReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34))
END SUBROUTINE 


And changing the element code to
Code
Select All
// Prints the Over 30 Days by Customer report

var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int



IF NOT @Mode() = 0
THEN
	{
	vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
	}
ELSE @MSGBOX("This Report can only be run in Update mode",
		"Please switch to Search/Update and try again",
		"")


ChangeReportFilename() 


  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] UserID attached to report filenames?
Reply #16 - Feb 5th, 2008 at 3:34pm
Print Post Print Post  
Scott,

You've got a scope problem. You need to pass the filename into the subroutine. Try something like this:

GLOBAL CODE
Code
Select All
SUBROUTINE ChangeReportFilename(vFilenameIn as String)
var vTemp as String
var vNewFilename as String
var vFilename as String
var vPos as Int
var vShell as Int

	// Get just the filename off the full path
	vTemp = @ReplLas(vFilenameIn, "\", "^")
	vPos = @Instr(vTemp, "^")
	vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)

	// Make the new filename
	vNewFilename = @UserID + "_" + vFilename

	// Issue the rename command
	vShell = @Shell("REN " + @Chr(34) + vFilenameIn + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34))

END SUBROUTINE 



Element Code:
Code
Select All
// Prints the Over 30 Days by Customer report
var vPrintTheReport as String

	IF NOT @Mode() = 0 THEN
	{
		vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
		ChangeReportFilename(vPrintTheReport)
	}
	ELSE
	{
		@MSGBOX("This Report can only be run in Update mode", "Please switch to Search/Update and try again", "")
	}
 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #17 - Feb 5th, 2008 at 3:43pm
Print Post Print Post  
Marvelous, thank you so much.  I knew it was something like that, because I could see that the element programming was creating vPrintTheReport but the subroutine had no way of knowing what it was.  Writeln() tests kept coming up blank.  I had no idea you could pass the info back into the code that way, thanks for teaching me new stuff!!
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] UserID attached to report filenames?
Reply #18 - Feb 5th, 2008 at 3:45pm
Print Post Print Post  
Infinity wrote on Feb 5th, 2008 at 3:43pm:
I had no idea you could pass the info back into the code that way, thanks for teaching me new stuff!!

Time for me to schedule an Advanced Programming class in Boston?  Wink
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #19 - Feb 5th, 2008 at 3:52pm
Print Post Print Post  
I would jump at it!  I'm woefully deficient on stuff like subroutines, functions, arrays, result sets, and global values.  Just tell me where and when.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] UserID attached to report filenames?
Reply #20 - Feb 5th, 2008 at 4:06pm
Print Post Print Post  
Infinity wrote on Feb 5th, 2008 at 3:52pm:
I would jump at it!  I'm woefully deficient on stuff like subroutines, functions, arrays, result sets, and global values.  Just tell me where and when.

It's a two day class at $350 per day and I'd need at least four people to cover the various expenses. Got three more people?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #21 - Feb 6th, 2008 at 12:58pm
Print Post Print Post  
Quote:
It's a two day class at $350 per day and I'd need at least four people to cover the various expenses. Got three more people?

Not on me at the moment, sorry.  Undecided


In re: the process we've been dealing with above (renaming report files with user names attached) for anyone else considering this who may be reading:  if the user's browser is not open before running the report, it will fail to display when the browser does open, because, of course, the file has been renamed in the meantime and the browser cannot find what it's been told to open.

I'm trying to figure out a way, now, to process the report, rename it, and then display it in the browser.  I'm also considering submitting a feature request to Lantica for a way to automate all this.  Maybe an extra switch added to @PrintAReport allowing one to tag on a value or the contents of an element to a report name?  I can think of lots of uses for this, as the monkey-mass of reports in my Reports folder are just gibberish right now, though some of them could be significant and worth saving for repeated viewing if they were tagged in certain ways.
  

**
Captain Infinity
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: [Solved] UserID attached to report filenames?
Reply #22 - Feb 6th, 2008 at 3:05pm
Print Post Print Post  
Infinity wrote on Feb 6th, 2008 at 12:58pm:
I'm trying to figure out a way, now, to process the report, rename it, and then display it in the browser.

Why couldn't you use @AsynchShell(vNewFilename) at the end of the ChangeReportFilename subroutine?

EDIT:
I just noticed that vNewFilename doesn't contain the full path, so you may need to tag the path to the front of vNewFilename before using it in @AsynchShell().
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] UserID attached to report filenames?
Reply #23 - Feb 6th, 2008 at 5:10pm
Print Post Print Post  
Version 2.0.6 will make Carl's suggestion a bit easier.

I just added another Mode to @PrintAReport() and @XResultSetPrintReport() that creates the HTML report but does not print it or display it. It just creates it and returns the name of the file. So you can re-name it and display it in your case. or E-mail it, or FTP it automatically or any number of things that you can think of.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #24 - Feb 6th, 2008 at 6:23pm
Print Post Print Post  
That sounds great Ray, thanks.  And thanks to Carl, too, your suggestion was precisely what I had in mind to try, although (until Ray tinkered with it) I couldn't think of a way to suppress the initial report presentation.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #25 - Feb 11th, 2008 at 6:35pm
Print Post Print Post  
Ray, about the Mode change you made, if I want to rename the file will I still need to open a shell window?  If not is there, or could there be, a way to manipulate the filename before it is saved to disk (thereby eliminating the shell window)?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] UserID attached to report filenames?
Reply #26 - Feb 11th, 2008 at 7:13pm
Print Post Print Post  
Hello Scott,

Yes you will still need to use a shell window to rename the file.

The change I made to 2.0.6 was simply to add another mode to the 4 that were already there. So now the options for Mode are

Code
Select All
#define REPORT_MODE_HTML		0
#define REPORT_MODE_HTML_PREVIEW	1
#define REPORT_MODE_PRINT_ONLY		2
#define REPORT_MODE_PRINT_ONLY_PREVIEW	3
#define REPORT_MODE_HTML_GENERATE	4 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send Topic Send Topic Print Print