Macrodroid: Convert "+63" area code to "0"


Question

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.


Answer


  • 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


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes