Jump to content
Sign in to follow this  
jmon

How to correctly post AutoIt code to the forum?

Recommended Posts

jmon

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
bogQ

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
Melba23

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


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

 

Share this post


Link to post
Share on other sites
jmon

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

jmon,

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

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

 

Share this post


Link to post
Share on other sites
guinness

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


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_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: 22/04/2018

Share this post


Link to post
Share on other sites
kylomas

@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  

  • Similar Content

    • Skeletor
      By Skeletor
      Hi All,
      It has been bugging me for a while now. 
      Can you view the AutoIt code from within a compiled exe. Like how you can with most .Net exe's by using a certain program.
      If this is possible, how then can I secure my program (if this method exists).
       
    • Jemboy
      By Jemboy
      Yesterday I had to make some little changes to an old Autoit program we use at my work.
      The program reads some data and convert it to Excel.
      Before writing the cell, it is changed to text and later on I slap the column with an autofitwidth.
      Furthermore weI execute a conditional format on the sheet, to make the data more readable.
      I quickly found out that because of the breaking changes Excel.udf had starting from AutoIt 3.3.12.0,
      a lot of things had to been changed.
      The changes I had to do, only took 10 minutes.
      After trying to adjust the script for over 5 hours, to get it working with the new Excel.udf, I gave up.
      I stopped changing the script, uninstalled the my Autoit and went looking for an older version.
      Luckilly I was able to find Autoit v3.3.8.1 (with corresponding Scite) in my software repository.
      Installing Autoit V3.3.8.1 and compiling the file, now took me  10 minutes .
       
      So why did I not get the old script working with the new Excel.udf?
      There are several reasons I failed getting the old script working with the new Excel UDF.
       I had some pressure from management to fix it ASAP (and got a little anxious)  Most all resources on the internet point to the working of the old EXcel.UDF And offcourse there were thosing "breaking changes",
      with new functions using diffrent parameters or using parameters in different order. One of the column's on the sheet is used to store EAN13 (barcode) and was formatted like 1,23E12.
      I couldn't change the cell to text, also autofitwidt was not working and using conditional formatting was also a no-no.
      So in the end I could use the new Excel UDF, but not desapointed management.
       
      What would I like to ask?
      I understand that sometimes you want to rewrite a program to make it better. I even understand that one has to make breaking changes sometimes.
      But in this case because of lacking examples/resources my day went completely down the drain.
      I would like to ask the Excel.udf developpers to:
      Make more functions available to do things like changing cell properties easily, changing cell color, do an autofit columnwidth, format data conditionally. 
        Or write an Example using the (new) Excel UDF, making examples how to format a cell, do conditional format, changing cell colors etc.
        I probably am more of an example guy.
      Having a good Excel.UDF Example showing a lot of common things normally makes, programming things easy for me.
      Because I can keep tweaking snippets until I get it working the way I want it.
       
      So dear developpers, could you help me and other future user out?
       
       
       
       
       
       
       
       
       
       
       
       
       
       
    • 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!
×