Sign in to follow this  
Followers 0
GordonFreeman

Match in one line

14 posts in this topic

#1 ·  Posted (edited)

have any way to match this in one line, without loops.

I need match:

If 16-32-48-64-80-96 Then

msgbox(0,"","Matched")

Endif

but i need put the 16 in a var to change how i want

Thanks for support!

Edited by GordonFreeman

Share this post


Link to post
Share on other sites



I'm not sure if you realize that what you're asking is impossible to answer as you didn't even begin to explain what it is you need to do.


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

#3 ·  Posted (edited)

I'm not sure if you realize that what you're asking is impossible to answer as you didn't even begin to explain what it is you need to do.

Haha, sorry.

$var = 16

If $i =  ($var * "All possibilities") Then
;CODE
EndIf

;It will run code if $i = 16 or 32 or 48 or 64 or .....
Edited by GordonFreeman

Share this post


Link to post
Share on other sites

Not one line, but it can easily done this way.

For $I = 16 to 96
    If Mod($i, 16) Then
        ConsoleWrite("$i (" & $i & ") is NOT a multiple of 16" & @CRLF)
    Else
        ConsoleWrite("$i (" & $i & ") is a multiple of 16" & @CRLF)
    EndIf
Next

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

$test =  "32"

If $test = "16" or $test = "32" or $test =  "48" or $test = "64" or $test = "80" or $test = "96" Then msgbox(0, '' , "Match")


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

StringInStr...or better explain, please

$iMatch = "16-32-48-64-80-96"
$iVar = 16
If StringInStr($iMatch,$iVar) Then
    ConsoleWrite($iVar & " found in " & $iMatch & @CRLF)
EndIf
$iVar = 15
If Not StringInStr($iMatch,$iVar) Then
    ConsoleWrite($iVar & " not found in " & $iMatch & @CRLF)
EndIf
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks for all. Im trying create a "sustentable" function to create many aligned buttons.

 

 

Local $sMultiple = ""

 

For $i = 1 to $iAmount

 

$sMultiple &= ($iMaxByLine * $i) & "-"

 

Next

 

Thanks @jdelaney, solution is nice but i think cause problems in match why 32 will match before 320 Or 328.

 

Thanks @boththose, i also thinked in it but is not a flexibily solution

 

Thanks @BrewManNH, i trying solve this <snip> math and implement your solution

Edited by Melba23
Profane language removed

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

what needs to be 'flexibily' about it?  Are there more rules besides

I need match:

 

If 16-32-48-64-80-96 Then

msgbox(0,"","Matched")

Endif

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

another:

#include <array.au3>
$iMatch = "16-32-48-64-80-96"
$iVar = 16
$Values = StringSplit($iMatch, "-", 2)
If - 1 <> _ArraySearch($Values, $iVar) Then MsgBox(0, "", "Matched")

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

GordonFreeman,

I have edited your post above - there is absolutely no valid reason for using such language on a public forum. Please do not use such terms again. :naughty:

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

#11 ·  Posted (edited)

Thanks for all who help me.

when i finish the func i will be putting here

 

GordonFreeman,

I have edited your post above - there is absolutely no valid reason for using such language on a public forum. Please do not use such terms again. :naughty:

M23

Sorry by the language, escaped without i realize

Fixed! Done! Solved! Thanks to all by atention and support!

Func _GuiCtrlCreateButtons($iAmount,$iMaxByLine,$iLeft,$iTop,$iWidht,$iHeight)

Local $aButtons[$iAmount]

$iStartLeft = $iLeft
$iStartTop = $iLeft

For $i = 1 to $iAmount

If $i <> 1 Then
$iLeft += $iWidht

If Mod($i-1,$iMaxByLine) Then

Else

$iLeft = $iStartLeft
$iTop += $iHeight

EndIf

EndIf

$aButtons[$i-1] = GUICtrlCreateButton($i,$iLeft,$iTop,$iWidht,$iHeight)

Next

Return $aButtons

EndFunc;==>_GuiCtrlCreateButtons
Edited by GordonFreeman

Share this post


Link to post
Share on other sites

nice little function - I'm adding it to my 'snipit' file - could come in handy......

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

nice little function - I'm adding it to my 'snipit' file - could come in handy......

Thanks @TechCoder, i added to example forum with the possibility to add horizontal and vertical distances between buttons and fixed some things

'?do=embed' frameborder='0' data-embedContent>>

Edited by GordonFreeman

Share this post


Link to post
Share on other sites

I just create my aligned buttons through For loop.  I added variables to be able to change space and amount of buttons.

Below is just an example for vertical but could easily be changed to horizonal

#include <GUIConstantsEx.au3>
$hGUI = GUICreate("Test", 200, 200)
Global $Button[1], $spacer = 16, $buttons = 10

For $i = 0 to $buttons
    $Button[$i] = GUICtrlCreateButton("Button " & $i, 10, $i*$spacer, -1, 15)
    ReDim $Button[UBound($Button)+1]
Next

Global Const $ctrl_offset = $Button[1] - $Button[0]
GUISetState(@SW_SHOW)

Do
    $msg = GUIGetMsg()
    Switch $msg
        Case $Button[0] To $Button[$buttons]
            $x = Abs(($msg - $Button[0]) / $ctrl_offset)
            MsgBox(0, "Test", "Button " & $x & " was clicked")
    EndSwitch
Until $msg = $GUI_EVENT_CLOSE

GUIDelete($hGUI)
Exit

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