Пишу, по большей части, про историю, свою жизнь и немного про программирование.

99 бутылок: Microsoft Dialer

11. Microsoft Dialer. Можно только удивляться, сколько языков программирования можно найти у себя на компьютере. Эта песнь о пиве написана на языке программирования SCP-файлов, файлов, руководящих соединением через модем. Насколько я понял в этом языке есть примитивная арифметика, вывод, циклы и ветвление (правда без else), но нет преобразования типов. Так что переменная цикла nB используется только для упрощения. Но как бы то ни было, написать программу у меня получилось. :)

Скрипт, выводящий песню о пиве.

; "99 beer" song by Evgeny V. Stepanischev
proc main
    string szA = "9"
    string szB = "9"
    string szS = " bottles"
    string szX = ""
    string szY = ""

    integer nB = 99

    set screen keyboard on
    delay 2

    ; Эту строчку ждет мой провайдер
    ; У вас она может быть другой
    transmit "@D^M^M"

    while Nb>0 do

    if szA!="0" then
    transmit szA
    endif

    transmit szB

    szS = " bottles"
    if nB==1 then
    szS = " bottle"
    endif

    transmit szS
    transmit " of beer on the wall, "

    if szA!="0" then
    transmit szA
    endif

    transmit szB
    transmit szS
    transmit " of beer.^M"
    transmit "Take one and pass it around,^M"

    szX = szA

    if szB=="0" then
        if szA=="1" then
        szX = "0"
        endif

        if szA=="2" then
        szX = "1"
        endif

        if szA=="3" then
        szX = "2"
        endif

        if szA=="4" then
        szX = "3"
        endif

        if szA=="5" then
        szX = "4"
        endif

        if szA=="6" then
        szX = "5"
        endif

        if szA=="7" then
        szX = "6"
        endif

        if szA=="8" then
        szX = "7"
        endif

        if szA=="9" then
        szX = "8"
        endif

    szY = "9"

    endif

    if szB=="1" then
    szY = "0"
    endif

    if szB=="2" then
    szY = "1"
    endif

    if szB=="3" then
    szY = "2"
    endif

    if szB=="4" then
    szY = "3"
    endif

    if szB=="5" then
    szY = "4"
    endif

    if szB=="6" then
    szY = "5"
    endif

    if szB=="7" then
    szY = "6"
    endif

    if szB=="8" then
    szY = "7"
    endif

    if szB=="9" then
    szY = "8"
    endif

    szA = szX
    szB = szY

    nB = nB - 1

    if nB==0 then
    transmit "No more bottles of beer on the wall.^M"
    endif

    if nB!=0 then
    if szA!="0" then
    transmit szA
    endif

    transmit szB

    szS = " bottles"
    if nB==1 then
    szS = " bottle"
    endif

    transmit szS
    transmit " of beer on the wall.^M^M"
    endif

    endwhile


    transmit "No more bottles of beer...^M"
    transmit "Go to the store and buy some more...^M"
    transmit "99 bottles of beer.^M"

    delay 99
endproc