Professional Web Applications Themes

cannot get rid of whitespace - Macromedia ColdFusion

The following code writes a file to the server, however when I check the file that it writes it starts the written code on line 2 and leaves a whitespace where line 1 is. I have tried the cfsetting and the cfsilent way of removing the whitespace, does anybody have an idea for me please? See code: <cfsetting enablecfoutputonly="yes"> <cfsilent> <cfobject component="select" name="getModel"> <cfset biotext = getModel.GetModelData(URL.girlnum)> <cfset openBracket = Chr(60)> <cfset closeBracket = Chr(62)> <cfset openBold = openBracket & "b" & closeBracket> <cfset closeBold = openBracket & "/b" & closeBracket> <cfset openHeader = openBracket & "header" & closeBracket> <cfset ...

  1. #1

    Default cannot get rid of whitespace

    The following code writes a file to the server, however when I check the file
    that it writes it starts the written code on line 2 and leaves a whitespace
    where line 1 is. I have tried the cfsetting and the cfsilent way of removing
    the whitespace, does anybody have an idea for me please? See code:

    <cfsetting enablecfoutputonly="yes">
    <cfsilent>
    <cfobject component="select" name="getModel">
    <cfset biotext = getModel.GetModelData(URL.girlnum)>
    <cfset openBracket = Chr(60)>
    <cfset closeBracket = Chr(62)>
    <cfset openBold = openBracket & "b" & closeBracket>
    <cfset closeBold = openBracket & "/b" & closeBracket>
    <cfset openHeader = openBracket & "header" & closeBracket>
    <cfset closeHeader = openBracket & "/header" & closeBracket>
    <cfset openHeader2 = openBracket & "header2" & closeBracket>
    <cfset closeHeader2 = openBracket & "/header2" & closeBracket>
    <cfset openBody = openBracket & "body" & closeBracket>
    <cfset closeBody = openBracket & "/body" & closeBracket>
    </cfsilent>
    <cfoutput><cfset pageString = #biotext.girlnum# & "="></cfoutput>
    <cfset openBreak = openBracket & "br" & closeBracket>
    <cfset pageString = pageString & openHeader>
    <cfif biotext.LastName NEQ "">
    <cfoutput><cfset pageString = pageString & #UCase(#biotext.FirstName#&" "&
    #biotext.LastName#)#></cfoutput>
    <cfelse>
    <cfoutput><cfset pageString = pageString &
    #UCase(#biotext.FirstName#)#></cfoutput>
    </cfif>

    <cffile action = "write"
    file="#getDirectoryFromPath(getTemplatePath())##fi lename#.txt" output =
    "#pageString#">

    AkronNick Guest

  2. #2

    Default Re: cannot get rid of whitespace

    Have you checked that your Application.cfm is not generating any whitespace?
    You have to handle whitespace there as well.

    Incidentally you do not need the <cfoutputs> or the <cfsilent> in there either!

    Stressed_Simon Guest

  3. #3

    Default Re: cannot get rid of whitespace

    Actually at this point in the application I don't have an application.cfm page setup. What do you mean I don't need the <cfsilent> or <cfoutput> in there?
    AkronNick Guest

  4. #4

    Default Re: cannot get rid of whitespace

    Oh, I know what you mean.. yeah I am not sure why I put those in there, that's
    fixed now. Here is the code now, and I still get a whitespace but I need the
    text file to write starting on line 1, do you have any other ideas Simon?

    <cfobject component="select" name="getModel">
    <cfset biotext = getModel.GetModelData(URL.girlnum)>
    <cfset openBracket = Chr(60)>
    <cfset closeBracket = Chr(62)>
    <cfset openBold = openBracket & "b" & closeBracket>
    <cfset closeBold = openBracket & "/b" & closeBracket>
    <cfset openHeader = openBracket & "header" & closeBracket>
    <cfset closeHeader = openBracket & "/header" & closeBracket>
    <cfset openHeader2 = openBracket & "header2" & closeBracket>
    <cfset closeHeader2 = openBracket & "/header2" & closeBracket>
    <cfset openBody = openBracket & "body" & closeBracket>
    <cfset closeBody = openBracket & "/body" & closeBracket>
    <cfset pageString = #biotext.girlnum# & "=">
    <cfset openBreak = openBracket & "br" & closeBracket>
    <cfset pageString = pageString & openHeader>
    <cfif biotext.LastName NEQ "">
    <cfset pageString = pageString & #UCase(#biotext.FirstName#&" "&
    #biotext.LastName#)#>
    <cfelse>
    <cfset pageString = pageString & #UCase(#biotext.FirstName#)#>
    </cfif>
    <cfset pageString = pageString & chr(10) & closeBody>
    <cffile action = "write"
    file="#getDirectoryFromPath(getTemplatePath())##bi otext.girlnum#.txt" output =
    "#pageString#">

    AkronNick Guest

  5. #5

    Default Re: cannot get rid of whitespace

    OK once you put the <cfsetting enablecfoutputonly="yes"> only content inside a
    <cfoutput> will be displayed. So putting <cfsilent> doesn't add anything as you
    don't need the <cfoutput> around the <cfset> tags.

    If you wan to generate variable names just use <cfset "#variable#" =
    ..............>

    Stressed_Simon Guest

  6. #6

    Default Re: cannot get rid of whitespace

    I gotcha on that, thanks, but why do I get a whitespace in the text file for
    line 1, and also a whitespace after the last line of text. The last line
    doesn't matter to me, but the first one does, it's very important that the text
    generated start on line 1 and it won't.

    AkronNick Guest

  7. #7

    Default Re: cannot get rid of whitespace

    For those that give a rats.. I added this tag and that took care of the
    whitespace at the top of the file, I guess not many people use that or
    something..but it works for me. <cfprocessingdirective
    SUPPRESSWHITESPACE='Yes'>

    AkronNick Guest

  8. #8

    Default Re: cannot get rid of whitespace

    The root of your problem is this line (if my assumptions are correct about
    getModel):

    <cfset biotext = getModel.GetModelData(URL.girlnum)>

    I'm assuming getModel is a CFC, and GetModelData doesn't have output="no" as
    part of it's function declaration. That means what you're getting stored in
    biotext has a blank line appended to it.

    Try it:
    <cfset biotext = getModel.GetModelData(URL.girlnum)>
    <cfoutput>::Start::#biotext#::End::</cfoutput>

    then view the source. It should look something like this:
    ::Start::
    biotextstuff::End::

    Kronin555 Guest

  9. #9

    Default Re: cannot get rid of whitespace

    originally I thought that the processingdirective tag worked, it didnt.. then
    you posted this and i got excited thinking it would work, it didn't work
    either.. but you are right I didn't have output='false' in the component
    function.. any other ideas? i cannot believe it is this hard to make sure
    there is not a whitespace at the top of the file that cold fusion is writing to
    the server....

    AkronNick Guest

  10. #10

    Default Re: cannot get rid of whitespace

    Have you checked the CF Administrator settings? I thought there is a switch
    in there. I believe that Forta's WACK has more information. hth

    -brian

    "AkronNick" <webforumsusermacromedia.com> wrote in message
    news:d36gaj$mbq$1forums.macromedia.com...
    > originally I thought that the processingdirective tag worked, it didnt..
    then
    > you posted this and i got excited thinking it would work, it didn't work
    > either.. but you are right I didn't have output='false' in the component
    > function.. any other ideas? i cannot believe it is this hard to make sure
    > there is not a whitespace at the top of the file that cold fusion is
    writing to
    > the server....
    >

    Brian Hogue Guest

  11. #11

    Default Re: cannot get rid of whitespace

    I actually had a problem building my string, that's what ed up my white
    space at the top and the bottom. I had an extra &amp; chr(10) in there
    somewhere and it made a difference because it was before the string.. bla bla
    bla.. it was a tiny coding error that ed up things. Thanks for the help
    everybody!

    AkronNick Guest

Similar Threads

  1. CFC getter and whitespace
    By BSterner in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: July 16th, 12:52 AM
  2. Whitespace Problems
    By JakeFlynn in forum Macromedia ColdFusion
    Replies: 3
    Last Post: June 22nd, 09:52 PM
  3. Preserve whitespace
    By Mike in forum ASP.NET Web Services
    Replies: 1
    Last Post: April 21st, 10:44 AM
  4. get rid of whitespace around pipes??
    By Jeff 'Japhy' Pinyan in forum PERL Beginners
    Replies: 3
    Last Post: December 17th, 04:26 PM
  5. Trimming Whitespace
    By Sean Levesley in forum Macromedia Director Basics
    Replies: 3
    Last Post: August 22nd, 10:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139