�������-�� � ���� ��������. ����� ��� REXX ��� ���� �������. ���� ������ ������
�� �������������� ����������� ������ ������ �������� ������.
/*
2-� ��������� ���������� �����.
�������� �� ���������� Nc_Soft (PHP) 27.03.09
---
2-letter domain names of countries decoder.
Based on source code Nc_Soft (PHP) 27.03.09
Translate 2 REXX - Vadim "Oxyd" Priluzkiy 05.09.2010
Updated 17.10.2010
*/
/*
������ �������� �� ��������� ������,
��������� � ������� ������� � ����� � ���������� land.
���� � ���������� ��������� ������ ����� ������� � ���������� �� ����������
���������.
---
Read the argument from the command line
translate to upper case and write it to a variable "land".
If the command line is empty jump with a message for the completion of the
program.
*/
PARSE UPPER ARG land
IF land ='' THEN DO
land = '������� ������������� ����������� ������.'
/*land = 'Enter the two-letter symbol of the country.'*/
SIGNAL Saying
END
/*
��������� ���������� ���������� ����� � stem �� �����.
���� � �������� ����������������� ����� �� ����� ����� �������,
������� �� ����� � ��������� ����. ��� ������� ����������.
��, ������, � ����� ����� ������������ ����������� ���� "; ��� �����������."
---
Fill the variable naming countries into the stem from a file.
If in the process of interpreting the lines, we suddenly found the desired,
exit the loop and close the file. So quickly obtained.
Oh, and in the file, you can use the comments form "; this is comment."
*/
CData='.\Countries.dat'
rc = STREAM(CData, 'c', 'open read')
IF rc \= 'READY:' THEN DO
SAY 'Can''t open file ' || CData || '!'2
EXIT 1
END
DO WHILE lines(CData) > 0
line = linein(CData)
/* strip comments */
p = POS(';', line)
IF p > 0 THEN line = DELSTR(line, p)
line = STRIP(line)
IF line = '' THEN ITERATE
INTERPRET line
IF Country.land \= 'COUNTRY.'|| land THEN LEAVE
END
CALL STREAM CData, 'c', 'close'
/*
����� ���, ����� �� ������ ������ �������.
SAY Country.land
�� �� ����� ���������, ��� � ������������ �������,
������� ������ ������... ��������� ������. ��� ���������� ����� �����������
��������.
������ �������� �� ������������� ������� ������ � ������.
---
Can be so, then he will issue a full line.
SAY Country.land
But the string contains Russian and English spellings, so comment out the line
"PARSE VAR Country.land '(' land ')'"
And uncomment the "land = delstr (Country.land, pos ('(', Country.land))"
Oh yeah, here, as we check the country in the list of countries.
*/
IF Country.land = 'COUNTRY.' || land THEN
land = '������ '|| land || ' �� �������.'
/*land = 'Country ' || land || ' not found'*/
ELSE
PARSE VAR Country.land '(' land ')'
/*land=Delstr(Country.land, Pos('(', Country.land))*/
Saying:
SAY land
��������� ������� ����� Countries.dat:
;
; ���� �������� ����� ��� Countries.cmd
; File with a list of countries for the script Countries.cmd
;
Country.AC='Ascension Island (������ ����������)'
Country.AD='Andorra (�������)'
Country.AE='United Arab Emirates (������������ �������� �������)'
Country.AF='Afghanistan (����������)'
Country.AG='Antigua and Barbuda (������� � �������)'
Country.AI='Anguilla (��������)'
Country.AL='Albania (�������)'
Country.AM='Armenia (�������)'
Country.AN='Netherlands Antilles (���������� ���������� �������)'
Country.AO='Angola (������)'
Country.AQ='Antarctica (����������)'
Country.AR='Argentina (���������)'
Country.AS='American Samoa (������������ �����)'
Country.AT='Austria (�������)'
Country.AU='Australia (���������)'
Country.AW='Aruba (�����)'
Country.AX='Aland Islands (��������� �������)'
Country.AZ='Azerbaijan (�����������)'
Country.BA='Bosnia and Herzegovina (������ � �����������)'
Country.BB='Barbados (��������)'
��������� �����:
http://oxyd.alt2.spb.ru/blog:vadim_priluzkiy:05-09-2010-rexx_vs_php
������� ����-���� ��� ������z��� ����������. ;)
---
� ���������, Oxyd
27 фев 11 11:04, ты писал(а) All:
VP> Надеюсь кому-нить сия полезнzшка пригодится. ;)
Эта полезняшка более эффективно бы pаботала и выглядела коpоче пpи
использовании стандаpтной подгpужаемой функции SysFileSeach()
А фоpмат файла данных таков, что можно его тупо весь отинтеpпpетиpовать и
затем выводить на печать член массива с введённым двухбуквенным именем
(номеpом). А на случай, если нет такого - фильтp-ловушку на IF поставить
Valentin
VP> Попиарю-ка я свой викаблог. Благо про REXX там есть немного. Итак скрипт
VP> которй по двухбуквенному обозначению домена выдаёт название страны.
Сопоставить ISO код страны с её названием можно короче.
nw=x2c('0a')
ad="Andorra"
ae="United Arab Emirates"
say center('ISO country code', 79) || nw ,
|| 'Введи код:'
parse pull q01 .
interpret say q01
--
Чтобы обрести признанье в наше время, Потребно честь и стыд отбросить, словно
бремя. Бесстыдство - вот кумир, кому подчинены Все сверху донизу: сословья и
чины. - П. Ронсар