Confusion over passing by reference vs passing by value
#11
As far as I know, BASIC doesn't allow one to set a whole array to some value all at once, which is what you're trying to do here:

satz3() = "SagNiemalsNie!"

You need an index of some sort to assign the value to, such as the below here:

Code: (Select All)
Dim satz3(10) As String


Print
satz3(0) = "SagNiemalsNie!"
Satztest3 satz3() '!! Damit hat der Compiler Probleme
Print "Wert des Feldes von satz3 nach der Subroutine: ", satz3(0)

End



Sub Satztest3 (feld() As String)
    feld(0) = feld(0) + "DonaldDuck"
End Sub

Note also that you can not pass arrays via parenthesis.

Satztest3 (satz3()) -- this is bugged and produces a c++ compile failure.

Satztest3 satz3() -- change it to this and it works perfectly fine.
Reply


Messages In This Thread
RE: Confusion over passing by reference vs passing by value - by SMcNeill - 06-19-2022, 06:20 PM



Users browsing this thread: 3 Guest(s)