Sign in to follow this  
Followers 0
tomashen

string (trim/left) etc need bit help :D

21 posts in this topic

$search = 0
    $search_complete = StringLen($update_command)
    Do
        $space_found = StringMid($update_command, $search, 1)
        If $space_found = "^" Then
            $found_middle = $space_found
        EndIf
        $search = $search +1
    Until $search = $search_complete

;~     $trim_update = StringTrimRight($update_command, $until_space)
    GUICtrlSetData($update_command, StringMid(GUICtrlRead($COMMAND_INSERT), $found_middle, $search_complete))

im tring to get the split where... the sign is "^"

so likei if i have

TEXT^NEWTEXT

the 'TEXT' will be replace to the new word after '^' sign which in this case is "NEWTEXT"

if the sign '^' not found in the whole string... then show error

im tring but i fail and fail...


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

_StringInStr perhaps, or perhaps _StringSplit?

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

tomashen,

Look at StringSplit in the Help file. :D

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

lol i didnt understand it before.. never worked for me before.. i noticed now that u need to put

$array[x] haha thnx melba :oops::D


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

You really do need to search and read the Help file now and again rather than immediately posting here. :D

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

hehe ye sometimes im rly tired... after my hard gym workouts.. lot of weights u know how it goes :D


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

And while I am in the picky mood - please start writing correctly as I am getting very tired of all the "txt spk" you use. The Shift button is available on all modern keyboards - as are all the other characters you need to write normally. :D

It is a joke - but a little bit serious too.

:oops:

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

do you know abot else ?

Share this post


Link to post
Share on other sites

ok melba :D but um im getting this error

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
GUICtrlSetData($Command_Called[1], $Command_Called[2])
GUICtrlSetData($Command_Called[1], ^ ERROR

all i got is this

$COMMAND_INSERT = GUICtrlCreateInput("Insert command...", 0, 280, 500, 20)


$Command_Called = StringSplit(GUICtrlRead($COMMAND_INSERT), "=", 1)
        GUICtrlSetData($Command_Called[1], $Command_Called[2])

Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

And what does the Help file tell you will happen if the delimiter is not found? :D

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

umm it says it sets error..

but i used the example tho o.O but anyway um i fixed it lol i put

global $Command_Called[2]
but now another problem :oops: trying to solve it while no answer but the problem is that

$Command_Called = StringSplit(GUICtrlRead($COMMAND_INSERT), ',', 1)
        $left_cut = StringMid(guictrlread($COMMAND_INSERT), 2, $Command_Called[1] -1)
        GUICtrlSetData($Command_Called[1], $Command_Called[2])
        $UPDATED = _GUICtrlEdit_InsertText($COMMAND_BOX, @crlf & "Command : " & $Command_Called[1] & " - Set to : " & $Command_Called[2])

GuiCtrlSetData() wont work in this case.

It wouldnt set the data to the control that i type in.like as for example i type in $Label,testing and it should set the label text to "testing" but it doesnt :D


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

That is not the way to fix it. :oops:

If there is no delimiter then you will have @error set and only have 2 elements in your array - that is why $Command_Called[2] (the third element) gives an error. You need to check the StringSplit return like this:

$COMMAND_INSERT = GUICtrlCreateInput("Insert command...", 0, 280, 500, 20)

$Command_Called = StringSplit(GUICtrlRead($COMMAND_INSERT), "=", 1)
If @error
    ; What you do if there is no delimiter
Else
    ; You know you have both elements so you can use them
    GUICtrlSetData($Command_Called[1], $Command_Called[2])
EndIf

As to the second problem, what on earth do you think $Command_Called[1] -1 gives you? :rip:

StringSplit returns an array containing the split strings from the input. So why are you trying to use this string for a parameterin StringMid as if it was a numerical position in the string? That is what you get as a return from StringInStr. :D

I am going to say this one more time - READ the Help file. If you continue to ask questions which a cursory glance at the Help file will solve, you will begin to find that very few of the experienced members here will even bother to read your posts let alone answer them. Am I making myself perfectly clear? :)

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

[i]$Command_Called[1] -1
i just put wrong figure there ^^

yes very clear :D but erm it wont set the new text for the label still.. :// sry if i rly annoy u :oops:


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

One last effort! :rip:

$Command_Called[1] contains a string - as it is an element on the array returned by StringSplit which holds the parts of the string you pass to it.

In this snippet:

$left_cut = StringMid(guictrlread($COMMAND_INSERT), 2, $Command_Called[1] -1)

StringMid is expecting a number - which you would get as a return from StringInStr. If you use a string you will not get a return from StringMid and so have nothing to enter as data when you try to use GUICtrlSetData. :oops:

Got it? :D

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

#15 ·  Posted (edited)

ok got it :oops: but then what if i use it like this

$COMMAND_SELECT = GUICtrlCreateCombo("", 0, 280, 100, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "$TEST")


$Command_Called = StringSplit(GUICtrlRead($COMMAND_INSERT), "/", 1)
If @error Then
    ; What you do if there is no delimiter
    _GUICtrlEdit_InsertText($COMMAND_BOX, @crlf & "error!")
Else
    ; You know you have both elements so you can use them
    GUICtrlSetData(GUICtrlRead($COMMAND_SELECT), $Command_Called[2])
EndIf

and i test this but still dont work...so how can i get to read the array and then do the thing in this ... :) damn its hard with this... almost all day sitting on this point :D

finaly i got an idea like this and it works

If GUICtrlRead($COMMAND_SELECT) = "$_NormalLogs" Then GUICtrlSetData($_NormalLogs, _NowTime() & $Command_Called[2])

now :rip:

Edited by tomashen

Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

ok got it

Good! :oops:

But what is $TEST in your script? I see it used as data within your combo, but is it a control in your GUI? :rip:

If so then you need to write the code like this: :(

#include <guiconstantsex.au3>
#include <comboconstants.au3>
#include <guiedit.au3>

$hGUI = GUICreate("Test", 500, 500)

$COMMAND_SELECT = GUICtrlCreateCombo("", 10, 10, 100, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "TEST") ; Note we have to leave off the leading $

$COMMAND_INSERT = GUICtrlCreateInput("Insert command...", 10, 200, 400, 20)

$hButton = GUICtrlCreateButton("Go", 10, 300, 80, 30)

; Create a control to match the name in the combo
$TEST = GUICtrlCreateLabel("", 200, 300, 150, 20)
GUICtrlSetBkColor(-1, 0xFFCCCC)

$COMMAND_BOX = GUICtrlCreateEdit("", 10, 400, 400, 90)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            $Command_Called = StringSplit(GUICtrlRead($COMMAND_INSERT), "/", 1)
            ; Check we got a suitable return from StringSplit AND that there is a selection in the combo
            If @error Or GUICtrlRead($COMMAND_SELECT) = "" Then
                ; What you do if there is no delimiter or the combo is empty
                _GUICtrlEdit_InsertText($COMMAND_BOX, @crlf & "error!")
            Else
                ; You know you have both elements so you can use them - but you have to convert the text in the combo to the ControlID using Eval
                GUICtrlSetData(Eval(GUICtrlRead($COMMAND_SELECT)), $Command_Called[2])
            EndIf
    EndSwitch

WEnd

Is that what you are trying to do? :D

M23

P.S. I really am beginning to hate this forum editor with a passion - it is a real crock of :D. Please can we go back to the old one - at least it did not add random text to the post when you edit! :)


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

heh yeah that is very same thingi wanted to do :rip:

well i will keep your example for later if i get any problems with the one i just got working :oops: and thnx for all the help !

btw is it posible for me to add u in msn or yahoo or skype ? :D

those are faster than forums and u know it :)


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

is it posible for me to add u in msn or yahoo or skype

So I become your personal code slave? Not a chance! :)

This forum exists so that everyone can read and learn - that is why PMs asking for help are against the Forum Rules. You post your questions here and I will help if I can. :oops:

Besides, a slightly slower data input rate will probably help my responses sink into your exercise over-heated brain more easily! :rip:

M23

P.S. Thanks for the effort to use more proper English words in the last few posts - I appreciate it! :D


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

haha D: slave lol :D no but ye i understand why :oops:

and no problem for the english :rip:

im lithuanian tho... so dont expect every word to be perfect! :)


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

im lithuanian tho... so dont expect every word to be perfect!

No problem! :oops:

I used to visit your country quite often - mainly Kaunas and Siauliai. Good food and nice beer as I remember. :D

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

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