Jump to content

How to send ; from autoit ?


Recommended Posts

Hello All

 

I wanted to generate a HTML table report from data given in text file (a.txt). This i am doing by :

1. Reading data from "a.txt"

1. Writing HTML code from "FileWriteLine" command into "xxx.txt" (taking a.txt data as reference i will be building html code.

2. Renaming the "xxx.txt" to "xxx.html" using "FileCopy" command.

 

Problem is HTML code contains many special characters which cannot be used in autoit like    ;    and  " Can you please let me know how to send these characters in file write line command ?

 

the desired output i.e "xxx.txt" is attached. Please help me!

THANKS

 

latest - Copy.txt

Link to comment
Share on other sites

Use HTML encoding as described here.

Means: Instead of ";" write "&#59;" to your file.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Well, not 100% sure if this id what you want, but it's for the concept  :)
[be careful when mixing single and double quotes]

#include <File.au3>
#include <Array.au3>

Local $aArray, $n = 0

$sFilePath = @scriptdir & "\Results.txt"
$sFileResult = @scriptdir & "\Results.html"

_FileReadToArray($sFilePath, $aArray, $FRTA_NOCOUNT, @TAB)
;_ArrayDisplay($aArray)

Local $html = "<html><head><meta content='text/html charset=ISO-8859-1'http-equiv='content-type'><title>AUTO-LOGGER Result History</title></head><img src=C:\Autologger\arh.png></big></td></tr></tbody></table><br style='font-family: Calibri'><big style='font-family: Calibri font-weight: bold'> </big>"
$html &= '<br style="font-family: Calibri;"><table style="text-align: left; font-family: Calibri; width: 1285px; height: 40px;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Order</td><td style="background-color: rgb(204, 204, 204); font-weight: bold; width: 550px; text-align: center;">    Test Case</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 97px;">Result</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Seq-ID</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 400px;">Binary</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 400px;">Location</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 97px;">Setup</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Hour</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Day</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Month</td><td style="text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;">Year</td></tr>'

For $i = 1 to UBound($aArray)-1
    $n += 1
    $html &= '<tr>'
    $html &= '<td style="text-align: center;">' & $n & '</td>'
    For $j = 0 to UBound($aArray, 2)-1
       $html &= '<td style="text-align: center;">' & $aArray[$i][$j] & '</td>'
    Next
    $html &= '</tr>'
Next
$html &= '</tbody></table><br style="font-family: Arial;"></body></html>'

Filewrite($sFileResult, $html)
ShellExecute($sFileResult)

 

Link to comment
Share on other sites

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Thank You Mikell

I am also following similar type of script: 

The good thing is html also accepts ' instead of "

Now my question is how to get this html data in pdf as well as xls format ? can you help me in that ?

SCITE:

#include <File.au3>
#include <Array.au3>

Local $lines = _FileCountLines(@ScriptDir & "\Results.txt")
            FileWriteLine("C:\Autologger\Result-Historyhtm.txt", "<html><head><meta content='text/html charset=ISO-8859-1'http-equiv='content-type'><title>AUTO-LOGGER Result History</title></head><img src=C:\Autologger\arh.png></big></td></tr></tbody></table><br style='font-family: Calibri'><big style='font-family: Calibri font-weight: bold'> </big><br style='font-family: Calibri'><table style='text-align: left; font-family: Calibri; width: 1285px; height: 40px;' border='1' cellpadding='2' cellspacing='2'><tbody><tr><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Order</td><td style='background-color: rgb(204, 204, 204); font-weight: bold; width: 550px; text-align: center;'>    Test Case</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 97px;'>Result</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Seq-ID</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 400px;'>Binary</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 400px;'>Location</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 97px;'>Setup</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Hour</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Day</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Month</td><td style='text-align: center; background-color: rgb(204, 204, 204); font-weight: bold; width: 52px;'>Year</td></tr>")
            For $a = 2 To $lines Step 1
                $resultline = StringSplit(FileReadLine(@ScriptDir & "\Results.txt", $a), "    ")
                $resultline[0] = "<tr><td style='width: 99px; text-align: center;'>" & $a - 1 & "</td>"
                $resultline[1] = "<td style='text-align: left; width: 536px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & $resultline[1] & "</td>"
                $resultline[2] = "<td style='text-align: center; width: 128px;'>" & $resultline[2] & "</td>"
                $resultline[3] = "<td style='text-align: center; width: 128px;'>" & $resultline[3] & "</td>"
                $resultline[4] = "<td style='text-align: center; width: 250px;'>" & $resultline[4] & "</td>"
                $resultline[5] = "<td style='text-align: center; width: 450px;'><a href=file:///" & StringReplace($resultline[5], " ", "%20") & " ><i>" & $resultline[5] & "</i></a></td>"
                $resultline[6] = "<td style='text-align: center; width: 128px;'>" & $resultline[6] & "</td>"
                $resultline[7] = "<td style='text-align: center; width: 99px;'>" & $resultline[7] & "</td>"
                $resultline[8] = "<td style='text-align: center; width: 99px;'>" & $resultline[8] & "</td>"
                $resultline[9] = "<td style='text-align: center; width: 99px;'>" & $resultline[9] & "</td>"
                $resultline[10] = "<td style='text-align: center; width: 99px;'>" & $resultline[10] & "</td></tr>"
                $resultline1 = _ArrayToString($resultline, "")
                FileWriteLine(@ScriptDir & "\Result-Historyhtm.txt", $resultline1)
            Next
            FileWriteLine(@ScriptDir & "\Result-Historyhtm.txt", "</tbody></table><br style='font-family: Arial;'></body></html>")
            FileCopy(@ScriptDir & "\Result-Historyhtm.txt", @ScriptDir & "\AUTO-LOGGER_Result-History.html", 1)
ShellExecute(@ScriptDir & "\AUTO-LOGGER_Result-History.html", 1)
FileDelete(@ScriptDir & "\Result-Historyhtm.txt")

 

Edited by JLogan3o13
adding code
Link to comment
Share on other sites

  • Moderators

@SatyaGanesh in the future, please enclose your code in a block (<> symbol on the toolbar) to make it easier to read. I have done so for you in the post above ;)

 

"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!

Link to comment
Share on other sites

To export it to Excel please use the Excel UDF that comes with AutoIt. You can then export it from Excel to PDF using function _Excel_Export.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

×
×
  • Create New...