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")
how differentiate the commas inside parameters and commas that separate those parameters
-
- Posts: 40
- Joined: 12 Jun 2021, 15:28
how differentiate the commas inside parameters and commas that separate those parameters
Last edited by gregster on 28 Sep 2021, 18:57, edited 1 time in total.
Reason: Posts were split from unrelated topic.
Reason: Posts were split from unrelated topic.
Re: v1 -> v2 Script Converter
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" ?
can you show me the final result you want ?
do you want to get the text ?
"One" and " two and three" ?
-
- Posts: 40
- Joined: 12 Jun 2021, 15:28
Re: v1 -> v2 Script Converter
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"
so im wondering how AHK could tell apart the commas
Re: how differentiate the commas inside parameters and commas that separate those parameters
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
strip the function bits, run a Loop Parse CSV on whatever's left. it will handle the commas automatically
Re: how differentiate the commas inside parameters and commas that separate those parameters
edit: post was moved
paste ID1 := TV_Add("One, two and three", ID0, "Expand")
into https://fupeijiang.github.io/ahk_parser.js/
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
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},
]
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")
Re: how differentiate the commas inside parameters and commas that separate those parameters
how do you even think of that ?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"
Re: how differentiate the commas inside parameters and commas that separate those parameters
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)
-
- Posts: 40
- Joined: 12 Jun 2021, 15:28
Re: how differentiate the commas inside parameters and commas that separate those parameters
yes I do need it in real time and I'd rather not have it request something from the internet, thanksMrDoge wrote: ↑28 Sep 2021, 19:02edit: post was moved
paste ID1 := TV_Add("One, two and three", ID0, "Expand")
into https://fupeijiang.github.io/ahk_parser.js/
this might be usefulCode: 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}, ]
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 complicatedCode: 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")
-
- Posts: 40
- Joined: 12 Jun 2021, 15:28
Re: how differentiate the commas inside parameters and commas that separate those parameters
it seems like a good idea, but how exactly would I come to do this may I ask?
-
- Posts: 40
- Joined: 12 Jun 2021, 15:28
Re: how differentiate the commas inside parameters and commas that separate those parameters
Nevermind lol, I managed to do it on my own, thanks for the help! my script is done now, thank youEntropicBlackhole wrote: ↑29 Sep 2021, 12:25it seems like a good idea, but how exactly would I come to do this may I ask?
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)
}
}
}
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
Re: how differentiate the commas inside parameters and commas that separate those parameters
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:
or are you using executing this code AND parsing it ?
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"
Who is online
Users browsing this forum: Google [Bot], ulysim and 303 guests