how differentiate the commas inside parameters and commas that separate those parameters

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
EntropicBlackhole
Posts: 40
Joined: 12 Jun 2021, 15:28

how differentiate the commas inside parameters and commas that separate those parameters

28 Sep 2021, 12:02

One question, how do you differentiate the commas inside parameters and commas that separate those parameters
Example:
How do you differentiate this comma:

Send, Hello, World!

From this comma:

Send, Hello, World!

And can this be done inside a function too?, because I want to separate the commas in a TreeView Add function

ID1 := TV_Add("One, two and three", ID0, "Expand")
Last edited by gregster on 28 Sep 2021, 18:57, edited 1 time in total.
Reason: Posts were split from unrelated topic.
MrDoge
Posts: 160
Joined: 27 Apr 2020, 21:29

Re: v1 -> v2 Script Converter

28 Sep 2021, 18:03

what do you mean by "separate the commas" ?
can you show me the final result you want ?

do you want to get the text ?
"One" and " two and three" ?
EntropicBlackhole
Posts: 40
Joined: 12 Jun 2021, 15:28

Re: v1 -> v2 Script Converter

28 Sep 2021, 18:42

MrDoge wrote:
28 Sep 2021, 18:03
what do you mean by "separate the commas" ?
can you show me the final result you want ?

do you want to get the text ?
"One" and " two and three" ?
no, what I want is to not touch the text (One, two and three) at all, instead what im trying to do is deconstruct the TV_Add() into its parameters, however someone could put TV_Add("One, two and three", ID0, "Expand), but I want to sepearate the parameters, and of course by the commas, so I would have

Code: Select all

Name := "One, two and three"
Level := "ID0"
Options := "Expand"
however when I do that, it also separates the "one" and the "two"
so im wondering how AHK could tell apart the commas
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: how differentiate the commas inside parameters and commas that separate those parameters

28 Sep 2021, 18:58

looks like u need help with something unrelated to this thread. u shouldve started a new one

strip the function bits, run a Loop Parse CSV on whatever's left. it will handle the commas automatically
MrDoge
Posts: 160
Joined: 27 Apr 2020, 21:29

Re: how differentiate the commas inside parameters and commas that separate those parameters

28 Sep 2021, 19:02

edit: post was moved

paste ID1 := TV_Add("One, two and three", ID0, "Expand")
into https://fupeijiang.github.io/ahk_parser.js/

Code: Select all

[
{type:'assignment', text:'ID1', i1:0, c1:undefined, c2:3},
{type:'emptyLines', text:' ', i1:0, c1:3, i2:0, c2:4},
{type:'2operator', text:':=', i1:0, c1:4, c2:6},
{type:'whiteSpaces', text:' ', i1:0, c1:6, c2:7},
{type:'start unit'},
{type:'functionName', text:'TV_Add', i1:0, c1:7, c2:13},
{type:'( function CALL', text:'(', i1:0, c1:13},
{type:'String', text:'"One, two and three"', i1:0, c1:14, i2:0, c2:34},
{type:', function CALL', text:',', i1:0, c1:39},
{type:'emptyLines', text:' ', i1:0, c1:35, i2:0, c2:36},
{type:'start unit'},
{type:'idkVariable', text:'ID0', i1:0, c1:36, c2:39},
{type:'end unit'},
{type:', function CALL', text:',', i1:0, c1:49},
{type:'emptyLines', text:' ', i1:0, c1:40, i2:0, c2:41},
{type:'String', text:'"Expand"', i1:0, c1:41, i2:0, c2:49},
{type:') function CALL', text:')', i1:0, c1:49},
{type:'end unit'},
{type:'end assignment'},
{type:'emptyLines EOF', text:'
', i1:0, c1:50, i2:1, c2:0},
]
this might be useful

you can look stuff after {type:'functionName', text:'TV_Add'

do you need to use this in REAL TIME ?
do you want a CLI tool ? or I could update the website with a button: get args of function ?

I suppose you want to batch get the args:
can you show me the format of your stuff ?
is it like ? on many lines, or is it more complicated

Code: Select all

ID1 := TV_Add("One, two and three", ID0, "Expand")
ID1 := TV_Add("One, two and three", ID0, "Expand")
ID1 := TV_Add("One, two and three", ID0, "Expand")
ID1 := TV_Add("One, two and three", ID0, "Expand")
MrDoge
Posts: 160
Joined: 27 Apr 2020, 21:29

Re: how differentiate the commas inside parameters and commas that separate those parameters

28 Sep 2021, 19:10

If this parameter is CSV, InputVar will be parsed in standard comma separated value format. Here is an example of a CSV line produced by MS Excel:

"first field",SecondField,"the word ""special"" is quoted literally",,"last field, has literal comma"
how do you even think of that ?
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: how differentiate the commas inside parameters and commas that separate those parameters

28 Sep 2021, 21:01

this was initially posted in the v1->v2 converter thread. not sure why it was moved/split because i think he was asking how we do it in the converter (which i dont remember off the top of my head)

EntropicBlackhole
Posts: 40
Joined: 12 Jun 2021, 15:28

Re: how differentiate the commas inside parameters and commas that separate those parameters

29 Sep 2021, 12:24

MrDoge wrote:
28 Sep 2021, 19:02
edit: post was moved

paste ID1 := TV_Add("One, two and three", ID0, "Expand")
into https://fupeijiang.github.io/ahk_parser.js/

Code: Select all

[
{type:'assignment', text:'ID1', i1:0, c1:undefined, c2:3},
{type:'emptyLines', text:' ', i1:0, c1:3, i2:0, c2:4},
{type:'2operator', text:':=', i1:0, c1:4, c2:6},
{type:'whiteSpaces', text:' ', i1:0, c1:6, c2:7},
{type:'start unit'},
{type:'functionName', text:'TV_Add', i1:0, c1:7, c2:13},
{type:'( function CALL', text:'(', i1:0, c1:13},
{type:'String', text:'"One, two and three"', i1:0, c1:14, i2:0, c2:34},
{type:', function CALL', text:',', i1:0, c1:39},
{type:'emptyLines', text:' ', i1:0, c1:35, i2:0, c2:36},
{type:'start unit'},
{type:'idkVariable', text:'ID0', i1:0, c1:36, c2:39},
{type:'end unit'},
{type:', function CALL', text:',', i1:0, c1:49},
{type:'emptyLines', text:' ', i1:0, c1:40, i2:0, c2:41},
{type:'String', text:'"Expand"', i1:0, c1:41, i2:0, c2:49},
{type:') function CALL', text:')', i1:0, c1:49},
{type:'end unit'},
{type:'end assignment'},
{type:'emptyLines EOF', text:'
', i1:0, c1:50, i2:1, c2:0},
]
this might be useful

you can look stuff after {type:'functionName', text:'TV_Add'

do you need to use this in REAL TIME ?
do you want a CLI tool ? or I could update the website with a button: get args of function ?

I suppose you want to batch get the args:
can you show me the format of your stuff ?
is it like ? on many lines, or is it more complicated

Code: Select all

ID1 := TV_Add("One, two and three", ID0, "Expand")
ID1 := TV_Add("One, two and three", ID0, "Expand")
ID1 := TV_Add("One, two and three", ID0, "Expand")
ID1 := TV_Add("One, two and three", ID0, "Expand")
yes I do need it in real time and I'd rather not have it request something from the internet, thanks
EntropicBlackhole
Posts: 40
Joined: 12 Jun 2021, 15:28

Re: how differentiate the commas inside parameters and commas that separate those parameters

29 Sep 2021, 12:25

swagfag wrote:
28 Sep 2021, 18:58
looks like u need help with something unrelated to this thread. u shouldve started a new one

strip the function bits, run a Loop Parse CSV on whatever's left. it will handle the commas automatically
it seems like a good idea, but how exactly would I come to do this may I ask?
EntropicBlackhole
Posts: 40
Joined: 12 Jun 2021, 15:28

Re: how differentiate the commas inside parameters and commas that separate those parameters

29 Sep 2021, 13:21

EntropicBlackhole wrote:
29 Sep 2021, 12:25
swagfag wrote:
28 Sep 2021, 18:58
looks like u need help with something unrelated to this thread. u shouldve started a new one

strip the function bits, run a Loop Parse CSV on whatever's left. it will handle the commas automatically
it seems like a good idea, but how exactly would I come to do this may I ask?
Nevermind lol, I managed to do it on my own, thanks for the help! my script is done now, thank you :D

I ended up with this function:

Code: Select all

TV_MakeTree(List, Del := "`n") {
	ID0 := 0
	Loop, Parse, List, %Del%
	{
		if InStr(A_LoopField, "TV_Add")
		{
			StringSplit, TVAdd, A_LoopField, =
			AssignLevel := StrReplace(TVAdd1, " :")
			TV := SubStrInBtw(TVAdd2, "(", ")")
			Loop, Parse, TV, CSV
			{
				if (A_Index = 1)
					Name := A_LoopField
				if (A_Index = 2)
					Level := StrReplace(A_LoopField, " ")
				if (A_Index = 3)
					Options := A_LoopField
			}
			Options .= " Expand"
			%AssignLevel% := TV_Add(Name, %Level%, Options)
		}
	}
}
Just have a list like:
ID0 := 0
ID1 := TV_Add("Fruits", ID0)
ID2 := TV_Add("Apples", ID1)
ID3 := TV_Add("Red", ID2)
ID3 := TV_Add("Hard", ID2)
ID3 := TV_Add("Circular", ID2)
ID2 := TV_Add("Oranges", ID1)
ID3 := TV_Add("Orange", ID2)
ID3 := TV_Add("Squishy", ID2)
ID3 := TV_Add("Circular", ID2)
and it automatically parses it and adds it to the tree
MrDoge
Posts: 160
Joined: 27 Apr 2020, 21:29

Re: how differentiate the commas inside parameters and commas that separate those parameters

29 Sep 2021, 14:19

it's a bit weird that you would have to parse AHK in your AHK, can't the data be json or newline separated ?
it does look way nicer than json though (is this the reason?)
I also make my config in this form, then I parse it:

Code: Select all

something:="value"
path:="value"
var:="value"
or are you using executing this code AND parsing it ?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], ulysim and 303 guests