Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove text/find/replace ect
#1
I was looking at help files but couldnt find code that would do the action i need. Here is the problem:
I have this text in the cliboard "10,977.21 RSD [ <color=0xff00ff00>-39.72% below Regional average ]"
and i need to extract just the price in front so it is just 10977.21. now i tried various methods with
find/replace but the second part keep changing and i cant just copy it and use it every time.
Is there a way to first remove everything on the right of RSD? That would leave me with just RSD and "," to replace every time.

-maby to first try to find the "RSD" position and than use
Code:
Copy      Help
s.replace(ss [from] [nc])
.. Just
brainstorming here dow i dont have a clue how to find RSD position eather :oops:

-Trying to find RSD position with
Code:
Copy      Help
_s.getclip
lpstr delimiters = " .:\/''[]"
int findw(_s RSD 0 delimeters)

But i keep getting an error: Error in Macro21: this name already exists. Give different name. (and highlight's findw)

-But even if i find the position how to i inplement it in
Code:
Copy      Help
s.replace(ss [from] [nc])
because it's asking for a number to be put in, but i need to use variable because the position will change..
#2
must be int variable=findw(...)

Macro Macro1658
Code:
Copy      Help
str s="10,977.21 RSD [ <color=0xff00ff00>-39.72% below Regional average ]" ;;replace to str s.getclip
int i=find(s " RSD"); if(i<0) ret
s.left(s i)
s.findreplace(",")
out s
#3
Awesome it worked! I also was trying out diferent things and made it work with this combination:
Code:
Copy      Help
lpstr delimiters = " "
str s.getclip()
int i = findt(s 1 delimiters)
out i

s.replace("" i)
s.findreplace(",")
out s

Cant believe what you can do with this program and a few lines of code.
I'm just sad it's not easy to learn/comprehend for a guy with zero programing background Smile
#4
Ok now that i have the value extracted and formated i need to be able to add or substract/ devide/multiply ect. I cant figure out why when i want to set variable to be same as string with the number i get a bunch of other numbers that don't make sence to me.
Code:
Copy      Help
str s.getfile("C:\folder1\extracted number.txt")  ;; value is 2540977.12
out s
int i
i=s
out i  ;; i get some numbers that have nothing to do with what i have on file and they are not with decimals in the end (51029776)

int a
a=i+5.45
out a  ;; new value i need to create -he takes the 51029776 and adds just 5 without decimal values
a is now 51029781

How can i take the value i got ( 2540977.12) and work with it + - / * while keeping the decimals and do plain old calculation?
Thank's Smile
#5
Macro Macro1659
Code:
Copy      Help
str s=10.5
;convert str to double
double d=val(s 2)
out d
;now with d can do calculations with + - / *
d+1
d=d+1
;convert double to str
s=d
out s
#6
peravoj Wrote:I'm just sad it's not easy to learn/comprehend for a guy with zero programing background Smile

Take a look at my blog (link below) it should help get you started.
An old blog on QM coding and automation.

The Macro Hook
#7
Great that got it working \o/ I seriocely would never figured it out without your help (or maby in a year or so Smile )
And thank's for the tip Ken i'm already digging in, as more learning material is defenetely a must with this awesome program. Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)