Copy String between 2 different delimiters - VisualNEO Win - Forum

Forum Navigation
You need to log in to create posts and topics.

Copy String between 2 different delimiters - VisualNEO Win

I have done this using string commands, search, delete, sub, and etc... but there is lot of code and program became slow. too slow...

Variable [LA_property] is "Test"

Variable [for_analyzer] is a line with data like this: "(Test: 'SOME VALUE HERE') (Blah: 'SOME VALUE HERE')"

I'm trying to find Test and Get SOME VALUE HERE from line.

ClearVariables "[LA_Value]"

StrLen "[LA_property]" "[LA_Prop_Len]"

SearchStr "([LA_property]: '" "[for_analyzer]" "[LA_pos1]" ""
.if command not found or syntax error:
If "[LA_pos1]" "=" "0"
   SetVar "[LA_Value]" ""
   Return
EndIf


StrDel "[for_analyzer]" "1" "[LA_pos1]" "[LA_clean]"

Math "[LA_Prop_Len]+3" "0" "[LA_Total_Chars]"
StrDel "[LA_clean]" "1" "[LA_Total_Chars]" "[LA_clean]"

SearchStr "')" "[LA_clean]" "[LA_pos2]" ""
StrLen "[LA_clean]" "[LA_clean_Len]"
StrDel "[LA_clean]" "[LA_pos2]" "[LA_clean_Len]" "[LA_Value]"

In short, i need to find string between 2 different delimiters:

delimiter 1 is: "(Test: " and demiliter 2 is "')".

is there any plugin to do that?

@noyzen

In short, i need to find string between 2 different delimiters:
delimiter 1 is: "(Test: " and demiliter 2 is "')".
is there any plugin to do that?

Unless I have misunderstood, I don't think you need a plugin for that.

1) use SearchStr to make sure that [LA_property] has at least one instance inside [for_analyzer]

2) if it does, do a StrParse on [for_analyzer] using [LA-property] as the delimiter ... let us name the resulting array variable [LA_property_start]

3) now do a StrParse on [LA_property-start1] using delimiter2 as the delimiter ... name the resulting array [LA_property_end]

Your desired result will be in [LA-property_end1]

Let me know if my understanding is incorrect ... or you need code for this.

Ah this is better option than what i did there and its more simple. let me try it and see if things go faster!

I give feedback soon.

Thanks @Gaev

1) use SearchStr to make sure that [LA_property] has at least one instance inside [for_analyzer]

2) if it does, do a StrParse on [for_analyzer] using [LA-property] as the delimiter ... let us name the resulting array variable [LA_property_start]

3) now do a StrParse on [LA_property-start1] using delimiter2 as the delimiter ... name the resulting array [LA_property_end]

Your desired result will be in [LA-property_end1]

This trick worked but you had 1 mistake on code, at step 3 you have to use [LA_property-start2] not 1.

Code is smaller now but program is still slow, i have to look for another lines to fix it.

I have a LOT of subroutines and sometimes big code for some events. but that is small program at all and i dont know if its neobook limitation or my bad coding...

Thanks @Gaev for great help as always :)

I have Attached my program here, if you are interested to check it!

(When you add few lines, program become slow to refresh icons)
I have to read all lines and set icons for each Tree Item after each change...

Also I like to @luishp and @hpw to see what I'm working on :D

When program finish and I made About and Help pages I will give credits to everyone who helped me, of course.
This is a very early version and you may face a LOT of bugs and errors.

Uploaded files:
  • You need to login to have access to uploads.
luishp has reacted to this post.
luishp

@noyzen

This trick worked but you had 1 mistake on code, at step 3 you have to use [LA_property-start2] not 1.

Yes, it should be [LA_property-start2] (the second element in the array).

Put it down to an old man who was not quite awake at the time :-)

Code is smaller now but program is still slow, i have to look for another lines to fix it.

Can you provide some numbers ? ...

- how big is the text in [for_analyzer] ?
- how many instances of [LA_property] in [for_analyzer] ?
- how long does it take to do steps 1, 2 and 3 ? ... or at least the sum of the three steps ?

(When you add few lines, program become slow to refresh icons)

Are you sure that "it is the search steps that are slow" and not due to other things like an overload of resources ?

noyzen has reacted to this post.
noyzen

I made some improvement and its better now, and no it was not about that part of code.

for info, [for_analyzer] variable is like this:

(Search Image) (Left: '218') (Top: '465') (Width: '53') (Height: '53') (File: '202151319285435749') (Repeat: '1') (Delay Time: '10') (Delay Format: 'Milliseconds') (Found Action: '1') (Not Found Action: '1') (Found Folder: '') (Not Found Folder: '')

Are you sure that "it is the search steps that are slow" and not due to other things like an overload of resources ?

No, I think it's because another part of code.
I made some changes and it's a bit faster now. you can check program attached to previous post (slow one).

I used Neobook (VisualNEO Win) for like 20 years(?) and i remember you from old forum also, but i'm not good at coding like you guys that's why I ask a lot of questions :D

If you Right Click on previously added "Search Image" Function to VisualEdit it, you can see how long it takes for program to get all values and parse them into visual form. (my PC is too old and slow, also maybe it's because of this).

A code like this:

(Search Image) (Left: '218') (Top: '465') (Width: '53') (Height: '53') (File: '202151319285435749') (Repeat: '1') (Delay Time: '10') (Delay Format: 'Milliseconds') (Found Action: '1') (Not Found Action: '1') (Found Folder: '') (Not Found Folder: '')

 

Hello,

You may consider using an RegEx command from hpwControl:

A teststring:  (Test: 'Bla')(Top: '455')(Test2: 'Bla')(Delay Format: 'Milliseconds')

A regex-pattern to find Top with its numbers:

\(Top: '\d{1,4}'\)

A regex-pattern to find Delay-Format and its string.

\(Delay Format: '\S{1,40}'\)

Usable commands:

hpwExecRegExpList "[RegexStr]" "[SourceStr]" "[#13][#10]" "[Regex_Result]"

hpwExecRegExpPos "[RegexStr]" "[SourceStr]" "[Regex_Result]"

Regards

 

noyzen has reacted to this post.
noyzen