ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 9th, 2012, 09:22 PM
new2cfrb new2cfrb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 59 new2cfrb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 27 m 24 sec
Reputation Power: 4
Cfdocument and variables

I'm creating a PDF from Flash which I then print using cfprint. A simplified version of the function is:

<cffunction name="printPO" access="remote" output="false">
<cfargument name="p1" type="string" required="yes">
<cfset replyStruct = StructNew()>
<cfdocument format="pdf" name="poPdf">
<P>#p1#</P>
<h3><U>FROM:</U></h3>
<P>testcompany,<BR>
4 Smith Street,<BR>
Melbourne, Victoria,<BR>
Australia 3000<BR>
</cfdocument>
<cfprint source="poPdf" printer="hp LaserJet 4300">
<cfset replyStruct.status = "ALLOK">
<cfset replyStruct.param = #p1#>
<cfreturn replyStruct>
</cffunction>

The whole process essentially works with the p1 parameter being passed back correctly and the pdf printing. The problem is that the p1 variable prints as the literal 'p1' instead of the contents of the variable p1. I presume I'm defining it incorrectly, so what is the correct syntax? Do I need to use cfoutput in order to 'evaluate' the variables?

Reply With Quote
  #2  
Old December 10th, 2012, 01:55 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
Try wrapping it in cfoutput, and also confirm with logging or cfdump that the value of p1 is what you think it is, and isn't actually the string value "p1".

Reply With Quote
  #3  
Old December 10th, 2012, 03:19 AM
new2cfrb new2cfrb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 59 new2cfrb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 27 m 24 sec
Reputation Power: 4
kiteless to the rescue again! Thanks mate, I think I'm in danger of getting the hang of this now.

Reply With Quote
  #4  
Old December 11th, 2012, 11:12 PM
cfSearching cfSearching is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 117 cfSearching User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 16 m 2 sec
Reputation Power: 6
As an aside, do not forget to VAR/LOCAL scope all of your function local variables. It is also a good practice to scope all variables ie "arguments.p1" instead of "p1".

Not tested, but something along these lines


Code:
<cffunction name="printPO" access="remote" output="false">
    <cfargument name="p1" type="string" required="yes">

    <cfset VAR replyStruct = StructNew()>
    <cfset VAR poPdf = "">

    <cfdocument format="pdf" name="poPdf">
        <P>#arguments.p1#</P>
        <h3><U>FROM:</U></h3>
        <P>testcompany,<BR>
        4 Smith Street,<BR>
        Melbourne, Victoria,<BR>
        Australia 3000<BR>
    </cfdocument>
    <cfprint source="poPdf" printer="hp LaserJet 4300">
    <!--- "look Ma, no # signs" ---> 
    <cfset replyStruct.status = "ALLOK">
    <cfset replyStruct.param = arguments.p1>

    <cfreturn replyStruct>
</cffunction>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Cfdocument and variables

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap