Jump to content

Long strings into a variable


Recommended Posts

Some time back I think I saw an AutoIt sample script that assigned a long, multiline string to a variable using syntax like this:

$strLongString = "<HTML>

<HEAD>

</HEAD>

<BODY>

This is the body.

</BODY><HTML>"

At the time I thought "Dang, that's clever" - but I have since forgotten how it was done. I recently wrote a Perl script that used q to feed a lot of raw HTML into a variable and thought about this again.

Can anyone think of how to do this - feed raw text into a variable without using quotes and continuation characters?

Thanks bunches.

Bluebearr

BlueBearrOddly enough, this is what I do for fun.
Link to comment
Share on other sites

Some time back I think I saw an AutoIt sample script that assigned a long, multiline string to a variable using syntax like this:

$strLongString = "<HTML>

<HEAD>

</HEAD>

<BODY>

This is the body.

</BODY><HTML>"

At the time I thought "Dang, that's clever" - but I have since forgotten how it was done. I recently wrote a Perl script that used q to feed a lot of raw HTML into a variable and thought about this again.

Can anyone think of how to do this - feed raw text into a variable without using quotes and continuation characters?

Thanks bunches.

Bluebearr

Do you mean something like...?

$strLongString = "<HTML>" & @CRLF & "<HEAD>" & @CRLF & "<BODY>" & @CRLF & _
"This is the body." & @CRLF & "</BODY>" & @CRLF & "<HTML>"

Or

$strLongString = "<HTML>" & @CRLF & _
"<HEAD>" & @CRLF & _
"<BODY>" & @CRLF & _
"This is the body." & @CRLF & _
"</BODY>" & @CRLF & _
"<HTML>"

Or am I completely missing the point?

Link to comment
Share on other sites

Some time back I think I saw an AutoIt sample script that assigned a long, multiline string to a variable using syntax like this:

you probably remember my post some time back: http://www.autoitscript.com/forum/index.ph...topic=12378&hl=

I suggested to implement perl "here documents" in AutoIT because I was missing that feature.

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Some time back I think I saw an AutoIt sample script that assigned a long, multiline string to a variable using syntax like this:

$strLongString = "<HTML>

<HEAD>

</HEAD>

<BODY>

This is the body.

</BODY><HTML>"

At the time I thought "Dang, that's clever" - but I have since forgotten how it was done. I recently wrote a Perl script that used q to feed a lot of raw HTML into a variable and thought about this again.

Can anyone think of how to do this - feed raw text into a variable without using quotes and continuation characters?

Thanks bunches.

Bluebearr

you could use an external file to hold the html then use:

$HtmlCode = FileRead("C:\htmlfile.html",FileGetSize("C:\htmlfile.html"))
Link to comment
Share on other sites

you could use an external file to hold the html then use:

Yeah, I dislike using an external file because inevitably you lose it, and then you have to test for it and/or store the contents in the script so you have a ready backup blah blah...

Thanks anyway. I ended up including it in the script, because I had to stick some text in the middle anyway & it was easier to just start with it in pieces than to break it up. I know I've written spreadsheets to add the "_ @CRLF & " stuff but I couldn't place it (lazy Friday).

It's a cool script - it monitors an IP address to see if it's pingable. If it isn't, it sets a flag, and then waits for it to be pingable again. When it's pingable again it loads a web page that sends me a text page. This is so I can know that my VPN connection got broken and and that I need to reauthenticate so my huge download can continue...

Peace,

BlueBearr

BlueBearrOddly enough, this is what I do for fun.
Link to comment
Share on other sites

Yeah, I dislike using an external file because inevitably you lose it, and then you have to test for it and/or store the contents in the script so you have a ready backup blah blah...

Thanks anyway. I ended up including it in the script, because I had to stick some text in the middle anyway & it was easier to just start with it in pieces than to break it up. I know I've written spreadsheets to add the "_ @CRLF & " stuff but I couldn't place it (lazy Friday).

It's a cool script - it monitors an IP address to see if it's pingable. If it isn't, it sets a flag, and then waits for it to be pingable again. When it's pingable again it loads a web page that sends me a text page. This is so I can know that my VPN connection got broken and and that I need to reauthenticate so my huge download can continue...

Peace,

BlueBearr

you could fileinstall() the external file into your script, then you don't lose it...
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...