Sign in to follow this  
Followers 0
jmon

How to correctly post AutoIt code to the forum?

7 posts in this topic

#1 ·  Posted (edited)

Hello,

When I want to post some code to the forum, I always have some issues on how to paste it correctly so the code looks correct in my post.

The problems I ran into are:

- the tab indent disapear

- some smileys appear with some regexp patterns

- the forum try to auto format the text and add some html tags in my regexp patterns

- paste the code in "toggle edit mode" to keep the tab indents but this method adds some html tags here and there

- I don't know about you guys, but when I try to paste some code in the "Special BB code" and select "Autoit" then the window stretches up and I cannot click the button to validate (the button goes out of my screen (Google Chrome and Windows 7 x64))!

I tried several ways and it seems that the best way of doing it is:

1 - Paste the code as plain text (to make sure no text formatting is kept)

2 - write myself the [ autoit ] tags at the beginning and end of the code

3 - now the problem is that this method doesn't keep the tab indents.

I was thinking that there should be a tutorial pinned in every forum, because I've seen that I am not the only one having troubles with it.

So if you have some tips, I'd be happy to know them so I don't pull my hairs every time!

jmon.

[EDIT]

Solved: So it's a problem with the IPB forum editor, so while there is no update, the best way of doing it is (From Melba23 and BogQ):

1 - Toggle "Edit mode" (Top left of the text editor)

2 - do all you things in edit mode

3 - add manually the autoit tags for autoit code ([*autoit*] for the beginning, [*/autoit*] for the end (remove the stars))

4 - preview your post. If there is unwanted html tags, then remove them manually

5 - post

This method keeps the TAB indents, but sometimes add some unwanted html tags in RegExp Patterns and URLs. Also sometimes, #includes containing "<" or ">" will disappear. In this case, preview your post and if you notice this then just write them again...

Edited by jmon

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

just do from the start to the end in toggleded mode and add every tag by hand and youl probably not have any problems ;)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

jmon,

This is a problem with the IPB forum editor - and each time Jon posts a bug report it comes back "cannot reproduce". :(

It does however seem to be very browser dependent and so each case is slightly different. Personally I use the "basic" editor mode (as opposed to the "WYSIWYG" version - you toggle using the button at top left) and add all my tags by hand. I get very few problems - other than the addition of <b></b> tags in the middle of some URL tags. I suggest you post like that for now and hope that the next update gets us a better built-in editor. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

@BogQ and @Melba23

Thanks for you help. I'm glad to see that I'm not the only one having the issue. I will use the "toggle editing mode" from now on!

Another bug I got sometime, is the includes are removed sometimes (I guess when they contain "<" or ">"), so posting something like this:

#include <imagesearch.au3>
#include <Array.au3>

may come out like this sometimes:

#include 
#include <Array.au3>

Share this post


Link to post
Share on other sites

jmon,

Same problem - same solution as far as I am concerned. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Strange that they (IPB) can't reproduce it, but hundreds of users can.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

@M23 - Thanks, works perfectly

@jmon - There is a test thread in the CHAT forum for testing various posting methods

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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
Sign in to follow this  
Followers 0

  • Similar Content

    • Jury
      By Jury
      I've failed to find an example of _Word_DocFindReplace which searches for formatted text (I'm looking for stand alone paragraph marks that are formatted other than normal i.e. Bold Italic, Underlined). 
      The reason being that when converting a Word document to html one of the main problems in the results is that a stand alone paragraph mark is converted to an html space that retains the formatting ...>&nbsp;<... thus showing up as a underline _  in a browser when it should be blank.  I've played around with the script and got it to at least un-bold  the first paragraph mark regardless if it was bold or not but I'd like to clear all formatting from any stand alone paragraph marks in the whole document.  Below is what I've done so far (not much more than in the help file I'm afraid) .  Way down at the bottom of the _Word_DocFindReplace  help  text is this parameter but without any examples to be found :
      $bFormat   [optional] True to have the find operation locate formatting in addition to or instead of the find text (default = False) #include <MsgBoxConstants.au3> #include <Word.au3> $processing = @MyDocumentsDir & '\AutoIt_code\getter\processing\' Global $oWord = _Word_Create() Global $sTestfile = $processing & "Testing.docx" ConsoleWrite($sTestfile & @CRLF) Global $oDoc = _Word_DocOpen($oWord, $sTestfile) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "ERROR", "Error opening file = '" & $sTestfile & "'" & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oRangeFound = _Word_DocFind($oDoc, "^p", Default, Default) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _ "Error locating paragraph control character in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oRangeFound.Bold = False If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _ "Error inserting text after the paragraph control character in the document." & @CRLF & "@error = " & @error & _ ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", "Paragraph control character successfully replaced." & @CRLF & _ "Text inserted in paragraph 2.")  
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i want to optimize my search code, because i don't think that my solution is "acceptable" from development perspective, it might be optimized.
      I have a text file, i read it and i copy all the entries to an Array, then i have to start a search to see if a specific entry is present. I have about ten different strings to search.
      Func FileSearch($file_content_array, $search) $j=0 For $i = 0 To UBound($file_content_array) - 1 $search_result=StringInStr($file_content_array[$i],$search) If $search_result<>0 Then ReDim $searchResultArray[UBound($searchResultArray) + 1] $searchResultArray [$j] = $file_content_array[$i] $j+=1 EndIf Next Return $searchResultArray EndFunc My solution would be ok for a single search, but in case of multiple searches? would it be still good?
      I have thought to use a 2D Array, where the first column is the array-item and the second column is "yes" or "no". But what about the searches? Do i have to use 10 times the function?
      In case of questions: I have to scan a directory and check whether some files are present or not and then write into another file:"yes, it is present", "no, it is not present".
      Thanks in advance
    • genbadger
      By genbadger
      Hi All,
      I'm not too code savvy but I know this is a simple one! Here's my problem, I have a folder with text files containing gcode. they are appended .nc, .ngc, and .gcode randomly. I can rename them all .ngc which is my preferred file type. In these files there's lines of gcode, carrying commands for a CNC. What I need to do is remove some comments from the beginning and format the text a certain way. I'll show an example of the original file and what I need it to look like. The files can be 20 lines or 10,000 long depending on the part.
      Old text:
      ( Header 1 text                      )
      ( Header 2 text                      )
      G90   (set absolute distance mode)
      G90.1 (set absolute distance mode for arc centers)
      G17   (set active plane to XY)
      G21   (set units to mm)
      #<z_safe> =  0.250 
      #<plunge_feed> =     5 
      (---------------------------------------------------------)
      G0 X 17.2644 Y 1.6127
      M03 
      G1 X 2.2842 Y 8.0674 F 0.01 
      G1 X 15.3642 Y 17.8133
      G1 X 17.2644 Y 1.6127
      M05 
      G0 X 0.0000 Y 0.0000
      M05 
      M02 
       
       
      What it needs to look like:
      G90
      G21
      G0 X17.2644 Y1.6127
      M03
      G1  X2.2842 Y8.0674  <--- copy and paste above the next m05
      G1  X15.3642 Y17.8133
      G1  X17.2644 Y1.6127
      G1  X2.2842 Y8.0674  <--- pasted here
      M05
      G0 X0.000 Y0.000
      M05
      M02
      Some things to note: g90 sets absolute coordinate mode, g21 tets units to mm, g0 is first coordinate to move the tool to. 
      This is an important step: m03 is what turns on a laser. I need the first coordinate after every m03 to be copied to the line above m05 for each chunk of gcode. the very last m05 before the m02 needs to be ignored. There are multiple chunks with m03 x,ys then m05. each chunk is going to have different coordinates after the m03.
       
      I have no idea where to start other than find the line with the wanted string, m03. dont know how to handle m05 though... any help is very much appreciated!
    • Kyan
      By Kyan
      Hi, SL3NCK calculates the 7 NCK's levels used for unlocking SL3 phones.
      SL3NCK("0000000000000000000000000000000000000000", "080803080307030003010002020305")
      _output:
      #pw+283037116581614+1# #pw+235518432205471+2# #pw+595388505163502+3# #pw+415333744058839+4# #pw+259299316395048+5# #pw+467723677207791+6# #pw+690485095019780+7# You can test run and see is the same code output as in the following websites:
      http://www.francesco-pompili.it/Hash2Nck.aspx http://nokia-sl3.com/nck.php #include <Crypt.au3> ; #Function# =========================================================================================================== ; Name...........: SL3NCK ; Description ...: Calculates 7 NCK levels for SL3. ; Syntax.........: SL3NCK("TARGET_HASH","MASTER_SP_CODE") ; Return values .: string with 7 levels NCK's. ; Author ........: kyan (autoIT code), oOXTCOo (PHP code). ; Remarks .......: $TargetHash is a string with 40 hex chars. $MasterSP is a string with 30 digits. ; Related .......: SimlFeistel(), _packH() ; Requeires .....: #include <Crypt.au3> ; =============================================================================================================================== Func SL3NCK($TargetHash, $MasterSP) $result = '' $MasterSP = '000000' & StringMid($MasterSP, 0 + 1, 24) For $i = 1 To 7 $hash = _packH('0' & $i & $TargetHash) $hash = StringTrimLeft(StringUpper(_Crypt_HashData($hash, $CALG_SHA1)), 2) $precode8 = StringMid($MasterSP, 0 + 1, 16) $precode7 = StringMid($MasterSP, 17 + 1, 30) For $magic = 0 To 1 $sh = _packH('0' & $magic & StringMid($hash, 0 + 1, 32) & $precode8) $sh = StringTrimLeft(StringUpper(_Crypt_HashData($sh, $CALG_SHA1)), 2) $precode = SimlFeistel($sh, $precode7) $precode7 = $precode $sh = _packH('0' & $magic & StringMid($hash, 0 + 1, 32) & $precode) $sh = StringTrimLeft(StringUpper(_Crypt_HashData($sh, $CALG_SHA1), 2) $precode = SimlFeistel($sh, $precode8, 8) $precode8 = $precode Next $final = $precode8 & $precode7 $x = 1 $nck = '' For $y = 1 To 15 $nck = $nck & StringMid($final, $x + 1, 1) $x += 2 Next $result &= '#pw+' & $nck & '+' & $i & '#' & @CRLF Next Return $result EndFunc ;==>SL3NCK Func SimlFeistel($sh, $precode, $bytes = 7) Local $result = '', $j = 0, $nck = '', $nck2 = '' While ($j < ($bytes * 2)) $nck = StringMid($sh, $j + 1, 1) & StringMid($sh, $j + 2, 1) $nck2 = StringMid($precode, $j + 1, 1) + StringMid($precode, $j + 2, 1) $prenck = Mod((Dec($nck) + Dec($nck2)), 10) $result = $result & '0' & $prenck $j += 2 WEnd Return $result EndFunc ;==>SimlFeistel Func _packH($sInput) Local $sReply = "" For $xx = 1 To StringLen($sInput) Step 2 $sReply &= Chr(Dec(StringMid($sInput, $xx, 2))) Next Return $sReply EndFunc ;==>_packH by Luigi Hope it comes handy for someone
      PS: You can't unlock a phone only with this. Google is your friend.
    • guinness
      By guinness
      This function is used to create a unique system I/O control code (IOCTL).
      ; Ported from C to C#: http://www.emoticode.net/c-sharp/win32-ctl_code-macro-ported-to-c.html Func _WinAPI_Create_CTL_CODE($iDeviceType, $iFunction, $iMethod, $iAccess) Return BitOR(BitShift($iDeviceType, -16), BitShift($iAccess, -14), BitShift($iFunction, -2), $iMethod) EndFunc ;==>_WinAPI_Create_CTL_CODE