Jump to content
Sign in to follow this  
nobbe

a string with original formatting over more than 1 line?

Recommended Posts

nobbe

hi

is it possible to have something like "qq" as in perl in autoit??

example : a string over more than 1 line, keeping formatting and quotes intact?

comes handy if you like to use original text as string values..

$test=qq~
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body onload="start()"><div style="position:absolute; z-index:10; left:188px; top:0px;  height:60px;"><iframe  allowtransparency="true" scrolling="no" hspace="0" vspace="0" frameborder="0" marginheight="0" marginwidth="0" src="ad/un/ads.php" width="468" height="60"></iframe></div><div style="position:absolute; background-color:#747273; left:0px; top:0px; width:100%; height:60px;">
~;

Share this post


Link to post
Share on other sites
/dev/null

Not implemented. I asked the same questions some time ago. There is no interest to implement it.


__________________________________________________________(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 *

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

There is no interest to implement it.

Glup! I am VERY interesting by this implementation.

Litteral string multi-line is implemented in many languages (Python "triple-quot", Ruby, Perl, Object-PAL, etc.)

In use, it's very very very good/useful/funny/smart.

When this possibility will be implemented in AutoIt!, I use it more often.

Share this post


Link to post
Share on other sites
kjactive

There is a solution though, make all into a variable, I offen do this when working with HTML hybrid coding...

$a = '$test=qq~'
$a = $a & '<meta http-equiv="imagetoolbar" content="no">'
$a = $a & '<meta http-equiv="content-type" content="text/html; charset=UTF-8">'
$a = $a & '</head>'
$a = $a & '<body onload="start()"><div style="position:absolute; z-index:10; left:188px; top:0px;  height:60px;"><iframe  '
$a = $a & 'allowtransparency="true" scrolling="no" hspace="0" vspace="0" frameborder="0" marginheight="0" ' 
$a = $a & 'marginwidth="0"'
$a = $a & 'src="ad/un/ads.php" width="468" height="60"></iframe></div><div style="position:absolute; background-'
$a = $a & 'color:#747273; left:0px; top:0px; width:100%; height:60px;">'
$a = $a & '~;'

The variable wrap can be made automatically as a Do / Until loop

The HTML code is now $a variable ready to get fired, a walk around but works fine...

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites
SmOke_N

There is a solution though, make all into a variable, I offen do this when working with HTML hybrid coding...

$a = '$test=qq~'
$a = $a & '<meta http-equiv="imagetoolbar" content="no">'
$a = $a & '<meta http-equiv="content-type" content="text/html; charset=UTF-8">'
$a = $a & '</head>'
$a = $a & '<body onload="start()"><div style="position:absolute; z-index:10; left:188px; top:0px;  height:60px;"><iframe  '
$a = $a & 'allowtransparency="true" scrolling="no" hspace="0" vspace="0" frameborder="0" marginheight="0" ' 
$a = $a & 'marginwidth="0"'
$a = $a & 'src="ad/un/ads.php" width="468" height="60"></iframe></div><div style="position:absolute; background-'
$a = $a & 'color:#747273; left:0px; top:0px; width:100%; height:60px;">'
$a = $a & '~;'

The variable wrap can be made automatically as a Do / Until loop

The HTML code is now $a variable ready to get fired, a walk around but works fine...

kjactive :)

In my experience...

$a &= xxxoÝ÷ ØjË^®ØZ«­¢+ØÀÌØíôÀÌØíµÀìáá

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
kjactive

In my experience...

$a &= xxxoÝ÷ ØjË^®ØZ«­¢+ØÀÌØíôÀÌØíµÀìáá
True but the string gets to long for autoit3 to handle - it's a walk around...

I just discovered that this should function to...

Func ChangeHtmlCodeIntoVariable($HTML_code)
Return '$a = ' & StringReplace($HTML_code,@CRLF, @CRLF & '$a = $a & ')
EndFunc

Anyway in Theory it does...

kjactive :)

Share this post


Link to post
Share on other sites
nobbe

hi

i found the only thing to get it to work is to read it char by char from a tempfile ..

reading all lines with filereadline doesnt work either, the string gets too long ...

$file = FileOpen(".\htm\temp.htm", 0) 
$test = "";
; Read in 1 character at a time until the EOF is reached
While 1
    $chars = FileRead($file, 1)
    If @error = -1 Then ExitLoop
    $test = $test & $chars

    ;    MsgBox(0, "Char read:", $chars)

WEnd
FileClose($file)

MsgBox(0, "test ", $test)

Share this post


Link to post
Share on other sites
kjactive

found the only thing to get it to work is to read it char by char from a tempfile ..

reading all lines with filereadline doesnt work either, the string gets too long ...

There is no size limits to $allchars = FileRead(...,...) it's related to all the string functions etc....

What about like I do:

$ID = FileOpen(HTMLFile.htm,0)
$a = FileReadLine($ID)
While 1
      $line = FileReadLine($ID)
       If @error Then Exitloop
; do the string manipulation here to the variable $Line.....
 $a = $a & $Line
WEnd
FileClose($ID)
; The variable $a can now be toshed to a HTML component or to CWebpage.dll - what ever one wants

This function truely works but it's a walk around

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

Compare these three source-code:

AutoIt:

$st=""
$st &= "ldest=[" & @CRLF
$st &= "'toto@toto.com'," & @CRLF
$st &= "'titi@toto.com'," & @CRLF
$st &= "'gros.minet@titi.com'" & @CRLF
$st &= "]" & @CRLF
$st &= "for d in ldest:" & @CRLF
$st &= "    mailfiles('meme@tutu.com'," & @CRLF
$st &= "              d," & @CRLF
$st &= "              []," & @CRLF
$st &= "              ""I'm sorry""," & @CRLF
$st &= "              ""Y're my favorite dest..."" " & @CRLF
$st &= "    )"

Perl:

$st=qq~
ldest=[
'toto@toto.com',
'titi@toto.com',
'gros.minet@titi.com'
]
for d in ldest:
    mailfiles('meme@tutu.com', 
              d, 
              [],
              "I'm sorry", 
              "Y're my favorite dest..."
    )
~;

Python:

sr="""
ldest=[
'toto@toto.com',
'titi@toto.com',
'gros.minet@titi.com'
]
for d in ldest:
    mailfiles('meme@tutu.com', 
              d, 
              [],
              "I'm sorry", 
              "Y're my favorite dest..."
    )
"""

And choose:

- the more unreadable?

- the more difficult to type?

AutoIt can evolve.

If AutoIt evolve, it will a good thing for humanity :):D

Share this post


Link to post
Share on other sites
nobbe

There is no size limits to $allchars = FileRead(...,...) it's related to all the string functions etc....

What about like I do:

$ID = FileOpen(HTMLFile.htm,0)
$a = FileReadLine($ID)
While 1
      $line = FileReadLine($ID)
       If @error Then Exitloop
; do the string manipulation here to the variable $Line.....
 $a = $a & $Line
WEnd
FileClose($ID)
; The variable $a can now be toshed to a HTML component or to CWebpage.dll - what ever one wants

This function truely works but it's a walk around

kjactive :)

hi

its true that the variable is not limited in length, but the function FileReadLine() fails on LONG lines . thats why i read the file char by char..

Share this post


Link to post
Share on other sites
kjactive

hi

its true that the variable is not limited in length, but the function FileReadLine() fails on LONG lines . thats why i read the file char by char..

I never seen it and I used this function to manipulate a lot of HTML code, a line here is seldom longer than 4695 characters....

Limits:

MAX_LINESIZE 4095 characters - Maximum size for a line of script.

STRBUFFER 4095 characters - Size of a general string buffer.

CMDLINEPARAM_MAXLEN 4096 characters - Each parameter can be this many characters.

kjactive :)

Edited by kjactive

Share this post


Link to post
Share on other sites
jvanegmond

I know this is dumb.. But it works anyway:

#cs
this is
a test string
split over multiple lines
#ce

$cookie = ScriptReadLines(2,4)
MsgBox(0, "", $cookie )

Func ScriptReadLines($sLineStart,$sLineEnd)
    If @Compiled Then 
        SetError(1)
        Return 0
    EndIf
    Local $sReturn
    $sScript = FileOpen(@ScriptFullPath,0)
    For $x = $sLineStart To $sLineEnd
        $sReturn &= FileReadLine($sScript,$x) & @CRLF
    Next
    FileClose($sScript)
    Return $sReturn
EndFunc

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.