Jump to content
SatyaGanesh

How to send ; from autoit ?

Recommended Posts

SatyaGanesh

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
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
mikell

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

Share this post


Link to post
Share on other sites
SatyaGanesh

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
mikell

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
mLipok

 


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 UDF * 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 * Good coding practices in AutoIt * 

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: 2018-03-17

Share this post


Link to post
Share on other sites
SatyaGanesh

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
JLogan3o13

@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
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      I was trying to insert function header to the functions of my script, but, in the SciTE console, this appears:
      Function or struct definition not found, unable to insert header. @Jos Any suggestion?
      Thanks in advance.

      Best Regards.
    • cheeroke
      By cheeroke
      Hi I am not sure how to call it properly, but for those of you who use SciTE, when you typing built in function and about to pass parameters to it you can see popup with all the ones which can be passed.
      Question: how to create something like that for my own functions?
       
      Thanks
    • therks
      By therks
      Does SciTE have string or number ids for the recent file menu items?
      I was hoping to add shortcuts (using the user.shortcuts properties) to the most recent item, but the documentation doesn't list any id's for those items (unless I overlooked?).
      Also, did anyone else notice that the index listing for the SciTE doc doesn't work properly?
      It appears it's linking to this: mk:@MSITStore:C:\Program%20Files\AutoIt3\SciTE\Scite4AutoIt3.chm::/SciTEDocumentation.html
      When it should be this? mk:@MSITStore:C:\Program%20Files\AutoIt3\SciTE\Scite4AutoIt3.chm::/Scitedoc/SciTEDoc.html
    • BrewManNH
      By BrewManNH
      I was looking for a toolbar modification for SciTE and I was checking various versions of SciTE that were available on the internet. They all had some problems for how I wanted to use the editor, so I looked here to see if there were any toolbar modifications for Scite. I found one very old script by YogiBear (Volly) from 2006 that looked promising, though there were issues with it. I decided to see what I could do to modify this script, and make some improvements to it if possible. This script is the result of that work.

      It's not perfect and definitely could use some tweaking, but I thought that it had matured enough, and was mostly stable enough to release the updated version.

      Changelog:
      Version 2.0.1
      Minor update to remove all the old Obfuscator directives and replaced them with #Au3Stripper directives instead. I also corrected a minor bug that only showed up for me on one computer I tried this on, and caused the tool bar to crash for others as well.
      SciTE toolbar version 2.0
      Changed the settings values to use constants instead of 'magic numbers' The icons on the toolbar weren't lining up with the separator characters or with the toolbar GUI because they weren't set with the resize setting for the icons, only for the separators. Changed to using arrays for everything, it makes it a lot easier to loop through the controls Added a line to use an alternate path to the SciTE program, so you can start it using, for example, the portable version instead of installed version for those that don't install AutoIt and/or SciTE4AutoIt3. It will accept a commmand line parameter that points to the SciTE executable. Removed a lot of Global variables by moving the GUI creation and monitoring to the Main function and passing variables from it. I embedded the icon files into the script so that there isn't a separate download of the icon files used here. Saves download time and makes the package smaller. Modification of tools is easier because the icon names, tooltip text, and SciTE command codes are saved in the INI file upon first start up. These can be modified after the script has been run once, even after it's been compiled, by changing the ini file information, you can modify this script to automate it, or you can change it manually in any text editor. The icon files are now using, in just my opinion, better looking icons, after all it's been 7 years and icon files have matured. I have included a file with all of the constants that SciTE uses for its menu commands which comes from the SciTE source file "scite.h", so you can use this file to help you modify the commands that the toolbar works with, by figuring out what each of these values represent in SciTE. The core of the script is pretty much the same, I've just fixed a couple of issues that it had, tweaked a few things, added some new functionality and "prettied" it up a bit.

      If anyone has any suggestions as to improvements, bugs/bugfixes, etc. please let me know.

       
      scitetoolbar.zip
    • Aguilucho
      By Aguilucho
      Greetings to the AutoIt community.
      I hope that nobody considers my question insulting but I searched 'SciTEConfig.exe' and I did not find it anywhere;
      although it is mentioned, it seems like a myth, I can not see if it exists.
      On the other hand, I have downloaded the compressed archive (from ... autoit-script-editor/downloads) 'SciTEConfig_Source.zip'
      Does not contain any .exe either but does have a 'SciteConfig.au3' which, I suppose, has replaced the .exe because on the internet I only find it as malware.
      My problem is: My applications to unzip .zip archives, they can see what files SciTEConfig_Source.zip have but they can not unzip it: 'Unknown method' says WinRar.
          I have downloaded it again, in case it had been damaged but the result is always the same.

      My question is: Is the archive 'SciTEConfig_Source.zip' damaged or does it have any other method of compression?
      I need it to learn how to configure SciTE (lite).
      Thankful to the developers of AutoIt and to the community.
      Regards
       
×