Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Numeric Value
#1
Part of my program is to copy a numeric value into the clipboard. I want to subtract that number by 1 then paste the end result back into a field within another program. Any suggestions.....Thanks
#2

Look through the QM Reference for:
str, int, setclip/getclip, then you should be able to understand how to add or subtract strings or intercepts, as well as copy and pasteing information.


EXAMPLE:
Macro ( Example )
Code:
Copy      Help
int i=10 ;; Example number; int used when dealing with numbers.

out i-1 ;; Subtracts 1 from int value.
Taking on Quick Macros one day at a time
#3

You can't use int with setwintext or setclip you must convert the int to str


Code:
Copy      Help
str ps
int i

i+80

ps=i

ps.setclip
#4
Please forgive me, but I still don't understand. I extensively researched all suggestions and just get confused. Can somebody just post a full example. I'm sure I can make that do exactly what I want to do.
Example: copy 555 to a variable or clipboard. Subtract 1 from it. Then paste the end result (554) into another program.
Any and all help would be much appreciated.
Thanks
#5
Code:
Copy      Help
;variables
str s ;;create variable of str type. Variables of str type are used to hold strings (text) and perform string operations (formatting, getting selected text or window text, etc).
int i ;;create variable of type int. Variables of type int are used to hold integer numbers and perform numeric operations (adding, multiplying, etc). Alternatively can be used variables of type double. They support noninteger numbers.

s.getsel ;;copy selected text to s
i=val(s) ;;get numeric value of s and assign to i. If the string does not begin with a number, i will be 0.

i=i-1
;...

s=i ;;convert to string for pasting. Or you can use just outp i.
s.setsel ;;paste s
#6
Thank you very much Gintaras! That worked perfectly. You are always very helpful.

Big Grin Big Grin
#7
I would like to do some thing similar to this, and not sure how, ive got as far as getting the text, im grabbing the text, using Acc obj.

its for logging in as i have many log in accounts, and are like this example

loginaccount1

and then the next account will be

loginaccount2

and so on
up to loginaccount20

what im looking for is to add 1 each time i run the macro.
then all i got to do is enter my password by hand, it will help me a great deal.


Forum Jump:


Users browsing this thread: 2 Guest(s)