[Gambas-user] String[] in Sub, what is going wrong
T Lee Davidson
t.lee.davidson at ...626...
Wed Apr 27 18:39:02 CEST 2016
On 04/27/2016 12:02 PM, Rolf-Werner Eilert wrote:
> This is the code:
>
> Public Sub setFontNameList(fontliste As String[])
> Dim i As Integer
>
> fntexc.Clear
>
> For i = 0 To fontliste.count - 1
> fntexc.Add(fontliste[i])
> Next
>
> End
>
> It didn't run, so I set a Wait to the line fntexc.Clear. "fontliste[]"
> is delivered as it should, it has 3 items. But fontliste.Count is 0,
> fontliste.Max would be -1. So it is never copied.
>
> What is going wrong here???
>
> Regards
> Rolf
>
I have to assume that "fntexc" is a 'global' since it is not declared in the Sub.
This code...
' Gambas module file
Public fntexc As String[]
Public Sub Main()
Dim sFont As String
fntexc = []
setFontNameList(["courier", "helvetica", "arial"])
For Each sFont In fntexc
Print sFont
Next
End
Public Sub setFontNameList(fontliste As String[])
Dim i As Integer
Debug fontliste.Count
fntexc.Clear
For i = 0 To fontliste.count - 1
fntexc.Add(fontliste[i])
Next
End
...works, and outputs:
MMain.setFontNameList.19: 3
courier
helvetica
arial
Hope that helps,
--
Lee
__________
"Artificial Intelligence is no match for natural stupidity."
More information about the User
mailing list