Jump to content

Clean code when doing FileWrite with many lines


Alterego
 Share

Recommended Posts

I'm doing some screen scraping and generating some rss feeds. Is there a way to extend FileWrite over many lines so my line isn't so long (eg the entire feed )? I gave it a couple whacks but just got run errors.

Example:

FileWrite($f,'<?xml version="1.0"?>' & @CRLF & '<rss version="2.0">' & @CRLF & '   <channel>' & @CRLF & '     <title>widget widget widget</title>' & @CRLF &'     <link>http://widgets.com</link>' & @CRLF & '

only much much longer...the biggest problem with this aside from readability is that Scite only scrolls so far unless I use the end key with my cursor on the line

Link to comment
Share on other sites

Here's the rss feed autoit is now creating...the entire thing is on the FileWrite line you see above...it's a real pain to troubleshoot and enhance!

my method is to have it sleep for 9,000,000 milliseconds on my computer, check the date of the last update via some fancy string manipulation, read/write to an ini and publish a new feed if its more recent using curl to my server..

but man that's a long line...

Link to comment
Share on other sites

Why not just have it check every minute or so? I can't see a simple check like that getting in the way, and I hate having to wait :lmao: just my thought on that little bit of your script.

As for making a clean filewrite, you can extend lines via the _ delimeter, like so:

FileWrite($f,'<?xml version="1.0"?>' & @CRLF & _
'<rss version="2.0">' & @CRLF & _ 
'   <channel>' & @CRLF & _ 
'     <title>widget widget widget</title>' & @CRLF & _
'     <link>http://widgets.com</link>' & @CRLF & '
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

only much much longer...the biggest problem with this aside from readability is that Scite only scrolls so far unless I use the end key with my cursor on the line

For Scite.

Add this to User Options:

horizontal.scroll.width=7000
Change the number to suit the width suitable.

:lmao:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...