Интерпретатор HQ9+

PHP/JS+HTML+CSS/Python/др.

Сообщение Интерпретатор HQ9+
» 23 фев 2018, 16:22

Думаю некоторые пользователи форума видели мой интерпретатор hq9+ на construct 2, но я это показателем не посчитал, и поэтому написал его на js. Да он громоздок, но ОН РАБОТАЕТ
Изображение
П.С. Добавил от себя пару функций: "-" уменьшает счетчик на 1, и "0" обнуляет счетчик
Вот код:
Код: Выделить всё
<script>
//функция выводящая песенку 99 бутылок пива, ах да: без тега <br> он все напишет на одной строке, что нам не нужно
function poem(){
document.write('99 bottles of beer on the wall, 99 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 98 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('98 bottles of beer on the wall, 98 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 97 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('97 bottles of beer on the wall, 97 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 96 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('96 bottles of beer on the wall, 96 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 95 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('95 bottles of beer on the wall, 95 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 94 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('94 bottles of beer on the wall, 94 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 93 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('93 bottles of beer on the wall, 93 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 92 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('92 bottles of beer on the wall, 92 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 91 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('91 bottles of beer on the wall, 91 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 90 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('90 bottles of beer on the wall, 90 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 89 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('89 bottles of beer on the wall, 89 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 88 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('88 bottles of beer on the wall, 88 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 87 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('87 bottles of beer on the wall, 87 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 86 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('86 bottles of beer on the wall, 86 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 85 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('85 bottles of beer on the wall, 85 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 84 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('84 bottles of beer on the wall, 84 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 83 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('83 bottles of beer on the wall, 83 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 82 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('82 bottles of beer on the wall, 82 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 81 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('81 bottles of beer on the wall, 81 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 80 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('80 bottles of beer on the wall, 80 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 79 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('79 bottles of beer on the wall, 79 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 78 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('78 bottles of beer on the wall, 78 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 77 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('77 bottles of beer on the wall, 77 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 76 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('76 bottles of beer on the wall, 76 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 75 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('75 bottles of beer on the wall, 75 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 74 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('74 bottles of beer on the wall, 74 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 73 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('73 bottles of beer on the wall, 73 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 72 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('72 bottles of beer on the wall, 72 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 71 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('71 bottles of beer on the wall, 71 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 70 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('70 bottles of beer on the wall, 70 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 69 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('69 bottles of beer on the wall, 69 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 68 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('68 bottles of beer on the wall, 68 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 67 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('67 bottles of beer on the wall, 67 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 66 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('66 bottles of beer on the wall, 66 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 65 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('65 bottles of beer on the wall, 65 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 64 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('64 bottles of beer on the wall, 64 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 63 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('63 bottles of beer on the wall, 63 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 62 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('62 bottles of beer on the wall, 62 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 61 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('61 bottles of beer on the wall, 61 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 60 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('60 bottles of beer on the wall, 60 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 59 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('59 bottles of beer on the wall, 59 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 58 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('58 bottles of beer on the wall, 58 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 57 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('57 bottles of beer on the wall, 57 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 56 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('56 bottles of beer on the wall, 56 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 55 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('55 bottles of beer on the wall, 55 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 54 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('54 bottles of beer on the wall, 54 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 53 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('53 bottles of beer on the wall, 53 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 52 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('52 bottles of beer on the wall, 52 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 51 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('51 bottles of beer on the wall, 51 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 50 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('50 bottles of beer on the wall, 50 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 49 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('49 bottles of beer on the wall, 49 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 48 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('48 bottles of beer on the wall, 48 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 47 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('47 bottles of beer on the wall, 47 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 46 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('46 bottles of beer on the wall, 46 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 45 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('45 bottles of beer on the wall, 45 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 44 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('44 bottles of beer on the wall, 44 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 43 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('43 bottles of beer on the wall, 43 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 42 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('42 bottles of beer on the wall, 42 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 41 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('41 bottles of beer on the wall, 41 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 40 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('40 bottles of beer on the wall, 40 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 39 bottles of beer on the wall.');document.write('<br>')
document.write('<br>');
document.write('39 bottles of beer on the wall, 39 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 38 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('38 bottles of beer on the wall, 38 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 37 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('37 bottles of beer on the wall, 37 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 36 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('36 bottles of beer on the wall, 36 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 35 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('35 bottles of beer on the wall, 35 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 34 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('34 bottles of beer on the wall, 34 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 33 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('33 bottles of beer on the wall, 33 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 32 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('32 bottles of beer on the wall, 32 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 31 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('31 bottles of beer on the wall, 31 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 30 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('30 bottles of beer on the wall, 30 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 29 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('29 bottles of beer on the wall, 29 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 28 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('28 bottles of beer on the wall, 28 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 27 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('27 bottles of beer on the wall, 27 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 26 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('26 bottles of beer on the wall, 26 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 25 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('25 bottles of beer on the wall, 25 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 24 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('24 bottles of beer on the wall, 24 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 23 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('23 bottles of beer on the wall, 23 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 22 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('22 bottles of beer on the wall, 22 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 21 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('21 bottles of beer on the wall, 21 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 20 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('20 bottles of beer on the wall, 20 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 19 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('19 bottles of beer on the wall, 19 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 18 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('18 bottles of beer on the wall, 18 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 17 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('17 bottles of beer on the wall, 17 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 16 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('16 bottles of beer on the wall, 16 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 15 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('15 bottles of beer on the wall, 15 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 14 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('14 bottles of beer on the wall, 14 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 13 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('13 bottles of beer on the wall, 13 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 12 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('12 bottles of beer on the wall, 12 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 11 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('11 bottles of beer on the wall, 11 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 10 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('10 bottles of beer on the wall, 10 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 9 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('9 bottles of beer on the wall, 9 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 8 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('8 bottles of beer on the wall, 8 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 7 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('7 bottles of beer on the wall, 7 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 6 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('6 bottles of beer on the wall, 6 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 5 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('5 bottles of beer on the wall, 5 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 4 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('4 bottles of beer on the wall, 4 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 3 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('3 bottles of beer on the wall, 3 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 2 bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('2 bottles of beer on the wall, 2 bottles of beer.');document.write('<br>');
document.write('Take one down and pass it around, 1 bottle of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('1 bottle of beer on the wall, 1 bottle of beer.');document.write('<br>');
document.write('Take one down and pass it around, no more bottles of beer on the wall.');document.write('<br>');
document.write('<br>');
document.write('No more bottles of beer on the wall, no more bottles of beer.');document.write('<br>');
document.write('Go to the store and buy some more, 99 bottles of beer on the wall.');document.write('<br>');
}
var x=prompt('Text:'); //переменная x, сюда вводим код на яп hq9+
var inlength; //переменная, с помощью которой мы узнаем длину введенного кода, чтобы в дальнейшем иметь возможность обьяснить дяде йаваскрипту, чтобы остановил чтение кода когда читать будет уже нечего.
var n=0, z=''; //переменная n, индекс читаемого символа кода, переменная z, читаемый интерпретатором символ
var q=x; //переменная q, оригинал кода(те кто знает яп hq9+ поймут он зачем)
var cnt=0; //счетчик, обьяснение читай выше в скобках
inlength=x.length+1; //есть в js-е такой момент, отсчет любого индекса ведется с 0, а когда мы просим его показать нам длину текста, отсчет ведется с единицы, поэтому мы здесь это учитываем

// x=x.split('');
while(n < inlength){ //выполняем чтение до момента когда n станет больше inlength(символы кончатся)
z=x[n]; //указываем интерпретатору какой символ читать, беря его из x
if(z=='H'){ //думаю в нескольких последующих пунктах все понятно, при чтении определенного символа на экран выводится то что нужно
   document.write('Hello World!<br>');
}   
if(z=='h'){
   document.write('Hello World!<br>');
}
if(z=='Q'){
   document.write(q+'<br>');
}
if(z=='q'){
   document.write(q+'<br>');
}
if(z=='9'){
   poem();
}
if(z=='+'){
   
   cnt=cnt+1;
   document.write(cnt+'<br>');
}
if(z=='-'){
   cnt=cnt-1;
document.write(cnt+'<br>');
}
if(z=='0'){
   
   cnt=0;
   document.write(cnt+'<br>');
}
n=n+1; //увеличиваем индекс на 1, зачем? ))))))))))))))) чтобы дядя джаваскрипт все время не читал одну и ту же буковку сыночек мой)))

}   
// document.write('<br>'+x);
</script>
Последний раз редактировалось Vahagn 23 фев 2018, 16:27, всего редактировалось 1 раз.
 Не открывать
Ты провалил тест на силу воли, слабак!

Пасан ты куда воду льешь!!! У меня потолок рухнет я три недель назад ремонт сделал!!

Black Square Studios

Казачий раннер
http://black-rect.epizy.com/pages/game.php?f=1
Аватара пользователя

Участник
Сообщений: 529
Я тут с 01 ноя 2013
Откуда: Армения
Двиг: CC, C2, C3, JS
Лицензия: Buisness
Skype: Vahagn Buniatyan
Репутация 22 [ ? ]

Сообщение Интерпретатор HQ9+
» 23 фев 2018, 16:23

И да, С 23 Февраля вас парни! :drinks:
 Не открывать
Ты провалил тест на силу воли, слабак!

Пасан ты куда воду льешь!!! У меня потолок рухнет я три недель назад ремонт сделал!!

Black Square Studios

Казачий раннер
http://black-rect.epizy.com/pages/game.php?f=1
Аватара пользователя

Участник
Сообщений: 529
Я тут с 01 ноя 2013
Откуда: Армения
Двиг: CC, C2, C3, JS
Лицензия: Buisness
Skype: Vahagn Buniatyan
Репутация 22 [ ? ]

Сообщение Интерпретатор HQ9+
» 24 июн 2019, 09:47

Vahagn, есть способ намного короче, где 99 строчек превращаются в 3. Используй цикл for, чтобы вывести все строчки стиха.

Код: Выделить всё
<script>
//функция выводящая песенку 99 бутылок пива, ах да: без тега <br> он все напишет на одной строке, что нам не нужно
function poem(){
  for (var i = 99; i >= 1; i --) {
    document.write(i + ' bottles of beer on the wall, '+i+' bottles of beer.<br>');
  }
 
document.write('No more bottles of beer on the wall, no more bottles of beer.');document.write('<br>');
document.write('Go to the store and buy some more, 99 bottles of beer on the wall.');document.write('<br>');
}
var x=prompt('Text:'); //переменная x, сюда вводим код на яп hq9+
var inlength; //переменная, с помощью которой мы узнаем длину введенного кода, чтобы в дальнейшем иметь возможность обьяснить дяде йаваскрипту, чтобы остановил чтение кода когда читать будет уже нечего.
var n=0, z=''; //переменная n, индекс читаемого символа кода, переменная z, читаемый интерпретатором символ
var q=x; //переменная q, оригинал кода(те кто знает яп hq9+ поймут он зачем)
var cnt=0; //счетчик, обьяснение читай выше в скобках
inlength=x.length+1; //есть в js-е такой момент, отсчет любого индекса ведется с 0, а когда мы просим его показать нам длину текста, отсчет ведется с единицы, поэтому мы здесь это учитываем

// x=x.split('');
while(n < inlength){ //выполняем чтение до момента когда n станет больше inlength(символы кончатся)
z=x[n]; //указываем интерпретатору какой символ читать, беря его из x
if(z=='H'){ //думаю в нескольких последующих пунктах все понятно, при чтении определенного символа на экран выводится то что нужно
   document.write('Hello World!<br>');
}   
if(z=='h'){
   document.write('Hello World!<br>');
}
if(z=='Q'){
   document.write(q+'<br>');
}
if(z=='q'){
   document.write(q+'<br>');
}
if(z=='9'){
   poem();
}
if(z=='+'){
   
   cnt=cnt+1;
   document.write(cnt+'<br>');
}
if(z=='-'){
   cnt=cnt-1;
document.write(cnt+'<br>');
}
if(z=='0'){
   
   cnt=0;
   document.write(cnt+'<br>');
}
n=n+1; //увеличиваем индекс на 1, зачем? ))))))))))))))) чтобы дядя джаваскрипт все время не читал одну и ту же буковку сыночек мой)))

}   
// document.write('<br>'+x);
</script>


P.S. я знаю что прошёл целый год)
Сколько языков программирования ты знаешь — столько раз ты ПРОГРАММИСТ!

 Мои проекты
Rect JS Engine: viewtopic.php?f=116&t=14949
INI Editor Pro: viewtopic.php?f=14&t=13354
Симулятор Бомжа: viewtopic.php?f=116&t=13457
Mineсraft 2D JS: viewtopic.php?f=116&t=13642
Змейка на JS: viewtopic.php?f=116&t=13990
Project Sinus JS: viewtopic.php?f=116&t=13837

Black Square

Моя Музыка
Аватара пользователя

Участник
Сообщений: 192
Я тут с 03 фев 2017
Откуда: Киев
Двиг: C2, СC, JS
Лицензия: Business
Skype: sviatkoslav@gmail.co
Репутация 11 [ ? ]



Вернуться в Web

Сейчас эту тему просматривают

Зарегистрированные пользователи: нет зарегистрированных пользователей

Наверх