Jump to content

How to break long lines of autoitcode into multiple short lines automatically?


Trong
 Share

Recommended Posts

Declare only one variable per line. Also use line continuation:

Local $var1 = "something ..." & _
              "... continued" & _
              "end."
Local $var2 = "something else ..." & _
              "... end."

AutoiIt input lines have a limit of 4096 characters.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • Moderators

This is to handle different scripts is not my script.

Please elaborate, this statement makes no sense as written.

"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

  • Moderators

Trong,

This is to handle different scripts is not my script

if the scripts you want to "translate" are not yours, from where do you get them and why do they need the "translation"?

M23 

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Trong,

Please answer the questions:

  • From where do you get these scripts?
  • Why do they need "translation"?

No sensible answer means the thread gets locked as I am by no means certain that this requirement is legitimate - the variable names in this section ring a lot of alarm bells:

Func _StringRegExpC($a17f4510000, $listStrToEncode, $a61f4613c3d = 1)
    Local $a26f4712c1a = StringRegExp($a17f4510000, $listStrToEncode, $a61f4613c3d)
    If UBound($a26f4712c1a) > 0 Then Return $a26f4712c1a[0]
    Return ""
EndFunc   ;==>_StringRegExpC

M23

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

1. 

Func _StrRegExpA($sStringTest, $sPattern, $sFlag = 1)
    Local $expression = StringRegExp($sStringTest, $sPattern, $sFlag)
    If UBound($expression) > 0 Then Return $expression[0]
    Return ""
EndFunc   ;==>_StrRegExpA

2. The program not only written in English,
If you do not choose UTF-8 or Unicode when save / edit the unicode characters will be lost or corrupted.

Edited by Trong

Regards,
 

Link to comment
Share on other sites

  • Moderators

Trong,

Answers accepted.

But as you yourself point out, would it not be easier to set UTF-8 or Unicode encoding rather then this "translation"?

M23

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You could use StringLeft, StringTrimLeft, and StringLen

 

Get the length of the string, if it's >100 then use StringLeft to get the left most 100 characters and store them in a dynamic array (store it in the last element in the array, redim the array to add one to the size), and then StringTrimLeft the left most 100 characters

 

#include <Array.au3>
Local $binary_string = '0xC3BC394124742EC3BF2E2EE282AC402EE280B9C39646C692C3BA2E7CC398C3AB322EE280BA2E2E2E2EE280A6C39B742A6A2E6A2E6A2E6A2E2E45C3A050C3BFC397E280A6C380752EE280B94DC3BC394124742EC3BF2E2EE282AC402EE280B9C39646C692C3BA2E7CC39833C39B6A2E6A2E6A2E2E45C3A050C3BF2EC388E2809A402EC692C3B8C3BF74C2BDE280A6C38074542E4DC3A051C3BF2E2EE2809A402EC692C3842EE280A6C380752E2E55C3A052C3BF2EC384E2809A402E2E45C3A050C3BF2EC380E2809A402EE280B945C3A43D2E2E2E2E772E74CB86C692C3B82E74C6923DC2A02E2E2EC3AB2E3D2E2E2E2E2EE2809E71C3BFC3BFC3BFC2BB2E2E2E2E33C3B6C3A965C3BFC3BFC3BFE280B94DC3BCE280B92EE280B9422EC3BFC3905F5E33C3805BE280B9C3A55DC383C38CC38C55E280B9C3AC6AC3BF68C3B16D402E64C2A12E2E2E2E50C692C3AC5CC2A134C380402E33C385E280B045C3B0535657502E45C3B464C2A32E2E2E2E2E45C39050C3BF2E6CE2809A402E502E4DC38C33C3B651C2BB50E280A6402EE280B075C3BCC3A8272E2E2EC692C3842EC38645C3BC2EE280B945C390C692C380C3B02E502EC692C389C3BFC3B02EC3812E49E280A6C3892E2EE280B92EE280B92E50E280B9422EC3BFC390E280B94DC38C51C3BF2E30E2809A402EE280A6C3802EE2809EE2809E2E2E2E33C392C38745C3A82E2E2E2EE280B075C3A466E280B055C3942E45C394C38645C3BC2EE280B94DC38C5051C3BF2E5CE2809A402EC692C3842E2E4DC593C3BF2E58E2809A402EE280B075C2BCE280B075C380E280B075C384C2B32ECB865DC3BCC6927DC3A82EE280B94DC394732E2E4DC3942E55C39052C3A8C38E3D2E2E2E4DC2BC516878E280A6402E50C38645C3BC2EC3BF2E50E2809A402ECB865DC3BCE280B945C390C692C380C3B0C692C3842E2E502EC692C389C3BFC3B02EC3812E49E280A6C3892E2EE280B92EE280B92E50E280B9422EC3BFC390E280B94DC380E280B945C2BCE280B93DC2A4E282AC402E2BC388C381C3B92E33C39BE280A6C38974552E2ECB9CE280B92EE280B940C3B4C692C380C3BC2E4DC390C3A8C38B2E2E2EE280B975C39056C3BFC397E280B94DC2BCE280B92EE284A25650C3BF2E58E282AC402E2E46C3B02E502EC692C389C3BFC3B02EC3812E49E280A6C3892E2EE280B92EE280B92E50E280B9422EC3BFC390E280B94DC380E280B945C2BC2BC38843C381C3B92E3BC399722E33C3B6E280B955C38C52C3BFC397C38645C3BC2EE280B945C2BCE280B92EC3942E402E3BC3867442E280B94DC380E280B9C3B9E280B9C3B03BC381742F2EC2A4242E2E2E2EE280B92EC692C3A82E2E482EC692C38AC3BFC3B02EC3812E4AE280A6C3922E2EE280B92EE280B92E50E280B9422EC3BFC390C692C3862E3BC3B775C39BE280B945C2BC50C3BFC393C692C3842E33C3B62E4DC593E280B075C2BCE280B075C380E280B075C384C38645C3BC2EC3BF2E54E2809A402EC6927DC3A82E72'

; Each element stores 100 characters of the binary string
Local $data[1] = [Null]
; Will hold the full string with the _ @CRLF characters at the en
Local $new_string

While (StringLen($binary_string) > 100)
    Local $100_char_string = StringLeft($binary_string, 100)
    
    $binary_string = StringTrimLeft($binary_string, 100)
    
    $data[Ubound($data) - 1] = $100_char_string
    
    ReDim $data[Ubound($data) + 1]
WEnd

; If there still some data left in the binary string
If (StringLen($binary_string)) Then
    $data[UBound($data) - 1] = $binary_string
EndIf

For $i = 0 to Ubound($data) - 1
    $new_string &= "'" & $data[$i] & "'_" & @CRLF
Next

$new_string = StringTrimRight($new_string, 3)
ClipPut($new_string)
_ArrayDisplay($data)

 

Link to comment
Share on other sites

Thanks InunoTaishou,
But, if there is one string is not so complex.
It is 1 script and we do not know whether if taken to the 1,000 it on the keyword or function name to break the line.

I mean, with specific lines of code autoit if I will find paragraphs long it appropriate to breaks it down the line without making it fails.

 

 

#

 

Edited by Trong

Regards,
 

Link to comment
Share on other sites

I think you mean you don't know what all the script file is?

You can still use the example I posted (Turn it into a function taking a binary string parameter and returning a broken up string) and parse the file one line at a time. Checking to see if in the current line you've parsed if there is a binary string in there (using StringInStr or some other way to find a binary string). If there is a binary string, break up the current line you're parsing and convert the binary string to a broken up string then piece it back together.

I'll post an example later if no one else does.

Link to comment
Share on other sites

; copy code to be processed, and then run this script

Local $str = ClipGet(); <- binary or hex input

$str = StringRegExpReplace($str, '(.{1,100})', '    $s &= "\1"' & @CRLF)
$str = 'Func Example()' & @CRLF & '    Local $s = ""' & @CRLF & $str & '    Return $s' & @CRLF & 'EndFunc' & @CRLF

ClipPut($str); <- formatted output (paste into your script)

 

Example Output:

Func Example()
    Local $s = ""
    $s &= "0xC3BC394124742EC3BF2E2EE282AC402EE280B9C39646C692C3BA2E7CC398C3AB322E"
    $s &= "E280BA2E2E2E2EE280A6C39B742A6A2E6A2E6A2E6A2E2E45C3A050C3BFC397E280A6C3"
    $s &= "80752EE280B94DC3BC394124742EC3BF2E2EE282AC402EE280B9C39646C692C3BA2E7C"
    $s &= "C39833C39B6A2E6A2E6A2E2E45C3A050C3BF2EC388E2809A402EC692C3B8C3BF74C2BD"
    $s &= "E280A6C38074542E4DC3A051C3BF2E2EE2809A402EC692C3842EE280A6C380752E2E55"
    $s &= "C3A052C3BF2EC384E2809A402E2E45C3A050C3BF2EC380E2809A402EE280B945C3A43D"
    $s &= "2E2E2E2E772E74CB86C692C3B82E74C6923DC2A02E2E2EC3AB2E3D2E2E2E2E2EE2809E"
    $s &= "71C3BFC3BFC3BFC2BB2E2E2E2E33C3B6C3A965C3BFC3BFC3BFE280B94DC3BCE280B92E"
    $s &= "E280B9422EC3BFC3905F5E33C3805BE280B9C3A55DC383C38CC38C55E280B9C3AC6AC3"
    $s &= "BF68C3B16D402E64C2A12E2E2E2E50C692C3AC5CC2A134C380402E33C385E280B045C3"
    $s &= "B0535657502E45C3B464C2A32E2E2E2E2E45C39050C3BF2E6CE2809A402E502E4DC38C"
    $s &= "33C3B651C2BB50E280A6402EE280B075C3BCC3A8272E2E2EC692C3842EC38645C3BC2E"
    $s &= "E280B945C390C692C380C3B02E502EC692C389C3BFC3B02EC3812E49E280A6C3892E2E"
    $s &= "E280B92EE280B92E50E280B9422EC3BFC390E280B94DC38C51C3BF2E30E2809A402EE2"
    $s &= "80A6C3802EE2809EE2809E2E2E2E33C392C38745C3A82E2E2E2EE280B075C3A466E280"
    $s &= "B055C3942E45C394C38645C3BC2EE280B94DC38C5051C3BF2E5CE2809A402EC692C384"
    $s &= "2E2E4DC593C3BF2E58E2809A402EE280B075C2BCE280B075C380E280B075C384C2B32E"
    $s &= "CB865DC3BCC6927DC3A82EE280B94DC394732E2E4DC3942E55C39052C3A8C38E3D2E2E"
    $s &= "2E4DC2BC516878E280A6402E50C38645C3BC2EC3BF2E50E2809A402ECB865DC3BCE280"
    $s &= "B945C390C692C380C3B0C692C3842E2E502EC692C389C3BFC3B02EC3812E49E280A6C3"
    $s &= "892E2EE280B92EE280B92E50E280B9422EC3BFC390E280B94DC380E280B945C2BCE280"
    $s &= "B93DC2A4E282AC402E2BC388C381C3B92E33C39BE280A6C38974552E2ECB9CE280B92E"
    $s &= "E280B940C3B4C692C380C3BC2E4DC390C3A8C38B2E2E2EE280B975C39056C3BFC397E2"
    $s &= "80B94DC2BCE280B92EE284A25650C3BF2E58E282AC402E2E46C3B02E502EC692C389C3"
    $s &= "BFC3B02EC3812E49E280A6C3892E2EE280B92EE280B92E50E280B9422EC3BFC390E280"
    $s &= "B94DC380E280B945C2BC2BC38843C381C3B92E3BC399722E33C3B6E280B955C38C52C3"
    $s &= "BFC397C38645C3BC2EE280B945C2BCE280B92EC3942E402E3BC3867442E280B94DC380"
    $s &= "E280B9C3B9E280B9C3B03BC381742F2EC2A4242E2E2E2EE280B92EC692C3A82E2E482E"
    $s &= "C692C38AC3BFC3B02EC3812E4AE280A6C3922E2EE280B92EE280B92E50E280B9422EC3"
    $s &= "BFC390C692C3862E3BC3B775C39BE280B945C2BC50C3BFC393C692C3842E33C3B62E4D"
    $s &= "C593E280B075C2BCE280B075C380E280B075C384C38645C3BC2EC3BF2E54E2809A402E"
    $s &= "C6927DC3A82E72"
    Return $s
EndFunc

 

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

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...