Jump to content
UnknownUser

Really Long Line - (Moved)

Recommended Posts

Hello,

I'm programming an automated email and have a line that is really long.  I am using SciTE as my console.   Here is that line in test.  

$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $aArray2[$i][3], $Subject, "This is a form letter meant for " & $aArray2[$i][1] &" "& $aArray2[$i][2]&"." & @CRLF & "The letters in "& $aArray2[$i][1] &" "& $aArray2[$i][2] & "'s first name are " &  $aArray2[$i][4] &" " & $aArray2[$i][5] &" "&$aArray2[$i][6] &" "& $aArray2[$i][7] &" "&$aArray2[$i][8] &" "& $aArray2[$i][9] & @CRLF & chr(13) & "Thank you." & chr(13) & " ", $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) 

The body of the email that the $rc function is creating begins after $Subject and ends after chr(13) & " ",. That body is the primary cause of the length.  When this goes live, I can easily see adding 3000+ characters to this line.  Is there a line limit?  Is there a way to wrap text in SciTE?  Do you have a trick to break that line up into multiple lines for ease of coding and reading?

"Ideally I would like to be able to type text like this " & @CRLF &
"so that I could read what I am writing easily " & @CRLF &
"without having to keep scrolling to the right or " & @CRLF &
"to the left.  Scrolling is quite a pain in the neck " & @CRLF &
"and with 5000 characters, it might even become  " & @CRLF &
"a programming showstopper."

I am not able to pass this entire string as a variable because this string contains variables embedded in a for loop.  Thus, in so doing, I would multiplicate the loop.    I'll take any help I can get!

Share this post


Link to post
Share on other sites

Yes, you can wrap text in AutoIt with & _

and continue on the next line like this. Also, you could simply read a file that you store locally and replace specific sequences... like "|username|" with the actual user's name with StringReplace. I use water's OutlookEx UDF and do something similar with an Outlook template email.

Edit: That's a ampersand, a space, and an underscore there... kind of hard to see.

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

This help page lists AutoIt limits and defaults; the 3rd entry specifies 4095 chars as max linelength in scripts.

And welcome to the forums.:)

Share this post


Link to post
Share on other sites
; one line using continuation string
Global $sLongSingleLine
$sLongSingleLine = "Ideally I would like to be able to type text like this " & @CRLF & _
"so that I could read what I am writing easily " & @CRLF & _
"without having to keep scrolling to the right or " & @CRLF & _
"to the left.  Scrolling is quite a pain in the neck " & @CRLF & _
"and with 5000 characters, it might even become  " & @CRLF & _
"a programming showstopper."
MsgBox(0, "debug", $sLongSingleLine)



; basic approach avoiding character limit in single line
Global $sLongString
$sLongString = "Ideally I would like to be able to type text like this " & @CRLF
$sLongString &= "so that I could read what I am writing easily " & @CRLF
$sLongString &= "without having to keep scrolling to the right or " & @CRLF
$sLongString &= "to the left.  Scrolling is quite a pain in the neck " & @CRLF
$sLongString &= "and with 5000 characters, it might even become  " & @CRLF
$sLongString &= "a programming showstopper."
MsgBox(0, "debug", $sLongString)



; keeping the same basic format with the assumption that you want to iteratively parse variables later
Global $sLongStringWithVars
$sLongStringWithVars = "Ideally I would like to be able to type text like this " & @CRLF
$sLongStringWithVars &= "so that I could read what I am writing easily " & @CRLF
$sLongStringWithVars &= "without having to keep scrolling to $aArray2[$i][0] the right or " & @CRLF
$sLongStringWithVars &= "to the left.  Scrolling $aArray2[$i][1] is quite a pain in the neck " & @CRLF
$sLongStringWithVars &= "and with 5000 characters, it might even become  " & @CRLF
$sLongStringWithVars &= "a programming showstopper."

; some trivial substitutions to make
Global $aArray2[2][2] = [["Mr. Bob", "Yellow"], ["Mr. Fred", "Red"]]
Global $sLongStringWithVars_subs

; making the substitutions later in your code
; you can see how the search string could also be constructed by the loop, but hard coded here for clarity
For $i = 0 To 1
  $sLongStringWithVars_subs = StringReplace($sLongStringWithVars, "$aArray2[$i][0]", $aArray2[$i][0])
  $sLongStringWithVars_subs = StringReplace($sLongStringWithVars_subs, "$aArray2[$i][1]", $aArray2[$i][1])
  MsgBox(0, "debug", $sLongStringWithVars_subs)
Next

 

Edited by SlackerAl

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Share this post


Link to post
Share on other sites

Also take a look at Opt ("ExpandVarStrings", 1).  You can embed variables and macros directly into the string.  It doesn't work with arrays tho.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Professor_Bernd
      Hello.
      PSPad4AutoIt3 consists of the Editor PSPad and the Improvement Kit, and can be used as an portable Editor IDE for AutoIt3.
      The author of the PSPad Editor is Jan Fiala. I (Professor Bernd) am only the author of the Improvement Kit.
       
      After months of work, PSPad4AutoIt3 version 1.0.0 beta is now ready.  
      I like to call it the "first real" version, because the Improvement Kit now handles a lot of things autonomously. So PSPad remains operable when an au3 script is started. Also there is now a setup that makes the installation easier. 👍 And for those who don't like/do not want an installer, there is a download without setup. Without setup, the user has to take care of the prerequirements himself. Only recommended for experienced users.
      The core functionalities "Run, Check Syntax, Compile and Comile Dialog" are integrated and work very well. Thanks to @Jos for extending AutoIt3Wrapper!  There are also a few more features that you can find in the main menu, menu item "Scripts" => "_AutoIt". These include "Debug to Console", "Debug to MsgBox" and the "Koda FormDesigner" as a helper for creating GUIs. In this menu there is also an item "_Tips and shortcuts". After a click the AutoIt-relevant shortcuts are displayed.
      The language in the menu "_AutoIt" is English. The language for PSPad in general can be set for more than 40 languages (Main menu => Settings => Program Settings => Language).
      PSPad4AutoIt3 is in a beta stage and does not have many features yet. But I am working on it!
      More information (EN, DE) and the download can be found in my PSPad4AutoIt3 Projekt in the AutoIt.de forum.
      I would be glad if you have a look at it and write me your opinion. Have fun!
       
      2020-04-20 Note: The minimum version for AutoIt3 HAS TO BE 3.3.14.5!

      I had hoped that the changes would not be so severe, so in the downloads the minimum version 3.3.14.0 is still indicated. Unfortunately, it has recently become apparent that with older versions the main functions, e.g. CompilerRunner, the AutoIt3 Help and the upcoming CallTipViewer, fail.

      The downloads can be used so far, but everybody has to take care of the AutoIt3 version 3.3.14.5 by himself!
      Thank you very much,
      Bernd.
       
      New version PSPad4AutoIt3 v1.2.0 beta (2020-08-03). Download in Posting # 1 , Info Details
    • By DarkAqua
      I have a XML file that i need assistance in parsing. Below is a snipping from the XML File:
      <Tasks> <Task> <BeginDate>2015/08/15 01:27:45,4375 (0)</BeginDate> <MangaName>Kono S o, Mi yo! (Kono S o, Mi yo! 1 --&gt; Kono S o, Mi yo! 155 - Just the Two of Them [End])</MangaName> <Website>MangaHere</Website> <SaveTo>F:\Manga\Kono S o, Mi yo!</SaveTo> <Status>Completed</Status> <Percent>100</Percent> <State>Stopped</State> <Queue>0</Queue> <Chapters /> </Task> <Task> <BeginDate>2015/08/15 01:28:49,9415 (0)</BeginDate> <MangaName>Tate no Yuusha no Nariagari (Tate no Yuusha no Nariagari 1 - A Royal Summoning --&gt; Tate no Yuusha no Nariagari 16 - The Third Wave of Calamity)</MangaName> <Website>MangaHere</Website> <SaveTo>F:\Manga\Tate no Yuusha no Nariagari</SaveTo> <Status>Completed</Status> <Percent>100</Percent> <State>Stopped</State> <Queue>0</Queue> <Chapters /> </Task> </Tasks> I have tried a couple of different ways but i haven't had any luck so far. I have messed with XML parsing with Rainmeter and Crystal Reports but im having difficulty with Auto-it. I need to parse the nodes <MangaName> and <Website> to a 2D Array with the <MangaName> as the first column and <Website> is the second column. Attached is the full XML File. 
      Tasks.xml
    • By Zedna
      I'm doing parsing of HTML file with <table>. I need to go through rows and columns of table, ideally to get two dimensional array.
      I use this way with simple two levels of calling StrinRegExp() for rows and columns:
      ;~ $html = FileRead('table.html') $html = '<tr><td>r1c1</td> <td>r1c2</td></tr>  <tr><td>r2c1</td> <td>r2c2</td></tr>  <tr><td>r3c1</td> <td>r3c2</td></tr>' $rows = StringRegExp($html, '(?s)(?i)<tr>(.*?)</tr>', 3) For $i = 0 to UBound($rows) - 1 $row = $rows[$i] ConsoleWrite("Row " & $i & ': ' & $row & @CRLF) $cols = StringRegExp($row, '(?s)(?i)<td>(.*?)</td>', 3) For $j = 0 to UBound($cols) - 1 $col = $cols[$j] ConsoleWrite(" Col " & $j & ': ' & $col & @CRLF) Next Next Output:
       
      In my example there is called StringRegExp() for each row of table which is ineffective for many rows.
      It works fine, but my question is if there is better and more effective approach, maybe some clever the only one RegExp pattern?
      Or maybe using StringRegExp with option=4? I 'm not experienced with this option (array in array) and example in helpfile is not very clear to me so I don't know if this option=4 can be used also for HTML table parsing.
    • By LetsAuto
      Hi all.. i need to make a new line, i googled it and it said to use... `n .... for a new line.. however im getting an illegal character error on au3.. so how does one write the NEW LINE escape character?
    • By daxle
      Hi there everyone,

      I have a text file that looks something like the following:

      Administrator Guest Matt jaes james jas jasdfs jasds js Matthew pjaasddasdfs pjaasdds pjads pjdfs
      Notice the odd formatting; there are not always a consistant amount of spaces between terms, I'm looking for a way to break up this text file into the individual terms (in this case user accounts), and not include the spaces. Any ideas?

      Thanks for any advice!

      Matt
×
×
  • Create New...