Jump to content

String Manipulation(scrool)


Kyme
 Share

Recommended Posts

Hello Guys

I want to make a scroll text and send it to a lcd, I've managed the connection and be able to display it but i faced the "too much chars to be displayed" problem, so i need to create a function to scroll the text, the problem is that i have no idea how can i get the first char and put it last if the string it's too big and if not then let it as it is
Can anybody give me an idea where can i start?

Thank you

Link to comment
Share on other sites

  • Moderators

Kyme,

RTFC took the words from right out of my mouth!

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

Truly, I feel blessed today, as for once in my life I was faster than the black double goose-tailed winged dragon-griffon beasty lying in a bowl of red chilli (or whatever it is).:lol:

Link to comment
Share on other sites

  • Moderators

RTFC,

It is a chimera - in this specific case the badge of one of my previous units.

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

2 hours ago, RTFC said:

Thank you for fast response
i saw the script prior posting and as i understood it's a gui thing, i need a string format
i have a function that require a string to print it on lcd, can be used marquee to create a same size string as original one but rotating?maybe i've missed something, i could make a function to subtract the max-1 both sides and concatenate them and trim it to @30 chars, but it sounds painful and i guess it's harder then it sounds.
My small project it's to make a lcd app to print song name that's playing on spotify.

Till now i've managed to do the displaying but i want the text to be on 1 line only, and if the title it's longer then to scroll the text.

Edit:

this is what i'm come up to, is there any other more elegant solution, it looks sooo trivial...

$title="Adelitas Way - What It Takes"&"   " ;31
$max=10
while 1
   $title=title($title)
   ConsoleWrite(StringTrimRight($title,Int(StringLen($title))-$max)&@CRLF)
   Sleep(100)

WEnd

Func title($otitle)
   local $o_title=$otitle
   local $size=StringLen($o_title)
   local $char=StringTrimRight($o_title,$size-1)
   local $title_subed=StringTrimLeft($o_title,1)
   $first=StringTrimLeft($o_title,1)
   ;ConsoleWrite($title_subed&$char&@CRLF)
    Return $title_subed&$char
EndFunc


 

Edited by Kyme
Link to comment
Share on other sites

Try this and adapt:

HotKeySet("{ESC}", _Terminate)

Local $title = "Adelitas Way - What It Takes" & " here more long text, much larger than LCD 24-char display (example)  ...      "
Local $max = 24
Local $str = $title & $title        ; yes, concat two copies of text
Local $i
While 1
    $i += 1
    ConsoleWrite(StringMid($str, Mod($i, StringLen($title)), $max) & @CRLF)
    Sleep(200)
WEnd

Func _Terminate()
    Exit
EndFunc

 

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

...rotate a string left or right by a wanted num of chars

#include <GUIConstantsEx.au3>

Local $sString = "I want to make a scroll text and send it to a lcd, I've managed the connection and be able to display it but i faced the ""too much chars to be displayed"" problem " & ChrW(9786) & " " & ChrW(9829) & "  "
Local $iLCD_Len = 24

GUICreate("LCD", 400, 30)
$hLCD = GUICtrlCreateLabel("", 0, 0, 400, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Courier New")
GUICtrlSetBkColor(-1, 0x550000)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()

While 1
    $idMsg = GUIGetMsg()
    Select
        Case $idMsg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    ControlSetText('', '', $hLCD, StringLeft($sString, $iLCD_Len))

    $sString = _StringRotate($sString, -1)
    Sleep(100)
WEnd

GUIDelete()

; rotate a string by a nr of chars
; negative number rotate left <-- , positive number rotate right -->
Func _StringRotate($sString, $sStep = -1)
    Local $Len = StringLen($sString)
    Local $bROL = $sStep < 0
    $sStep = Mod(Abs($sStep), $Len)
    If $bROL Then
        Return StringRight($sString, $Len - $sStep) & StringLeft($sString, $sStep)
    Else
        Return StringRight($sString, $sStep) & StringLeft($sString, $Len - $sStep)
    EndIf
EndFunc   ;==>_StringRotate

 

Edited by Chimp

 

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

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