1

So there is already a working macro that does the following:

Whenever I dial/call a number with a prefix other than the ones I specified, a dialog box appears. I wanted to "filter" the numbers so I would be notified if I was to make a call to a number belonging to a different network/company.

To clarify, there are two codes in the prefix. One is the country code and the other is the network code. For instance, country code is +63 and network (company) code is 945. Furthermore, the country code +63 is interchangeable with 0 and both valid are when making a call. So a +63945xxx number is the same as 0945xxx.

My current issue is that 4-digit prefixes (the ones starting with 0 like 0945, 0917, etc) are already "filtered" by the existing macro. However, 6-digit prefixes (the ones starting with +63 like +63945,+63917 are not filtered), hence 0945 and +63945 which are virtually the same will get different responses (One will prompt a dialog box and the other will not). What I am looking for is a way to first convert +63 to 0 so that it becomes a 4-digit number which the macro can filter.

Here is a link to my previous question which can be used as reference.

Make a pop up message if about to call area codes excluding specified

Also attached is the macro that currently filters 4-digit prefixes but overlooks 6-digit ones.

Edit: 8/15/2020 14:10

I started a new macro from scratch just to be sure. But result in log seems to be the same. Examples of numbers called would be +639451234567 and 09451234567. All numbers dialled prompted a dialog box. Here are the screenshots:

(https://i.stack.imgur.com/wksR0.png) (https://i.stack.imgur.com/FJTtc.png) (https://i.stack.imgur.com/y9Jqi.png) (https://i.stack.imgur.com/qnwbm.png) (https://i.stack.imgur.com/JTS76.png) (https://i.stack.imgur.com/uBuJ8.png)

Edit: 22:30 Below macro given by beeshyams works well.

Kyle
  • 15
  • 3

1 Answers1

1
  • I am not sure what went wrong at your end, it could be wrong configuration, misuse of global variables or a silly mistake. In the absence of trouble shooting information, it's a guessing game.

  • Your approach of changing 63 to 0 as in the title is totally unnecessary.

Macro Logic

  1. Outgoing call number is assigned to local variable A as a string (don't use global variables unless you need)

  2. The length of the string in variable A is assigned to variable strlen. We have two types of outgoing numbers, those starting with +63, which is 13 digits long and the other starting with 09 that is 11 digits.

  3. We use IF-then-ELSE logic. If the string length is 13 (corresponding to numbers starting with +65):

a) We use text manipulation to find out the first six digits to find out whether they are allowed codes or not. In either case, they are assigned to variable A.

b) If the first 6 digits are allowed codes, no action is taken. If they aren't a warning dialogue is configured. This is done by the nested IF loop and can be extended to include more area codes.

  1. Back to step 2,if it is not 13 digits, then actions in else loop will be carried out. We are looking at 11 digits corresponding to 09 starting numbers. But by saying not 13,we are also including other cases like police, fire etc., which have 3 digits and for which the warning will still pop up and the effort to exclude this 3 digit case is not worth it IMO.

  2. For 9 digit numbers, the same set of actions at Para 3a) and b) are executed.

  3. At the end both variables are initialized

Macro is slightly long owing to comments, so it's in two screenshots, the first one covering IF and next one ELSE

IMG: IMG:

(Click to enlarge)

OP has confirmed it works as expected. To prevent MacroDroid being killed follow instructions at don't kill my app.com

beeshyams
  • 40,739
  • 30
  • 119
  • 269