Jump to content
czardas

Directory Enquiries Challenge

Recommended Posts

28 minutes ago, pluto41 said:

It seems to me there is no easy way

There is not. This is likely a data mining exercise. Not bad for a challenge. I, if not given a practical use, find it very difficult to act on, due to my OCD tendencies. :)  

Share this post


Link to post
Share on other sites
1 minute ago, argumentum said:

due to my OCD tendencies. :)

Same here :D.


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

Hehe! As far as problems go, I don't think this one's so complex: I just think it needs a little more time to simmer on the back burner. As far as usefulness is concerned: I suppose phones are an old fashioned concept nowadays. Nobody travels anywhere anymore. Info dumps - that's where it might be useful! :P

Share this post


Link to post
Share on other sites

Obviously the answer is: we need to petition the IEEE to create a global standard for telephone numbers.

Edited by rcmaehl
Specify scope.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

Those who know me a bit won't be surprised. Sorry for that.

#include <SQLite.au3>
#include "..\include\SQLiteExtLoad.au3"

; tester input
Global $aPhone = [ _
        '+262 692 12 03 00', '1800 251 996', '+1 994 951 0197', _
        '091 535 98 91 61', '2397865', '08457 128276', _
        '348476300192', '05842 361774', '0-800-022-5649', _
        '15499514891', '0096 363 0949', '04813137349', _
        '06620 220168', '07766 554433', '047 845 44 22 94', _
        '0435 773 4859', '(01) 882 8565', '00441619346434', _
        '09314 367090', '0 164 268 0887', '0590995603', _
        '991', '0267 746 3393', '064157526153', _
        '0 719 829 7756', '+1-541-754-3012', '+441347543010', _
        '03890 978398', '(31) 10 7765420', '020 8568 6646', _
        '0161 934 6534', '0 637 915 1283', '+44 207 882 8565', _
        '0800 275002', '0750 646 9746', '982-714-3119', _
        '000 300 74 52 40', '023077529227', '1 758 441 0611', _
        '0183 233 0151', '02047092863', '+44 20 7946 0321', _
        '04935 410618', '048 257 67 60 79']
Global $aQuery = [ _
        '882 8565', _
        '123 8762', _
        '7543010', _
        '07843 543287', _
        '03890 578398', _
        ' 10 7765420', _
        '20 8568 66464', _
        '00441619346534', _
        '0015417543012']

Local $dll = _SQLite_Startup("c:\bin\sqlite3.dll")

; load auto-extensions
_SQLite_LoadAutoExtension("unifuzz.dll")


Local $hDB = _SQLite_Open()

_SQLite_Exec($hDB, "drop table if exists phones; CREATE TABLE if not exists Phones (Id integer not NULL PRIMARY KEY, Number char, Digits CHAR);")
Local $aRows, $iRows, $iCols, $sSQL

;  bulk insert lines
Local $digits
_SQLite_Exec($hDB, "begin exclusive")
For $nb In $aPhone
    $digits = StringRegExpReplace($nb, "\D", "")
    _SQLite_Exec($hDB, "insert into phones(number, digits) values (" & _SQLite_FastEscape($nb) & ", '" & $digits & "')")
Next
_SQLite_Exec($hDB, "end")

Local $verb
For $nb In $aQuery
    $digits = StringRegExpReplace($nb, "\D", "")
    _SQLite_GetTable2d($hDB, "select Number, typos(digits, '" & $digits & "') diff from phones where diff < 4 order by diff", $aRows, $iRows, $iCols)
    Switch $iRows
        Case 0
            $verb = " is not found." & @CRLF
        Case 1
            $verb = " is found as " & $aRows[1][0] & @TAB & "(with " & ($aRows[1][1] ? $aRows[1][1] : "no") & " error" & ($aRows[1][1] ? "s)" : ")") & @CRLF
        Case Else
            $verb = " might match one of those numbers:" & @CRLF & @TAB & _ArrayToString($aRows, @TAB & "errors = ", 1, -1, @CRLF & @TAB, 0, 1)
    EndSwitch
    ConsoleWrite("The raw number " & $nb & $verb & @CRLF)
Next

One can pretty easily refine the search by adjusting the number of typos as some log function of the number (digit) length. Also build the resultset of a regex between the phone book and the queried number (all digits as well). Then refine the mix somehow to offer very few possibilities (depends on collision rates over real-world data).

The UDF and DLL can be found in the forum search. Sorry but I don't have much free time to polish the homework.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
58 minutes ago, jchd said:

; load auto-extensions
_SQLite_LoadAutoExtension("unifuzz.dll")

what is that and where you've got it from and what is the use of it and what ??? :drool:

Edit: ok, the zip attached has the UDF and the DLL. Still missing the explanation of what do the DLL does.

 

Edit2: you'll need to add Global $g_hDll_SQLite = $__g_hDll_SQLite before the #include "..\include\SQLiteExtLoad.au3" or it won't find the variable ;) 

Edit3: Might as well just attach the working set of files B)

184236-directory-enquiries-challenge&findComment1323709.zip

Edit4: ..and now I have to know what damerau-levenshtein distance is and how used here. This is becoming unfair ( given my condition ).

Edited by argumentum
found a link from 2010 to _SQLite_LoadAutoExtension

Share this post


Link to post
Share on other sites
2 minutes ago, argumentum said:

what is that and where you've got it from and what is the use of it and what ??? :drool:

http://sqlitetoolsforrootsmagic.wikispaces.com/RMNOCASE+-+faking+it+in+SQLite+Expert,+command-line+shell+et+al


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

What about this (although still refining it), loose draft code ;-)

#include <Array.au3>
;; need to update country calling codes based on
;;;; https://en.wikipedia.org/wiki/List_of_country_calling_codes0
;;; and exit codes http://www.howtocallabroad.com/codes.html

#cs looking for
882 8565
123 8762
7543010
07843 543287
00441619346534
+44208.....missing numbers [optional task]
0015417543012
#ce

Local $aArray = _
    ['+262 692 12 03 00', '1800 251 996',    '+1 994 951 0197', _
    '091 535 98 91 61',   '2397865',         '08457 128276', _
    '348476300192',       '05842 361774',    '0-800-022-5649', _
    '15499514891',        '0096 363 0949',   '04813137349', _
    '06620 220168',       '07766 554433',    '047 845 44 22 94', _
    '0435 773 4859',      '(01) 882 8565',   '00441619346434', _
    '09314 367090',       '0 164 268 0887',  '0590995603', _
    '991',                '0267 746 3393',   '064157526153', _
    '0 719 829 7756',     '+1-541-754-3012', '+441347543010', _
    '03890 978398',       '(31) 10 7765420', '020 8568 6646', _
    '0161 934 6534',      '0 637 915 1283',  '+44 207 882 8565', _
    '0800 275002',        '0750 646 9746',   '982-714-3119', _
    '000 300 74 52 40',   '023077529227',    '1 758 441 0611', _
    '0183 233 0151',      '02047092863',     '+44 20 7946 0321', _
    '04935 410618',       '048 257 67 60 79']


Local $countryCodes = _
    ['AFGHANISTAN|93', 'ALBANIA|355', 'ALGERIA|213', 'AMERICAN SAMOA|1-684', 'ANDORRA|376', 'ANGOLA|244', 'ANGUILLA|1-264', 'ANTARCTICA|672', 'ANTIGUA AND BARBUDA|1-368', 'ARGENTINA|54', _
    'ARMENIA|374', 'ARUBA|297', 'AUSTRALIA|61', 'AUSTRIA|43', 'AZERBAIJAN|994', 'BAHAMAS|1-242', 'BAHRAIN|973', 'BANGLADESH|880', 'BARBADOS|1-246', 'BELARUS|375', 'BELGIUM|32', 'BELIZE|501', _
    'BENIN|229', 'BERMUDA|1-441', 'BHUTAN|975', 'BOLIVA|591', 'BOSNIA AND HERZEGOVINA|387', 'BOTSWANA|267', 'BRAZIL|55', 'BRITISH INDIAN OCEAN TERRITORY|246', 'BRITISH VIRGIN ISLANDS|1-284', _
    'BRUNEI|673', 'BULGARIA|359', 'BURKINA FASO|225', 'BURUNDI|257', 'CAMBODIA|855|', 'CAMEROON|237', 'CAPE VERDE|238', 'CAYMAN ISLANDS|1-345', 'CENTRAL AFRICAN REPUBLIC|236', _
    'CHAD|235', 'CHILE|56', 'CHINA|86', 'CHRISTMAS ISLAND/COCOS ISLAND|61', 'COLOMBIA|57', 'COMOROS|269', 'COOK ISLANDS|682', 'COSTA RICA|506', 'CROATIA|385', 'CUBA|53', 'CURACAO|599', _
    'CYPRUS|357', 'CZECH REPUBLIC|420', 'DEMOCRATIC REPUBLIC OF THE CONGO|243', 'DENMARK|45', 'DJIBOUTI|253', 'DOMINICA|1-767', 'DOMINICAN REPUBLIC 1|1-809', 'DOMINICAN REPUBLIC 2|1-829', _
    'DOMINICAN REPUBLIC 3|1-849', 'EAST TIMOR|670', 'ECUADOR|593', 'EGYPT|20', 'EL SALVADOR|503', 'EQUATORIAL GUINEA|240', 'ERITREA|291', 'ESTONIA|372', 'ETHIOPIA|251', 'FALKLAND ISLANDS|500', _
    'FAROE ISLANDS|298', 'FIJI|679', 'FINLAND|358', 'FRANCE|33', 'FRENCH POLYNESIA|689', 'GABON|241', 'GAMBIA|220', 'GEORGIA|995', 'GERMANY|49', 'GHANA|233', 'GIBRALTAR|350', _
    'GREECE|30', 'GRENADA|1-473', 'GUAM|1-671', 'GUATAMALA|502', 'GUERNSEY|44-1481', 'GUINEA|224', 'GUINEA-BISSAU|245', 'GUYANA|592', 'HAITI|509', 'HONDURAS|504', 'HONG KONG|852', _
    'HUNGARY|36', 'ICELAND|354', 'INDIA|91', 'INDONESIA|62', 'IRAN|98', 'IRAQ|964', 'IRELAND|353', 'ISLE OF MAN|44-1624', 'ISREAL|972', 'ITALY|39', 'IVORY COAST|225', 'JAMAICA|1-876', _
    'JAPAN|81', 'JERSEY|44-1534', 'JORDAN|962', 'KAZAKHSTAN|7', 'KENYA|7', 'KIRIBATI|686', 'KOSOVO|383', 'KUWAIT|965', 'KYRGYZSTAN|996', 'LAOS|856', 'LATIVA|371', 'LEBANON|961', 'LESOTHO|266', _
    'LIBERIA|231', 'LIBYA|218', 'LIECHTENSTEIN|423', 'LITHUANIA|370', 'LUXEMBOURG|352', 'MACAU|853', 'MACEDONIA|398', 'MADAGASCAR|261', 'MALAWI|265', 'MALAYSIA|60', 'MALDIVES|960', 'MALI|223', _
    'MALTA|356', 'MARSHALL ISLANDS|692', 'MAURITANIA|222', 'MAURITIUS|230', 'MAYOTTE/REUNION|262', 'MEXICO|52', 'MICRONESIA|691', 'MOLDOVA|373', 'MONACO|377', 'MONGOLIA|976', 'MONTENEGRO|382', _
    'MONTSERRAT|1-664', 'MOROCCO|212', 'MOZAMBIQUE|258', 'MYANMAR|95', 'NAMIBIA|264', 'NAURU|674', 'NEPAL|977', 'NETHERLANDS|31', 'NETHERLANDS ANTILLES|599', 'NEW CALEDONIA|687', 'NEW ZEALAND|64', _
    'NICARAGUA|505', 'NIGER|227', 'NIGERIA|234', 'NIUE|683', 'NORTH KOREA|650', 'NORTHERN MARIANA ISLANDS|1-670', 'NORWAY|47', 'OMAN|968', 'PAKISTAN|92', 'PALAU|680', 'PALESTINE|970', 'PANAMA|507', _
    'PAPUA NEW GUINEA|675', 'PARAGUAY|595', 'PERU|51', 'PHILIPPLINES|63', 'PITCAIRN|64', 'POLAND|48', 'PORTUGAL|351', 'PUERTO RICO 1|1-787', 'PUERTO RICO 2|1-939', 'QATAR|974', _
    'REPUBLIC OF THE CONGO|242', 'ROMANIA|40', 'RUSSIA|7', 'RWANDA|250', 'SAINT BERTHELEMY|590', 'SAINT HELENA|290', 'SAINT KITTS AND NEVIS|1-869', 'SAINT LUCIA|1-758', _
    'SAINT MARTIN|590', 'SAINT PIERRE AND MIQUELON|508', 'SAINT VINCENT AND THE GRENADINES|1-784', 'SAMOA|685', 'SAN MARINO|378', 'SAO TOME AND PRINCIPE|239', 'SAUDI ARABIA|966', 'SENEGAL|221', _
    'SEBIA|381', 'SEYCHELLES|248', 'SIERRA LEONE|232', 'SINGAPORE|65', 'SINT MAARTEN|1-721', 'SLOVAKIA|421', 'SLOVENIA|386', 'SOLOMON ISLANDS|677', 'SOMALIA|252', 'SOUTH AFRICA|27', _
    'SOUTH KOREA|82', 'SOUTH SUDAN|211', 'SPAIN|34', 'SRI LANKA|94', 'SUDAN|249', 'SURINAME|597', 'SVALBARD AND JAN MAYEN|47', 'SWAZILAND|268', 'SYRIA|963', 'TAIWAN|886', 'TAJIKISTAN|992', _
    'TANZANIA|255', 'THAILAND|66', 'TOGO|228', 'TOKELAU|690', 'TONGA|676', 'TRINIDAD AND TOBAGO|1-868', 'TUNISIA|216', 'TURKEY|90', 'TURKMENISTAN|993', 'TURKS AND CAICOS ISLANDS|1-649', _
    'TUVALU|688', 'U.S. VIRGIN ISLANDS|1-340', 'UGANDA|256', 'UKRAINE|380', 'UNITED KINGDOM|44', 'UNITED ARAB EMIRATES|971', 'UNITED STATES/CANADA|1', 'URUGUAY|598', 'UZBEKISTAN|998', 'VANUATU|678', 'VATICAN|379', _
    'VENEZUELA|58', 'VIETNAM|84', 'WALLIS AND FUTUNA|681', 'WESTERN SAHARA|212', 'YEMEN|967', 'ZAMBIA|260', 'ZIMBABWE|263']

consolewrite('---- PROCESSING NATIONAL TELCO NUMBERS' & @CRLF)
For $i = 0 to Ubound($aArray)-1
    $aArray[$i] = StringRegExpReplace($aArray[$i],"[^0-9.]","") ; Santize Numbers

    Do ; do away with extra zero's at beginning, mostly for dialing outside of buildings
        IF StringLeft($aArray[$i],1) = 0 Then
            $aArray[$i] = StringTrimLeft($aArray[$i],1)
        EndIf
    until StringLeft($aArray[$i],1) <> 0 OR StringLen($aArray[$i]) = 10 or StringLen($aArray[$i]) = 7

    Select
        Case Stringlen($aArray[$i]) = 10 ; Long distance within country
            consolewrite('Possible Match! Unknown Country - National Call! -- Numbers Row: '& $i & '  -- Number: ' & $aArray[$i] & @CRLF)
        Case Stringlen($aArray[$i]) = 7 ; Should be a local call
            consolewrite('Possible Match! Unknown Country - Local Call! -- Numbers Row: '& $i & '  -- Number: ' & $aArray[$i] & @CRLF)
        Case Stringlen($aArray[$i]) = 3
            consolewrite('Possible Match! Unknown Country! -- Numbers Row: '& $i & ' -- POSSIBLE SPECIAL NUMBER -- Number: ' & $aArray[$i] & @CRLF)
    EndSelect
Next

consolewrite('---- PROCESSING INTERNATIONAL TELCO NUMBERS -- DOES NOT INCLUDE INTERNATIONAL EXIT CODE' & @CRLF)
for $a = 0 to ubound($countryCodes)-1
    $cCodes = Stringsplit($countryCodes[$a],'|')
    $cCountry = $cCodes[1]
    $cCode = StringReplace($cCodes[2],"-","")
    for $i = 0 to Ubound($aArray)-1
        $cCodeLen = StringLen($cCode)
        IF StringLen(StringTrimLeft($aArray[$i],StringLen($cCode))) >= 10 then ; real phone number local telco 7 or more characters
            IF Stringleft($aArray[$i],StringLen($cCode)) = $cCode then consolewrite('Possible Match! Country: '& $cCountry & ' -- Numbers Row: '& $i & '  -- Country Code: '& $cCode & " -- Number: " & $aArray[$i] & @CRLF)
        EndIf
    Next
Next

 

Edited by stamandster
adjusted to find international, national and local numbers

Share this post


Link to post
Share on other sites
12 hours ago, argumentum said:

Edit3: Might as well just attach the working set of files B)

I would have done that iff my connection wasn't so slow and resetting every 5-10 s at that time.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
11 hours ago, Somerset said:

I am still awaiting on what we win if we succeed.

You might get head-hunted by super-massive software giant, or be showered with gold coins by swathes of admirers. You may even appear in a major film release about how you transformed the communications industry with a single line of code. On the other hand, you won't win. :P

I don't know why this turned out to be so complicated. All you are required to do is find a phone number. :rolleyes:

Edited by czardas

Share this post


Link to post
Share on other sites

@jchd,

in the context of this challenge, your method is a bit unfair: you actually delegate the core task to an external library. although it is not as blatant as this:

however your post is very useful in the sense that now i'm aware of the fact that fuzzy search can be done in SQLite.

Share this post


Link to post
Share on other sites

I remind having posted an AutoIt transposition of the typos function, maybe here, but it's slow as hell and doesn't offer unaccentuation nor Unicode folding (both are irrelevant here since we only deal with digits). I turned to SQLite because 1) I'm a big fan and 2) I just had to glue two or three blocks of code to do that.

The missing part for UTF8 output of the code in above link:

; Unicode-aware ConsoleWrite
Func _ConsoleWrite($s)
    ConsoleWrite(BinaryToString(StringToBinary($s, 4), 1))
EndFunc   ;==>_ConsoleWrite

 

Edited by jchd
remove extra underscore in fct name

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
4 hours ago, czardas said:

I don't know why this turned out to be so complicated. All you are required to do is find a phone number

a phone number that has clues. The are separated/spaced as they would in the geographical point of origin but may be incomplete. That requires a function that would take each number and consider it as from each known area and that, in itself, is not a short piece of code. All I've got so far is the country codes:

Global $aCCodes[212][2] = [[211,""], _
["1","Canada / Caribbean Nations / USA"],["1 340","Virgin Islands"],["1 670","North Mariana Islands (Saipan)"],["1 787","Puerto Rico"],["1 868","Trinidad and Tobago"], _
["20","Egypt"],["212","Morocco"],["213","Algeria"],["216","Tunisia"],["218","Libya"],["220","Gambia"],["221","Senegal"],["222","Mauritania"],["223","Mali"], _
["224","Guinea"],["225","Ivory Coast (La Cote d'Ivoire)"],["226","Burkina Faso"],["227","Niger"],["228","Togo (Togolese Republic)"],["229","Benin"],["230","Mauritius"], _
["231","Liberia"],["232","Sierra Leone"],["233","Ghana"],["234","Nigeria"],["235","Chad"],["236","Central African Republic"],["237","Cameroon"],["238","Cape Verdi / CapeVerde Islands"], _
["239","Sao Tome and Principe"],["240","Equatorial Guinea"],["241","Gabon (Gabonese Republic)"],["242","Bahamas / Congo"],["243","Zaire"],["244","Angola"], _
["245","Guinea-Bissau"],["246","Barbados / Diego Garcia"],["247","Ascension Island"],["248","Seychelles"],["249","Sudan"],["250","Rwanda (Rwandese Republic)"], _
["251","Ethiopia"],["252","Somalia"],["253","Djibouti"],["254","Kenya"],["255","Tanzania (includes Zanzibar)"],["256","Uganda"],["257","Burundi"],["258","Mozambique"], _
["260","Zambia"],["261","Madagascar"],["262","Reunion (France)"],["263","Zimbabwe"],["264","Namibia (former South-West Africa)"],["265","Malawi"],["266","Lesotho"], _
["267","Botswana"],["268","Antigua / Swaziland"],["269","Mayolte / Comoros and Mayotte"],["27","South Africa"],["284","British Virgin Islands / British V.I."], _
["290","St. Helena"],["291","Eritrea"],["297","Aruba"],["298","Faroe (Faeroe) Islands (Denmark)"],["299","Greenland"],["30","Greece"],["31","Netherlands"], _
["32","Belgium"],["33","Monaco / France"],["34","Spain"],["345","Cayman Islands"],["350","Gibraltar"],["351","Portugal (includes Azores)"],["352","Luxembourg"], _
["353","Ireland (Irish Republic; Eire)"],["354","Iceland"],["355","Albania"],["356","Malta"],["357","Cyprus"],["358","Finland"],["359","Bulgaria"],["36","Hungary"], _
["370","Lithuania"],["371","Latvia"],["372","Estonia"],["373","Moldova"],["374","Armenia"],["375","Belarus"],["376","Andorra"],["378","San Marino"],["380","Ukraine"], _
["381","Yugoslavia (discontinued) / Serbia and Montenegro / Yemen (People's Democratic Republic of)"],["385","Croatia"],["386","Slovenia"],["387","Bosnia and Hercegovina"], _
["389","Macedonia"],["39","Vatican City / Italy"],["40","Romania"],["41","Switzerland"],["420","Czech Republic"],["421","Slovakia"],["423","Liechtenstein"], _
["43","Austria"],["44","United Kingdom"],["45","Denmark"],["46","Sweden"],["47","Norway"],["473","Montserrat / Grenada/Carricou"],["48","Poland"],["49","Germany"], _
["500","Falkland Islands"],["501","Belize"],["502","Guatemala"],["503","El Salvador"],["504","Honduras"],["505","Nicaragua"],["506","Costa Rica"],["507","Panama"], _
["508","St. Pierre &(et) Miquelon (France)"],["509","Haiti"],["51","Peru"],["52","Mexico"],["53","Cuba"],["54","Argentina"],["55","Brazil"],["56","Chile"], _
["57","Colombia"],["58","Venezuela"],["591","Bolivia"],["592","Guyana"],["593","Ecuador"],["594","French Guiana"],["595","Paraguay"],["596","French Antilles / Martinique (French Antilles)"], _
["597","Suriname"],["598","Uruguay"],["599","Netherlands Antilles"],["60","Malaysia"],["61","Australia"],["62","Indonesia"],["63","Philippines"],["64","New Zealand"], _
["65","Singapore"],["66","Thailand"],["670","Saipan"],["671","Guam"],["672","Australian External Territories"],["673","Brunei Darussalm"],["674","Nauru"], _
["675","Papua New Guinea"],["676","Tonga"],["677","Solomon Islands"],["678","Vanuatu (New Hebrides)"],["679","Fiji"],["680","Palau"],["681","Wallis and Futuna"], _
["682","Cook Islands"],["683","Niue"],["684","American Samoa"],["685","Western Samoa"],["686","Kiribati Republic (Gilbert Islands)"],["687","New Caledonia"], _
["688","Tuvalu (Ellice Islands)"],["689","Tahiti (French Polynesia)"],["690","Tokelau"],["691","Micronesia (F.S. of Polynesia)"],["692","Marshall Islands"], _
["7","Russia / Kazakhstan / Uzbekistan / Tajikistan"],["767","Dominca"],["809","Bermuda / Dominican Republic / Anguilla"],["81","Japan"],["82","Korea, Republic of (South Korea)"], _
["84","Viet Nam"],["850","North Korea / Korea, People's Republic of (North Korea)"],["852","Hong Kong"],["853","Macao"],["855","Khmer Republic (Cambodia/Kampuchea) / Cambodia"], _
["856","Laos"],["86","China (People's Republic)"],["869","St. Kitts/Nevis / Nevis"],["876","Jamaica"],["880","Bangladesh"],["886","Taiwan / China-Taiwan"], _
["90","Turkey"],["91","India"],["92","Pakistan"],["93","Afghanistan"],["94","Sri Lanka"],["95","Myanmar (former Burma)"],["960","Maldives"],["961","Lebanon"], _
["962","Jordan"],["963","Syrian Arab Republic (Syria)"],["964","Iraq"],["965","Kuwait"],["966","Saudi Arabia"],["967","Yemen Arab Republic (North Yemen)"], _
["968","Oman"],["971","United Arab Emirates"],["972","Israel"],["973","Bahrain"],["974","Qatar"],["975","Bhutan"],["976","Mongolia"],["977","Nepal"],["98","Iran"], _
["993","Turkmenistan"],["994","Azerbaijan"],["995","Georgia"],["996","Kyrgyz Republic"]]

The next step would be to match what area/country would use that notation and if it's a complete number. Then,.... I'll just wait to see what was the better approach.

Note to the winner: if you use the array I put together you'd owe me a drop of the coins of your admirers ;) ( if you so choose, oh, you, mighty one )

Share this post


Link to post
Share on other sites

@argumentum A "Map" would be more suited than an 2D array in this case! :D.


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites
7 minutes ago, TheDcoder said:

A "Map" would be more suited than an 2D array in this case!

Show me the code that proves it and I'll believe you:yawn: ( also explain the perceived meaning of the emoticon I've chosen, I thought ti was conversing but now I thinks it's sleeping )

No need. Got it.

Edited by argumentum

Share this post


Link to post
Share on other sites

@argumentum Here is a simple example for you :)

; NOTE: Use the latest BETA version of AutoIt
#include <MsgBoxConstants.au3>

Global $mCountryCodes[] ; Declare the map which will contain the country codes

; Add some country codes to the database
$mCountryCodes["1"] = "US"
$mCountryCodes["91"] = "India"
$mCountryCodes["81"] = "Japan"

Global $sInput ; This will store the input
While True ; Infinite Loop!
    $sInput = InputBox("Country Code Directory", "Enter the country code and I will tell you the country :)")
    If @error Then Exit ; If the user closes the InputBox...
    If MapExists($mCountryCodes, $sInput) Then ; Check if the country code exists in the database
        MsgBox($MB_ICONINFORMATION, "Country of the code", $sInput & " is used to call " & $mCountryCodes[$sInput])
    Else
        MsgBox($MB_ICONERROR, "Error", "Country code not in database :(")
    EndIf
WEnd

(Hint: You can use my Experimental Maps UDF to convert @argumentum's array to a map!)

(Big Hint: I have compiled all the necessary bits of code and made an Country Code Directory script! Just click "Download ZIP" to download all the files you need!)

1 hour ago, argumentum said:

also explain the perceived meaning of the emoticon I've chosen

I think it implies that you have no idea about what I am talking about and are very sceptical about it (or something similar like that).

Edited by TheDcoder
Added BIG HINT

A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...