Author Topic: PHP Help code copying  (Read 582 times)

0 Members and 1 Guest are viewing this topic.

Offline ocpaul20Topic starter

  • Enthusiast
  • Posts: 153
  • Gender: Male
    • View Profile
    • What Causes Stress?
PHP Help code copying
« on: September 08, 2010, 11:37:40 PM »
I have posted a piece of PHP demostrating a problem with thresholding images. When I try and copy it (Like I hope other will do to see what I am talking about), I get 3 newlines in between each statement line.

This is probably why I have no replies - but I can handle that...

The suggestion is to remind us(me!) that if we want to post code as an illustration of our problem then the bbcode php tag is fine, but if we want others to copy and paste our code, then this method is useless as far as I can see, because of all the extra newlines inserted between statements when pasted into a text editor.

This is just a moan and a suggestion, so dont take too much notice of it. :-)

Offline Jaysonic

  • Fanatic
  • Posts: 3,332
  • Gender: Male
  • 8548863
    • View Profile
    • I Am Lewy Babes
Re: PHP Help code copying
« Reply #1 on: September 09, 2010, 12:09:28 AM »
It doesn't always do it, at least not for me. Most times it copies correctly, other times it adds in the extra new lines. I put it down to the OPs editor usually.
Good luck with your coding.
Jason ~ ProjectFear ~ Jaysonic (and variations of... :))

Offline ocpaul20Topic starter

  • Enthusiast
  • Posts: 153
  • Gender: Male
    • View Profile
    • What Causes Stress?
Re: PHP Help code copying
« Reply #2 on: September 09, 2010, 07:42:59 PM »
On other forums the 'code' bbcode tag works better for me. I use linux and so editors recognise CR and NL as different from windows I suppose.

Offline DavidAM

  • Devotee
  • Posts: 1,026
  • Gender: Male
    • View Profile
Re: PHP Help code copying
« Reply #3 on: September 09, 2010, 09:27:59 PM »
It seems to me that this happens when there are TAB characters (char(9)) in the code tags. I gather it is the difference between the OP using copy & paste to post the code vs. just typing the code or copying from an editor that has replaced tabs with spaces.  It is a pain in the ... rear.  There was a time when this did not happen and then there was an update to the forum software and it starting happening. Maybe it has something to do with the javascript on this container and the paste function. All I know is, it is a pain in the ... rear.

The first code block below has TAB characters in it.  The second code block uses SPACEs

// This is just a line all by itself
	
One tab before this line ...
None here ...
	
	
two here
// The End


// This is just a line all by itself
    
One tab before this line ...
None here ...
        
two here
// The End


I just did a little test, and when I copy the code out of the first box and paste in my favorite editor, it puts one \n (newline) before the first \t (TAB) (that's in addition to the newline that is on the previous line) and TWO newlines ("\n") after EVERY TAB.

Did I mention that this is a pain in the ... rear?
-- I haven't lost my mind, it's backed up on tape ... somewhere!

Online Adam

  • Guru
  • Fanatic
  • *
  • Posts: 4,699
  • Gender: Male
    • View Profile
Re: PHP Help code copying
« Reply #4 on: September 10, 2010, 09:10:35 AM »
Perhaps suggest to SMF they should incorporate a fix for this in their next release?
Ronnie Wood, true or false?

Offline ocpaul20Topic starter

  • Enthusiast
  • Posts: 153
  • Gender: Male
    • View Profile
    • What Causes Stress?
Re: PHP Help code copying
« Reply #5 on: September 11, 2010, 07:13:35 PM »
Yes, this would be good to fix.

It does seem like it is TABs which make it happen and the example illustrates it very well.
Thanks for the explanation

Still no reply to my image thresholding problem though - it seems no-one has come across it or has any solution. :-(