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 3124 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
[Solved] UserID attached to report filenames?
Jan 30th, 2008 at 6:54pm
Print Post Print Post  
Is there a way to have a UserID added to the report filename (the html file) that is generated when a report is run?
« Last Edit: Feb 2nd, 2008 at 12:48am by Hammer »  

**
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: UserID attached to report filenames?
Reply #1 - Jan 30th, 2008 at 6:55pm
Print Post Print Post  
Infinity wrote on Jan 30th, 2008 at 6:54pm:
Is there a way to have a UserID added to the report filename (the html file) that is generated when a report is run?

Not if you're running it manually. If you are running it in code using@PrintAReport, you can.
  

- 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: UserID attached to report filenames?
Reply #2 - Jan 30th, 2008 at 7:05pm
Print Post Print Post  
Most of my reports are run via command buttons, and all the reports that I would need this for are done this way.

Here is the code I am using for my "Monthly Billed" button:
Code
Select All
// Prints the expanded Monthly Billing report for this month

Var vPrintTheReport as string

IF NOT @Mode() = 0
THEN
	{
	vPrintTheReport = @PrintAReport(".     Monthly Billed, this month", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
	}
ELSE @MSGBOX("Reports can only be run in Update mode", "Please switch to Update and", "select the records you wish to run the report on.") 



Looking at the book, page 330, it seems like I would have to do something with vFilename, but I'm not sure what.  Thanks for your help Erika.
  

**
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: UserID attached to report filenames?
Reply #3 - Jan 30th, 2008 at 7:48pm
Print Post Print Post  
Infinity wrote on Jan 30th, 2008 at 7:05pm:
Looking at the book, page 330, it seems like I would have to do something with vFilename, but I'm not sure what.  Thanks for your help Erika.

You probably want to use @Shell or CreateAProcess to issue a command to your system to rename the file from vFilename to @UserID + "_" + vFilename. Or something like that, depending on what you are trying to do.
  

- 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: UserID attached to report filenames?
Reply #4 - Jan 30th, 2008 at 8:07pm
Print Post Print Post  
Hmmm.  OK.  All I need is a simple Rename command.  My @PrintAReport code creates the filename as vPrintTheReport, and in Global code I've set a static variable sUserID = @UserID.  So the command would be something like

Code
Select All
REN F:\Sesame\Reports\vPrintTheReport vPrintTheReport+"_"+sUserID 



I don't think CreateAProcess is the way to go, probably @Shell.  I'm not sure how I can wrap the quotes into it, though.  OK, so maybe use another variable that adds them.  So I've got:
Code
Select All
var vUnderline as string
vUnderline = "_" 



So then it becomes

Code
Select All
REN F:\Sesame\Reports\vPrintTheReport vPrintTheReport+vUnderline+sUserID 



Would this work?

Code
Select All
var vRenameTheFile as Int

vRenameTheFile = @Shell("REN F:\Sesame\Reports\vPrintTheReport vPrintTheReport+vUnderline+sUserID") 



I'll give it a try.  In the meantime, if you see something glaringly wrong please hit me with a clue-by-four.  Thanks!
  

**
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: UserID attached to report filenames?
Reply #5 - Jan 30th, 2008 at 8:20pm
Print Post Print Post  
Hello Scott,

I'm pretty certain the filename returned by @PrintAReport includes the .htm file extenstion. So you'll need to cat the user id into the name before then.

Also
Code
Select All
vRenameTheFile = @Shell("REN F:\Sesame\Reports\vPrintTheReport vPrintTheReport+vUnderline+sUserID") 



Will rename a file named "vPrintTheReport" to be "vPrintTheReport+vUnderline+sUserID" as it is all in quotes those are literals and not variables.

-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: UserID attached to report filenames?
Reply #6 - Jan 30th, 2008 at 8:21pm
Print Post Print Post  
D'oh!

Trying this:
Code
Select All
// Prints the Over 30 Days by Customer report

Var vPrintTheReport as string

// Testing file rename procedure
Var vUnderline as String
var vRenameTheFile as Int
// Testing

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",
		"")

// Testing file rename procedure
vUnderline = "_"

vRenameTheFile = @Shell("REN F:\Sesame\Reports\vPrintTheReport F:\Sesame\Reports\sUserID+vUnderline+vPrintTheReport")
//Testing
 



The command box flashes by pretty quickly, but I think it's telling me "cannot find file specified".
  

**
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: UserID attached to report filenames?
Reply #7 - Jan 30th, 2008 at 8:26pm
Print Post Print Post  
Scott,

There's a lot you need to adjust.

1. @PrintAReport returns the full path.
2. If you add the UserID onto the end, you will mess up the extension.

Try adjusting this to your needs:

Code
Select All
var vReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int

	vReport = @PrintAReport("emy", 1, 1, 0, -1, -1, -1, -1, -1, -1)

	// Get just the filename off the full path
	vTemp = @ReplLas(vReport, "\", "^")
	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) + vReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34))

 

  

- 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: UserID attached to report filenames?
Reply #8 - Jan 30th, 2008 at 8:41pm
Print Post Print Post  
Erika,

That works like a champ!  I'm going to have to study it for a while to understand what you've done, dissecting the filename and all that, but thank you so much!

My next goal is to make it a subroutine.  WOO HOO!

Would using CreateAProcess instead of @Shell eliminate the flash of the command window?
  

**
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: UserID attached to report filenames?
Reply #9 - Jan 30th, 2008 at 8:49pm
Print Post Print Post  
Infinity wrote on Jan 30th, 2008 at 8:41pm:
Would using CreateAProcess instead of @Shell eliminate the flash of the command window?


I believe so. However, since REN is built into the command shell, you need to call cmd itself with the /C switch. Like this:

Code
Select All
CreateAProcess("CMD /C REN " + @Chr(34) + vReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34)) 

  

- 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: UserID attached to report filenames?
Reply #10 - Jan 30th, 2008 at 9:21pm
Print Post Print Post  
Nope, still flashes, but that's OK as it's very quick.  I can live with it, and I'll go back to using @Shell.

It's resisting my attempts at a functioning subroutine, however.  I think it has something to do with the variables.  Still working on it.
  

**
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: UserID attached to report filenames?
Reply #11 - Jan 30th, 2008 at 9:28pm
Print Post Print Post  
Infinity wrote on Jan 30th, 2008 at 9:21pm:
Nope, still flashes, but that's OK as it's very quick.  I can live with it, and I'll go back to using @Shell.

In this case, you are using the cmd process itself, so it is going to make a shell window flash no matter what.
  

- 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: UserID attached to report filenames?
Reply #12 - Jan 30th, 2008 at 9:32pm
Print Post Print Post  
Yep.  Thanks for your help.  I'm going to work on the subroutine some more tomorrow.  If I can get it to work I'll tag it onto all my report-generating buttons.
  

**
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 #13 - Feb 5th, 2008 at 2:38pm
Print Post Print Post  
Well, I'm stumped as to how to make this a functional subroutine.  I've declared the variables in both the subroutine code and in the element code, but it just doesn't want to work.  Any idea what I'm missing?
  

**
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 #14 - Feb 5th, 2008 at 2:45pm
Print Post Print Post  
Infinity wrote on Feb 5th, 2008 at 2:38pm:
Well, I'm stumped as to how to make this a functional subroutine.  I've declared the variables in both the subroutine code and in the element code, but it just doesn't want to work.  Any idea what I'm missing?

Not without seeing what you've got. Can you show me the code?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print