Jump to content

Can't get newline to work on your _GUICtrlRichEdit_WriteLine


akandesh
 Share

Recommended Posts

I've spent many hours on this issue today without finding anything that works. Tried just calling _GUICtrlRichEdit_AppendText($hWnd, "test" & @CRTF) and still not giving me another line at the end. 

 

Here's a ready to run test script: https://ghostbin.com/paste/m8yre (I'm aware there's way too many includes)

 

Whoever helps me find what's wrong is a godsend and I'll be forever grateful.

Link to comment
Share on other sites

  • Moderators

akandesh,

Welcome to the AutoIt forums.

Spot the difference:

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiRichEdit.au3>

$Form1 = GUICreate("Log", 600, 400, 200, 150)

; Perhaps if you tell the RichEdit that it is multi-line and should honour @CRLF? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Global $editctrl = _GUICtrlRichEdit_Create($Form1, "", 10, 10, 580, 330, BitOR($ES_MULTILINE, $ES_READONLY))
Global $button = GUICtrlCreateButton("Log", 10, 350, 80, 30)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            function1()
    EndSwitch
WEnd

Func function1()
    ; No need to add a @CRLF - the function does it for you <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    _GUICtrlRichEdit_WriteLine($editctrl, "Test", Default, Default, 0x38761D)

EndFunc   ;==>function1

Func _GUICtrlRichEdit_WriteLine($hWnd, $sText, $iIncrement = 0, $sAttrib = "", $iColor = -1)

    ; Count the @CRLFs
    StringReplace(_GUICtrlRichEdit_GetText($hWnd, True), @CRLF, "")
    Local $iLines = @extended
    ; Adjust the text char count to account for the @CRLFs
    Local $iEndPoint = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) - $iLines

    ; Add new text
    _GUICtrlRichEdit_AppendText($hWnd, $sText & @CRLF) ; @CRLF added by the function <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    
    ; Select text between old and new end points
    _GUICtrlRichEdit_SetSel($hWnd, $iEndPoint, -1)
    ; Convert colour from RGB to BGR
    $iColor = Hex($iColor, 6)
    $iColor = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2)
    ; Set colour
    If $iColor <> -1 Then _GUICtrlRichEdit_SetCharColor($hWnd, $iColor)
    ; Set size
    If $iIncrement <> 0 Then _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement)
    ; Set weight
    If $sAttrib <> "" Then _GUICtrlRichEdit_SetCharAttributes($hWnd, $sAttrib)
    ; Clear selection
    _GUICtrlRichEdit_Deselect($hWnd)

EndFunc   ;==>_GUICtrlRichEdit_WriteLine

And when you post code in future please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above.

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

Thanks a ton! 

Off-topic question: How do I make the ScLite editor show output when I run my scripts through Tools->Go? Only thing I get is things like this: 28jzd3b.png

I always have to debug by running the script outside of the editor and I know there's ways of seeing outputs and such in the editor, so how?

Edited by Melba23
Quote removed
Link to comment
Share on other sites

  • Moderators

akandesh,

When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.

To display output in SciTE, just use ConsoleWrite to show the variable content - for arrays you need _ArrayDisplay.

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

  • Developers

Then you need to use the SciTE located in C:\Program Files (x86)\AutoIt3\Scite for things to work!

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

The installer didn't do this so it must be something you have done manually!
Close the current one and start the indicated one andshow us the output again, but this time simply cut&paste the output text.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I already did. I even uninstalled the "official" version of it since I tried that earlier when I couldn't find how to change the looks of it (still cant). 

 

The output is:

>"C:\ProgramData\SciTE\..\autoit3.exe" /ErrorStdOut "O:\AutoIt Scripts\test\ConsoleWrite.au3"    
The filename, directory name, or volume label syntax is incorrect.
>Exit code: 1    Time: 0.05965
 

Link to comment
Share on other sites

  • Developers

I do not think you started the version in C:\Program Files (x86)\AutoIt3\Scite !

Did you first close current SciTE session and then start that one?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Ok, can you check for any enviroment variable by stating CMD en show me the result for:

set sc

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

As you can see, somebody somehow set the SCITE_HOME  to that place which is simply wrong and needs to be : "C:\Program Files (x86)\AutoIt3\Scite"

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

SciTE4AutoIt3 installer? That will install to the same directory were the AutoIt3 installer installed to... and on top of that: You are not running that version at all at this moment!

So, does it work when you change it?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

That is not my installer, so can't help you there! :)

So that means you have another SciTE setup stored in "C:\ProgramData\SciTE" ?
You probably best use the setupfiles from the Full version and store them in that setup and adapt accordingly.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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