SatyaGanesh

How to send ; from autoit ?

12 posts in this topic

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

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Could you post an example of initial "a.txt" file ?

Share this post


Link to post
Share on other sites

Thank You all .. currently i am following the solution given by JohnOne  

Hi Mikell please check the attached example "a.txt" file.

 

Thank you very much ... :)

Results.txt

Share this post


Link to post
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)

 

Share this post


Link to post
Share on other sites

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for 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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

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 * Best coding practices * 

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) * 

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 *

"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: 2017-06-04

Share this post


Link to post
Share on other sites

Just tripple your quotes

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

@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 ;)

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

  • Similar Content

    • wakillon
      By wakillon
      SciTE Hopper : Jump to Any line by one click and many other helpfull functions !


      As Ashalshaikh suggested me after leaving me the task to continue >SciTE Hopper, i open a new Topic about it.
      It will be more easy for futures updates.

      Many helpfull functions in contextual menu.
      SciTE Hopper is now multipurpose.
      • Color Catcher added
      • BinaryToAu3Kompressor added
      • TinyAu3Search replaced by StringFinder
      • RegJumper added
      • Edit With SciTE added (available in Options)
      • SpecialCharactersViewer added (available in Tray menu)
      New Contextual Menu :

      For a right Click on a function :

      • Copy function name
      • Insert a function header
      • Cut function
      • Copy function
      • Delete function
      • Create a variables List
      • Remove usseless Blank lines
      • Remove Debug lines ( all lines starting with ConsoleWrite or _ArrayDisplay )
      • Set AutoIt Code Layout
      • Remove Comments

      For entire script :

      • Create a functions List
      • Create a variables List
      • Remove usseless Blank lines
      • Remove Debug lines ( all lines starting with ConsoleWrite or _ArrayDisplay )
      • Set AutoIt Code Layout
      • Remove Comments
      • ( Open in SciTE a ) Duplicate of current Script in Temp Dir
      • ( Open in SciTE a ) Duplicate of current Script in Same Dir
      • Explore Parent Script Folder
      • Copy Script name
      • Copy Script path
      • Find Unused Functions
      • Find Unused Variables
      • Set all functions in alphabetic order.( func headers and regions ( in fact, all lines between functions ) are not supported.)

      SciTE Editor New Contextual Menu if SciTE Hopper is added ( in Options ) to SciTE Editor :
      when you made a selection in SciTE Editor you can :

      • Open a Reg Key in Regedit using RegJumper
      • Open a Url in your default Browser
      • Search on google in your default Browser
      • Search on AutoIt Website in your default Browser
      Now Can be added to windows start (minimized)
      Options are available by Tray Menu.
      A double click on tray icon will open clipboard content to SciTE Editor ( Handy when you have copied some code from your browser )

      How to proceed for add SciTE Hopper to SciTE Editor :
      Run Scite Editor, run Scite Hopper ( compiled! ) go to Options and select Add/Remove to SciTE Tab. then click on Add button and it's done !
      Right click on SciTE Editor and choose SciTE Hopper in Contextual Menu for run it when you need it !
      Update of 07 Dec 2017
      TinyAu3Search is replaced by StringFinder

      Previous downloads : 1287
      Script and compiled version are available in the download section
       
      Thanks to Ashalshaikh, Melba23, Th3 MMA, Alzri2, taitel, Manadar, taz742, Yashield, Authenticity, Xenobiologist for their help
      and asdf8 for his >Includes Helper and azjio for his >FileSearch.

      Hope it help you and happy Scripting !

       
    • wakillon
      By wakillon
      For more details go to the Topic
    • JaredStroeb
      By JaredStroeb
      I need to open an application and send it keys in Session 0.  I have exe's working locally, I can see the application open in session 0 through interactive services, but my send commands do not go to the application.  The following article running-autoit-session-0, directs me to use ControlSend() however my application has no controls that can be identified by AutoIt v3 Window Info.  Get All Windows Controls also returned nothing for the application's handle.  
      What are my options?  
      Can this be done with AutoIt?
      Is there a different "relatively simple" library/tool to use? (I am familiar with C# if there is a viable library there )

       
    • Skysnake
      By Skysnake
      Scite comes up occasional, almost incidentally, in some support topics.  I have not found a "Scite" topic in the forums, so this is where I will start.  I have recently been using Scite intensively, specifically with a large project and I have certain issues.  I know that Scite is not an AutoIt product, but it is so closely integrated to the core release that it makes sense to raise issues and request support here.  If this is not the right please refer me to the right forum.
      Thx
       
      Skysnake
    • TrashBoat
      By TrashBoat
      I've messed around in scite theme settings and it left this blue bar , how can i get rid of it?
      Image (imgur)