Posts: 1
Threads: 1
Joined: Jan 2024
01-29-2024, 04:38 PM
Dear all,
I am new to Quick Macros and I love this program by now. As trying to play with it I got the following issue. I got a string from my macro that contains a duplicated string. I need to detect those and delete the second part. How to do it?
str s = "repeatable stringrepeatable string"
int n
for n 0 s.len
out s.left(s n)
Even the for loop does not work... Why? How to find a solution?
Best regards
Gregor
Posts: 12,073
Threads: 140
Joined: Dec 2002
Quote:I am new to Quick Macros
Try LibreAutomate. It is similar to Quick Macros.
-----
Easy if the substring is known.
Example in LibreAutomate:
// script ""
string s = "repeatable stringrepeatable string";
if (s.RxFindAll(@"repeatable string", out var matches) && matches.Length > 1) {
for (int i = matches.Length; --i >= 1; ) {
var m = matches[i];
s = s.Remove(m.Start..m.End);
}
}
print.it(s);
Posts: 7
Threads: 1
Joined: Oct 2024
I'm sorry if I crossed a line. As an admin, why are you offering the free version instead of Quick Macro? And does ChatGPT really help in creating scripts for MacroQuest or LibreAutomate?
Because I have zero knowledge about programming languages, and my best 24-hour teacher is ChatGPT.
Posts: 12,073
Threads: 140
Joined: Dec 2002
LibreAutomate is a replacement for Quick Macros. It is better in many ways. Quick Macros now is a legacy app.
ChatGPT is not very familiar with LibreAutomate and QM. But in LibreAutomate you use C#, and ChatGPT can help much.
Posts: 12,073
Threads: 140
Joined: Dec 2002
10-31-2024, 04:22 AM
(This post was last modified: 10-31-2024, 04:49 AM by Gintaras.)
I tested how ChatGPT can answer the topic question.
In C# (LibreAutomate) the code is working, although the result isn't exactly what we need. I would give it score 7 / 10.
In QM it is far from valid and working. Score 3 / 10.
https://chatgpt.com/share/6723062f-e7b8-...b0c12b6098
Posts: 1,336
Threads: 61
Joined: Jul 2006
Your for loop doesn't work because as soon as you do this
out s.left(s n) when n =0 s is now empty and any further attempts after will have no value
need to store the string in a new string
str s = "repeatable stringrepeatable string"
int n
for n 0 s.len
,out _s.left(s n+1)