Jump to content

deScripterForString.au3


mLipok
 Share

Recommended Posts

I work with JavaScript, SQL, CSS very often.
When I use these technologies in AutoIt, there is often a need to improve such code.
 

For example, for JavaScript used inside AutoIt, you first need to turn the JavaScript code embedded in AutoIt into pure JavaScript code.
Which is not always simple.

For example try to manually ...

Spoiler

turn this code:

$sJavaScript = _
                "var myelement = arguments[0];" & _
                "return GetPropertyValue(myelement);" & _
                "" & _
                "function GetPropertyValue(element) {" & _
                "   var search = '" & $sCSSProperty & "';" & _
                "   var propertyname = '';" & _
                "   for (let i = 0; i < element.style.length; i++) {" & _
                "      propertyname = element.style.item(i);" & _
                "      if (propertyname == search) {return element.style.getPropertyValue(propertyname);}" & _
                "   }" & _
                "   return '';" & _
                "}"

 

into:

var myelement = arguments[0];
                return GetPropertyValue(myelement);

                function GetPropertyValue(element) {
                   var search = '" & $sCSSProperty & "';
                   var propertyname = '';
                   for (let i = 0; i < element.style.length; i++) {
                      propertyname = element.style.item(i);
                      if (propertyname == search) {return element.style.getPropertyValue(propertyname);}
                   }
                   return '';
                }

 

or this code:

Local $s_CSS_Parser = 
            "           td, th {                                                        " & @CRLF & _
            "               padding: 5px !important;                                    " & @CRLF & _
            "               margin: 5px !important;                                     " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           .page-content {margin: 0px !important;}                         " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           iframe {height: 1300px  !important;}                            " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           * {                                                             " & @CRLF & _
            "               line-height: 1 !important;                                  " & @CRLF & _
            "               margin: 0px !important;                                     " & @CRLF & _
            "               background-color: white !important;                         " & @CRLF & _
            "               font-family: 'Times New Roman', Times, serif !important;    " & @CRLF & _
            "               font-size: 10px !important;                                 " & @CRLF & _
            "               font-weight: normal !important;                             " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           tbody.ui-table-tbody span {                                     " & @CRLF & _
            "               line-height: 20px !important;                               " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           div.kafelekPodmiotu p-panel div,                                " & @CRLF & _
            "           div.ui-panel-0,                                                 " & @CRLF & _
            "           .ui-tabview-panels {                                            " & @CRLF & _
            "               padding: 4px !important;                                    " & @CRLF & _
            "               margin-top: 2px !important;                                 " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           div.ui-tabview-panels app-show-more-info-box div.container,     " & @CRLF & _
            "           div.ui-tabview-panels p-messages div.ng-star-inserted,          " & @CRLF & _
            "           div.header-info,                                                " & @CRLF & _
            "           app-header,                                                     " & @CRLF & _
            "           div.sidebar-wrapper,                                            " & @CRLF & _
            "           div.sidebar-menu,                                               " & @CRLF & _
            "           section.ng-scope,                                               " & @CRLF & _
            "           div.page-viewbar,                                               " & @CRLF & _
            "           div.page-container > app-sidebar,                               " & @CRLF & _
            "           div.buttons,                                                    " & @CRLF & _
            "           app-footer,                                                     " & @CRLF & _
            "           i[ng-class='::item.icon'],                                      " & @CRLF & _
            "           td.actions-col i,                                               " & @CRLF & _
            "           p-messages div.ui-messages-warn span.ui-messages-icon,          " & @CRLF & _
            "           div.footer-inner {                                              " & @CRLF & _
            "               display: none;                                              " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           #ui-panel-0,                                                    " & @CRLF & _
            "           #ui-panel-0 #ui-panel-0-content,                                " & @CRLF & _
            "           #ui-panel-0-content div.ui-panel-content,                       " & @CRLF & _
            "           #ui-panel-0-content div.ui-panel-content p-table {              " & @CRLF & _
            "               margin: 0px !important;                                     " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _

into:

td, th {
                            padding: 5px !important;
                            margin: 5px !important;
                        }

                        .page-content {margin: 0px !important;}

                        iframe {height: 1300px  !important;}

                        * {
                            line-height: 1 !important;
                            margin: 0px !important;
                            background-color: white !important;
                            font-family: 'Times New Roman', Times, serif !important;
                            font-size: 10px !important;
                            font-weight: normal !important;
                        }

                        tbody.ui-table-tbody span {
                            line-height: 20px !important;
                        }

                        div.kafelekPodmiotu p-panel div,
                        div.ui-panel-0,
                        .ui-tabview-panels {
                            padding: 4px !important;
                            margin-top: 2px !important;
                        }

                        div.ui-tabview-panels app-show-more-info-box div.container,
                        div.ui-tabview-panels p-messages div.ng-star-inserted,
                        div.header-info,
                        app-header,
                        div.sidebar-wrapper,
                        div.sidebar-menu,
                        section.ng-scope,
                        div.page-viewbar,
                        div.page-container > app-sidebar,
                        div.buttons,
                        app-footer,
                        i[ng-class='::item.icon'],
                        td.actions-col i,
                        p-messages div.ui-messages-warn span.ui-messages-icon,
                        div.footer-inner {
                            display: none;
                        }

                        #ui-panel-0,
                        #ui-panel-0 #ui-panel-0-content,
                        #ui-panel-0-content div.ui-panel-content,
                        #ui-panel-0-content div.ui-panel-content p-table {
                            margin: 0px !important;
                        }

 

or this code:

Local $sQUERY = _
            "SELECT" & @CRLF & _
            "   [testing_error]" & @CRLF & _
            "FROM" & @CRLF & _
            "   [database].dbo.[sprawy]" & @CRLF & _
            ""

into this:

SELECT
                [testing_error]
            FROM
                [database].dbo.[sprawy]

 

 

 

 

Today I was determined to simplify this task for myself.

Here is the result:

;~ https://www.autoitscript.com/forum/topic/209665-descripterforstringau3/
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

#cs
                "var myelement = arguments[0];" & @CRLF & _
                "return GetPropertyValue(myelement);" & @CR & _ ; some comment
                "" & @LF & _
                "function GetPropertyValue(element) {" & _
                "   var search = '" & $sCSSProperty & "';" & _
                "   var propertyname = '';" & _
                "   for (let i = 0; i < element.style.length; i++) {" & _
                "      propertyname = element.style.item(i);" & _
                "      if (propertyname == search) {return element.style.getPropertyValue(propertyname);}" & _
                "   }" & _
                "   return '';" & _
                "}"

            "           td, th {                                                        " & @CRLF & _
            "               padding: 5px !important;                                    " & @CRLF & _
            "               margin: 5px !important;                                     " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           .page-content {margin: 0px !important;}                         " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           iframe {height: 1300px  !important;}                            " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           * {                                                             " & @CRLF & _
            "               line-height: 1 !important;                                  " & @CRLF & _
            "               margin: 0px !important;                                     " & @CRLF & _
            "               background-color: white !important;                         " & @CRLF & _
            "               font-family: 'Times New Roman', Times, serif !important;    " & @CRLF & _
            "               font-size: 10px !important;                                 " & @CRLF & _
            "               font-weight: normal !important;                             " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           tbody.ui-table-tbody span {                                     " & @CRLF & _
            "               line-height: 20px !important;                               " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           div.kafelekPodmiotu p-panel div,                                " & @CRLF & _
            "           div.ui-panel-0,                                                 " & @CRLF & _
            "           .ui-tabview-panels {                                            " & @CRLF & _
            "               padding: 4px !important;                                    " & @CRLF & _
            "               margin-top: 2px !important;                                 " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           div.ui-tabview-panels app-show-more-info-box div.container,     " & @CRLF & _
            "           div.ui-tabview-panels p-messages div.ng-star-inserted,          " & @CRLF & _
            "           div.header-info,                                                " & @CRLF & _
            "           app-header,                                                     " & @CRLF & _
            "           div.sidebar-wrapper,                                            " & @CRLF & _
            "           div.sidebar-menu,                                               " & @CRLF & _
            "           section.ng-scope,                                               " & @CRLF & _
            "           div.page-viewbar,                                               " & @CRLF & _
            "           div.page-container > app-sidebar,                               " & @CRLF & _
            "           div.buttons,                                                    " & @CRLF & _
            "           app-footer,                                                     " & @CRLF & _
            "           i[ng-class='::item.icon'],                                      " & @CRLF & _
            "           td.actions-col i,                                               " & @CRLF & _
            "           p-messages div.ui-messages-warn span.ui-messages-icon,          " & @CRLF & _
            "           div.footer-inner {                                              " & @CRLF & _
            "               display: none;                                              " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            "           #ui-panel-0,                                                    " & @CRLF & _
            "           #ui-panel-0 #ui-panel-0-content,                                " & @CRLF & _
            "           #ui-panel-0-content div.ui-panel-content,                       " & @CRLF & _
            "           #ui-panel-0-content div.ui-panel-content p-table {              " & @CRLF & _
            "               margin: 0px !important;                                     " & @CRLF & _
            "           }                                                               " & @CRLF & _
            "                                                                           " & @CRLF & _
            ""


            "SELECT" & @CRLF & _
            "   [testing_error]" & @CRLF & _
            "FROM" & @CRLF & _
            "   [database].dbo.[sprawy]" & @CRLF & _
            ""
#ce

_Main()
Func _Main()
    Local $s_Data = FileRead(@ScriptFullPath)
    $s_Data = StringRegExpReplace($s_Data, '(?is)(.+#CS.?\R)(.*?)(#CE.+)', '$2')
    ClipPut($s_Data)
    MsgBox(0, @ScriptLineNumber & ' BEFORE', $s_Data)
    deSripterForString(Default)
    MsgBox(0, @ScriptLineNumber & ' AFTER', ClipGet())
EndFunc   ;==>_Main

Func deSripterForString($s_Data = Default)
    Local $b_UseClipBoard = ($s_Data = Default)
    If $b_UseClipBoard Then $s_Data = ClipGet()

    #Region - ; check if first character is ' or "
    Local $s_Temp = StringRegExpReplace($s_Data, '[\s\R]','')
    Local Const $s_LeadingQuotationMark = StringLeft($s_Temp, 1)
    If Not StringRegExp($s_LeadingQuotationMark, '["'']', $STR_REGEXPMATCH) Then
        If $b_UseClipBoard Then Return SetError(@error, @extended, ClipPut(''))
        Return SetError(@error, @extended, '')
    EndIf
    #EndRegion - ; check if first character is ' or "

    $s_Data = @CRLF & $s_Data & @CRLF ; additional NEW LINE at start and end to make RegExpPattern easier
    Local $s_Pattern_Temp = StringReplace('(\R)(\s*?)(\")', '"', $s_LeadingQuotationMark)
    $s_Data = StringRegExpReplace($s_Data, $s_Pattern_Temp, '$1') ; strip leading quotes and spaces

    ; using $s_LeadingQuotationMark as quotation mark in next RegExpPattern
    Local $s_Pattern = StringReplace('(?i)([\"\s&_]*?(\s*?(@CRLF|@CR|@LF)[\"\s&_]*?|\s*?@CRLF[\"\s&_]*?|))(;\V+|)(\R)', '"', $s_LeadingQuotationMark)
    $s_Data = StringRegExpReplace($s_Data, $s_Pattern, '$5')

    $s_Data = StringStripWS($s_Data, $STR_STRIPTRAILING)

    If $b_UseClipBoard Then
        ClipPut($s_Data)
    Else
        Return $s_Data
    EndIf
EndFunc   ;==>deSripterForString


Have fun.
But if you found any issues ... please let me know.

 

EDIT:
2023/03/03 - new version
* added support for comment on the end of line
* better $s_LeadingQuotationMark handling
* striping WS $STR_STRIPTRAILING

EDIT:
2023/03/03 - new version
* better removal of leading whitespace

Edited by mLipok

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

Nice, I just started getting into SQLite with AutoIt, so I'll be checking this out some more soon. Any plans to make the reverse, or does that exist somewhere? Something to take an input like you deScripted examples or:

CREATE TRIGGER testing_modifiedDate
         AFTER UPDATE OF meowName
            ON testing
          WHEN new.meowName <> old.meowName
BEGIN
    UPDATE testing
       SET modifiedDate = datetime() 
     WHERE meowId = new.meowId;
END;

Into

"CREATE TRIGGER testing_modifiedDate" & @CRLF & _
"         AFTER UPDATE OF meowName" & @CRLF & _
"            ON testing" & @CRLF & _
"          WHEN new.meowName <> old.meowName" & @CRLF & _
"BEGIN" & @CRLF & _
"    UPDATE testing" & @CRLF & _
"       SET modifiedDate = datetime() " & @CRLF & _
"     WHERE meowId = new.meowId;" & @CRLF & _
"END;"

 

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

On this forum there is already script which you ask for.

It was made by me and then translated to lua by @Jos.

 

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

Found .

 

 

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

15 hours ago, mistersquirrle said:

Nice, I just started getting into SQLite with AutoIt, so I'll be checking this out some more soon. Any plans to make the reverse, or does that exist somewhere? Something to take an input like you deScripted examples or:

CREATE TRIGGER testing_modifiedDate
         AFTER UPDATE OF meowName
            ON testing
          WHEN new.meowName <> old.meowName
BEGIN
    UPDATE testing
       SET modifiedDate = datetime() 
     WHERE meowId = new.meowId;
END;

Into

"CREATE TRIGGER testing_modifiedDate" & @CRLF & _
"         AFTER UPDATE OF meowName" & @CRLF & _
"            ON testing" & @CRLF & _
"          WHEN new.meowName <> old.meowName" & @CRLF & _
"BEGIN" & @CRLF & _
"    UPDATE testing" & @CRLF & _
"       SET modifiedDate = datetime() " & @CRLF & _
"     WHERE meowId = new.meowId;" & @CRLF & _
"END;"

 

one more way:
in this post (https://www.autoitscript.com/forum/topic/204362-microsoft-edge-webview2-embed-web-code-in-your-native-application/?do=findComment&comment=1474817) there is also a small snippet, which I wrote some time ago, which does what you ask in a very simple way.
In short: copy the script you want to "embed" to clipboard, and then run that snippet of code. This "transforms" the listing that is on the clipboard into a function that returns that listing as-is in a string. The generated function is in turn placed on the clipboard.
now you can paste that function from the clipboard into your listing.
Hope it can be of use.

Edited by Gianni

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

2023/03/03 - new version - in Opening Post
* added support for comment on the end of line
* better $s_LeadingQuotationMark handling
* striping WS $STR_STRIPTRAILING

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

2023/03/03 - new version
* better removal of leading whitespace

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...