Ealric Posted February 18, 2008 Share Posted February 18, 2008 Scenario: I'm trying to create a preview with color syntax for an edit control. Basically, let's look at the following: /command [options:1] [options:2] Parameter The command will be a separate color The options combined will be a separate color The parameter will be a separate color Here's the bit of code I'm using as a test for pulling the data out into arrays so that I can see if I can even separate the values: Func _preview($string) $string = GUICtrlRead($MACRO) $command = StringRegExp($string, '\/\w+\s|\#\w+\s', 3) $options = StringRegExp($string, '\[\w+.*\]', 3) $parameter = StringRegExp($string, '\w+\z|\w+\r\n', 3) _ArrayDisplay($command) _ArrayDisplay($options) _ArrayDisplay($parameter) EndFunc The issue that I'm receiving involves a few things: First, let's take one of the issues I'm encountering: Sample: /command [options1,options2] Parameter /command [options1] /command Parameter /command [options1] [options2] Parameter If I run this using this function I get the following return data: _A..D..($command) returns [0] /command [1] /command [2] /command [3] /command .. so far so good. _A..D..($options) returns [0] [options1,options2] [1] [optons1] [2] [options1] [options2] .. this is not what I need. I need them to match the rows exactly. [2] should match up with [3] since it's located on the 4th row. So, this will cause a problem for me later on when I reformat the syntax with color coding on a label format. _A..D..($parameter) returns .. nothing! I need it to return the following: [0] Parameter [2] Parameter [3] Parameter .. Because it would be matching rows. I understand the issue with how the array is being returned. However, I need it to read more like a table with rows matching exact rows, etc. Is there something else I can use that will do this for me? Also, anyone want to figure out why the Parameters don't work? Thanks in advance. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 18, 2008 Moderators Share Posted February 18, 2008 You obviously have some type of clue how to use RegExp... The issue I personally see in helping you is not having a working/non-working piece of code to help analyze with you. Something that might help me/us to help you. 1. List the text here that GUICtrlRead() would normally return as $string. 2. From that text, show the "Exact" output you desire for each of the individual RegExp arrays. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Ealric Posted February 18, 2008 Author Share Posted February 18, 2008 You obviously have some type of clue how to use RegExp... The issue I personally see in helping you is not having a working/non-working piece of code to help analyze with you. Something that might help me/us to help you. 1. List the text here that GUICtrlRead() would normally return as $string. 2. From that text, show the "Exact" output you desire for each of the individual RegExp arrays. Example pieces and returns: $MACRO = GUICtrlCreateEdit("", 10, 480, 365, 100, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN)oÝ÷ Ù«¢+Øìñð}ͱÀ ¤©ÕÍÐÑÌÌÍ¥µÁ±ÁÕÍ¥¸Ñ¡µÍ±½½ÀÝ¡¥ ÉÌÑ¡Ñ¥¸Ñ¡¥ÐÝ¥¹½Ü°Í±½Ý̽ݸ±¥¹¥¹ÕÉ¥¹¡ÉÑȽչѥ¹¹ÕÁÑÌ¡ÉÑȱ°)Õ¹}ͱÀ ¤(%M±À ÀÀÌÀ¤ìͱÀ¡±Í½¹Ñ¼Í±½Ü½Ý¸Ñ¡Õ¹½¹Ñɽ±±±¥¹¥¹½Ñ¡ÍÑÑÕ̱°($ÀÌØíµÉ½µÍÍôU% ÑɱI ÀÌØí5 I The program is not a tiny application and houses about 5,609 lines of code and is a fully packaged application so hard for me to show you all of the code. However, an example GuiCtrlRead would be: #showtooltip Pyroblast /stopmacro [dead] [help] [noharm] /cast Presence of Mind /cast Arcane Power /stopcasting /use 13 /use 14 /cast Pyroblast That's a very simple macro script. A more elaborate macro script would be: /clearfocus [target=focus,dead] /focus [target=focus,noexists] /script SetRaidTarget("focus", 1) /cast [target=focus]Polymorph(Rank 1: Turtle) The # and / are commands The [..] are options Anything else outside of that is a parameter Usual syntax is /command [options] [more options] [even more options] parameter I want all 3 pieces to be stored so that they can be re-written on a label using color syntax for each type. Therefore, the rows of data need to match so that they are built properly again. If there is a better method than reg.. I'd like to know. Thanks for the help. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Ealric Posted February 18, 2008 Author Share Posted February 18, 2008 (edited) With a bit of patience and some troubleshooting, I wrote my own function. Here it is. It basically allows you to pull information from the edit control, parse the information into sub-sections, create a new child GUI, format and create the labels with color syntax for each sub-section. expandcollapse popupFunc _preview($string) GUISetState(@SW_HIDE, $parent) Local $Gtemp = GUICreate("Preview of your Macro", 700, 300, -1, -1, -1, $WS_EX_TOOLWINDOW, $parent) GUISetBkColor(0x0000000) Local $font_com = 0x099FFFF ; teal Local $font_opt = 0x0FFFF66 ; light yellow Local $font_res = 0x0FFFFFF ; white local $font_par = 0x066FF11 ; light green Local $prevar = GUICtrlRead($string) Local $lines = StringRegExp($prevar, '[^]]\w+.*', 3) Local $vLEN = 0 If IsArray($lines) = 0 Then Return SetError(1, 0, "No macro information is listed to preview.") For $i = 0 to UBound($lines)-1 $vLEN = $vLEN + 20 ; vertical spacing Local $command = StringRegExp($lines[$i], '\/\w+\s|\#\w+\s', 3) Local $cLEN = StringLen($command[0])*5 + 15 ; horizontal label formatting Local $comlabel = GUICtrlCreateLabel($command[0],20,$vLEN,$cLEN,20) GUICtrlSetColor($comlabel,$font_com) local $options = StringRegExp($lines[$i], '\[\w+.*\]', 3) If IsArray($options) = 1 Then Local $oLEN = StringLen($options[0])*5 + $cLEN ; horizontal label formatting Local $optlabel = GUICtrlCreateLabel($options[0],$cLEN + 8,$vLEN,$oLEN,20) GUICtrlSetColor($optlabel,$font_opt) EndIf Local $parameter = StringRegExp($lines[$i], '\s\w+.*', 3) If IsArray($parameter) = 1 Then if IsArray($options) = 1 Then Local $pLEN = StringLen($parameter[0])*5 +$oLEN ; horizontal label formatting Local $parlabel = GUICtrlCreateLabel($parameter[0],$oLEN + 8,$vLEN,$pLEN,20) GUICtrlSetColor($parlabel,$font_par) Else Local $pLEN = StringLen($parameter[0])*5 + $cLEN ; horizontal label formatting Local $parlabel = GUICtrlCreateLabel($parameter[0],$cLEN + 8,$vLEN,$pLEN,20) GUICtrlSetColor($parlabel,$font_par) EndIf EndIf Next GUISetState(@SW_SHOW, $Gtemp) Local $OKc = GUICtrlCreateButton("&OK", 20, 270, 100, 20,$BS_DEFPUSHBUTTON) While 1 $msg = GUIGetMsg() Select Case $msg = $OKc GUIDelete($Gtemp) GUISetState(@SW_SHOW, $parent) ExitLoop EndSelect WEnd EndFunc Edited February 18, 2008 by Ealric My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now