Jump to content
Macro Express Forums

How to check field for number


koden

Recommended Posts

My macro copies a 10 digit number from a list of many different numbers and insert number into a field on a web site.

 

If number is known macro open a new window and thats fine.

 

If number is not known the field will not take it and keeps empty.

 

But macro keeps running and does some wrong things.

 

How do I get the macro to stop if the field is empty after ctrl+v into field has left field empty?

Link to comment
Share on other sites

I maybe have an idea myself...but not sure how to do it.

 

the website name is always this on the site where my number is pasted into field..

 

https://test.com/#=

 

If number is not accepted and field therefore empty, website keeps on

 

https://test.com/#=

 

If numer pasted is accepted by website it changes to new window with name

 

https://test.com/#=X

 

where X is a number between 1 and infinite

 

So I assume there must be a function that can read if website name is with or without number and stop macro if no number is located after #=

 

 

Link to comment
Share on other sites

Yes that was my idea to do.

But not sure what controls to do it with and had hoped there was a more simple solution like 

"if nothing pasted macro stop"  🙂

 

But that intelligent I don't think it is 🙂

 

I will look in some of my old macros to find the right way to get the URL checked.

Think I used this function years ago.

Link to comment
Share on other sites

I don't think you can use controls on a web page.  There are no "standard" or "pre-set" variable names -- you make up your own.  The following sequence of macro commands are approximately what should work.  You may need some Delay commands as the web page changes, to keep the macro from outrunning the screen.

 

Variable Set String %expected_URL% to 'xxxxxx' -- this is the number you expect (hope) to see in the new URL

Text Type Alt-d to highlight the actual URL at the top of the browser page

Text Type Ctrl-c to copy the highlighted URL text into clipboard

Variable Set String [set value from clipboard] -- you can make up any variable name you want, for example %URL_Name%

If Variable %URL_Name% Contains %expected_URL%

. . . .

. . . .

 

 

 

Link to comment
Share on other sites

Thanks..

 

If I understand you right, you want me to check on the number after #=

 

The problem is that I don't know the number X after #=

It can be any number.

can I check on the place after #=   ?

 

If location after #= is used or not?

 

OR is it possible to do it as described underneed?

 

paste number to field and if number not known filed will not change.

 

Copy URL and do a check if URL have changed from #= to #=X

If not changed from #= to #=X then macro stop.

 

 

Link to comment
Share on other sites

thanks... but was not the problem.

Still not working 

 

alt+d and control c works fine

 

When I try run it with a number that will fail it does not work

 

My check with T3 and T4 is prob. not working.

 

T3 has this set from start:  #=_

 

When number is not known alt+d > ctrl+c > variable set string T4 from clipboard will set T4 with:  #=_

 

If variable T3 and T4 is equal, as it is in this example with wrong namber, macro should stop.

It does not.

 

maybe I can't compare text this way as I do?

 

Maybe I should use another metode or variabel function?

 

I remember there was a function that could check content in a variable.

maybe check for integer?

 


 

 

My URL is:

 

 

 

http://test.com/#=_

 

And when wrong number is used it's stil http://test.com/#=_

 

 

When correct number is pasted my url changes to http://test.com/#=X

 

X could be any number and notice that _ changes to X

 

 

So... something like.. if URL contains a integer keep running.

If URL does not contain a integer macro stop

 

I can see you have been involved in several threads about checking variables... just need to find the right solution for me, so that it's not being to complicated.

 

 
Link to comment
Share on other sites

I have search and search... but mot found the right solution or maybe I just did not understand the one I found 🙂

 

1. Is it possible to look for integer in a string, when there is 30 characters and only one is integer?

 

2. My URL is always 30 characters and the last character is either underscore or a number

 

Underscore when my pasted number is wrong and a number if my pasted number is correct.

 

My url can be more than 30 characters. It happens if number is 2 or sometimes 3 digits

Link to comment
Share on other sites

I don't understand how it can work if you type <ALT>d<

On my PC, typing <ALT>d highlights the URL, then typing the < character causes the entire highlighted URL to be replaced by < and the single character < is loaded into the clipboard.

 

Should have the Sound Beep command before the Macro Stop.

 

Other than that, I can't see where the problem is. 

For testing, try a Text Box Display just before the compare of T3 with T4.  Put some kind of brackets around the displayed variables so you can tell if there are invisible blanks or nulls at beginning or end of the variables.  That could make them appear unequal.

 

For example, in the Text Box, display

***%T3%***

***%T4%***

Link to comment
Share on other sites

so testet now

 

timing was the issue..

 

But I was so focused on when number was not accepted. So I forgot what to do when number is correct.

 

If number is correct it will now just keep on from the blue arrow and thats wrong. If number is right the URL has changed to http://test.com/#=X

And it should keep on from the red arrow

 

So it's set up wrong. I nned to check URL at blue arrow and if URL is http://test.com/#=_

Then macro stop

If URL is http://test.com/#=X

Then go on from RED arrow.

 

But can't find out how to set that together in the macro 🙂

 

image.png.1b892f37bd5ac354909dfb98a223a130.png

 

 

 

 

 

 

Link to comment
Share on other sites

The macro logic looks correct to me.  Whether it stops or continues depends on the values of T3 and T4 when the "IF" command.  That's why I suggested inserting a Text Box Display before the "IF", to determine exactly what the variables contain at that point. 

 

How soon does the screen change after the macro types T1 and ENTER?  Maybe you need a delay longer than 1000ms at that point, to make sure the application has had enough time to change the URL when the number is correct. 

Link to comment
Share on other sites

I have used text to see what happens.

 

So just before 

"if variable T4 = T3"

 

I have a text document where I paste T3 and T4

 

The result was

 

T3: /#h=_
T4: /#h=1

 

So it's working now...

 

problem WAS when it returns to webpage the URL is still highlighted and macro is in wrong place.

But that is solved with another TAB command.

 

At same time I minimized some delays, so that macro is faster than before.

 

 

So thanks for all your help... much appreciated 🙂

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...