Function not allowed within a procedure

我怕爱的太早我们不能终老 提交于 2019-12-12 05:01:31

问题


I have an assignment to write a macro in LibreOffice that will code a message using XOR operation. I get the problem: Function not allowed within a procedure. when I try to run the macro. This is the code:

REM  *****  BASIC  *****
Sub Main
end Sub

function izracunajHash(geslo, zacetni_hash)
    zacetni_hash = 17520
    hash = zacetni_hash
    mask = &H00FFFFFF
    dolzina = len(geslo)
    If dolzina > 0 Then
        for f=1 to dolzina step +1
            podniz = mid(geslo,dolzina,1)
            char = Asc(podniz)
            hash = 33*hash + char
            hash = hash AND mask
            dolzina = dolzina +1
            hash = hash AND &H00FFFFFF
        next f
        izracunajHash = hash
End function

function kodiraj(niz) //this is where the problem occurs according to LibreOffice
    y = 1
    if Len(niz) > 0 Then
        x = Len(niz)
        Do While y > (x+1)
            sign = Mid(niz, y, 1)
            z1 = Asc(sign)
            if z1 > 31 Then
                z2 = (CInt(rnd()*31))
                z1 = z1 XOR z2
                z1 = Chr(z1)
                Mid(niz,y,1,z1)
            End If
            y = y + 1
        Loop
    End If
    kodiraj = niz
End function

Thanks in advance. (I cut some unimportant code that I didn't have to write myself)


回答1:


In your first function you have an if statement without a corresponding End If.



来源:https://stackoverflow.com/questions/34162394/function-not-allowed-within-a-procedure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!