Re: [Gambas-user] String[] in Sub, what is going wrong

2016-04-28 Thread Jussi Lahtinen
I would guess somewhere in your code there is line, which make fntexc and
fontliste to point same memory address.
IE "fontliste = fntexc" or perhaps setFontNameList is called twice and that
time with fntexc as parameter.

Can you try to isolate the problem into small demonstration project? If
that is not error in the code (mostly that is the case!), it's bug in
Gambas.


Jussi

On Thu, Apr 28, 2016 at 10:00 AM, Rolf-Werner Eilert <
eilert-sprac...@t-online.de> wrote:

>
> Am 27.04.2016 18:39, schrieb T Lee Davidson:
> > 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,
> >
>
> Well, thank you. I will answer here to avoid double explanations. Thank
> you all for your answers!
>
> You are right, fntexc is declared upstairs in the module where this
> function is. The problem is, however, not fntexc but fontliste. The
> function is called from another module. Fontliste is declared PUBLIC
> there, and when the function is called, fontliste contains the items.
> But when fontliste shall be used within the function, it appears to be
> empty.
>
> So it is module 1 which has a string array named FontListe:
>
> Public FontListe As New String[]
> .
> .
> .
> Public Sub btnOK_Click()
> .
> .
>  ini.setFontNameList(FontListe)
> .
> .
> End
>
> And in module 2 ("ini") the contents is to be copied into the string
> array which is there:
>
> Private fntexc As New String[]
> .
> .
> .
> Public Sub setFontNameList(fontliste As String[])
> 'Dim i As Integer
>
>fntexc.Clear'When I stop here, fontliste is filled
>
>fntexc.Insert(fontliste) 'When I stop here, fontliste is empty
>
>' For i = 0 To fntliste.count - 1 'Thanks to Christof for the tip,
> but it doesn't run with Insert either
>'   fntexc.Add(fntliste[i])
>' Next
>
> End
>
> So my explanation is that I might need another string array which I
> declare within the calling Sub in module 1. But I cannot remember I have
> ever had a similar issue before. What confuses me most is that I can see
> the contents of the array when I enter the function, but it appears
> empty when I want to access it there.
>
> Rolf
>
>
>
> --
> Find and fix application performance issues faster with Applications
> Manager
> Applications Manager provides deep performance insights into multiple
> tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] String[] in Sub, what is going wrong

2016-04-28 Thread Gianluigi
And using classes instead of the modules?
See Attachment
Regards
Gianluigi

2016-04-28 9:00 GMT+02:00 Rolf-Werner Eilert :

>
> Am 27.04.2016 18:39, schrieb T Lee Davidson:
> > 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,
> >
>
> Well, thank you. I will answer here to avoid double explanations. Thank
> you all for your answers!
>
> You are right, fntexc is declared upstairs in the module where this
> function is. The problem is, however, not fntexc but fontliste. The
> function is called from another module. Fontliste is declared PUBLIC
> there, and when the function is called, fontliste contains the items.
> But when fontliste shall be used within the function, it appears to be
> empty.
>
> So it is module 1 which has a string array named FontListe:
>
> Public FontListe As New String[]
> .
> .
> .
> Public Sub btnOK_Click()
> .
> .
>  ini.setFontNameList(FontListe)
> .
> .
> End
>
> And in module 2 ("ini") the contents is to be copied into the string
> array which is there:
>
> Private fntexc As New String[]
> .
> .
> .
> Public Sub setFontNameList(fontliste As String[])
> 'Dim i As Integer
>
>fntexc.Clear'When I stop here, fontliste is filled
>
>fntexc.Insert(fontliste) 'When I stop here, fontliste is empty
>
>' For i = 0 To fntliste.count - 1 'Thanks to Christof for the tip,
> but it doesn't run with Insert either
>'   fntexc.Add(fntliste[i])
>' Next
>
> End
>
> So my explanation is that I might need another string array which I
> declare within the calling Sub in module 1. But I cannot remember I have
> ever had a similar issue before. What confuses me most is that I can see
> the contents of the array when I enter the function, but it appears
> empty when I want to access it there.
>
> Rolf
>
>
>
> --
> Find and fix application performance issues faster with Applications
> Manager
> Applications Manager provides deep performance insights into multiple
> tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>


DataTransfert-0.0.1.tar.gz
Description: GNU Zip compressed data
--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] String[] in Sub, what is going wrong

2016-04-28 Thread Rolf-Werner Eilert

Am 27.04.2016 18:39, schrieb T Lee Davidson:
> 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,
>

Well, thank you. I will answer here to avoid double explanations. Thank 
you all for your answers!

You are right, fntexc is declared upstairs in the module where this 
function is. The problem is, however, not fntexc but fontliste. The 
function is called from another module. Fontliste is declared PUBLIC 
there, and when the function is called, fontliste contains the items. 
But when fontliste shall be used within the function, it appears to be 
empty.

So it is module 1 which has a string array named FontListe:

Public FontListe As New String[]
.
.
.
Public Sub btnOK_Click()
.
.
 ini.setFontNameList(FontListe)
.
.
End

And in module 2 ("ini") the contents is to be copied into the string 
array which is there:

Private fntexc As New String[]
.
.
.
Public Sub setFontNameList(fontliste As String[])
'Dim i As Integer

   fntexc.Clear'When I stop here, fontliste is filled

   fntexc.Insert(fontliste) 'When I stop here, fontliste is empty

   ' For i = 0 To fntliste.count - 1 'Thanks to Christof for the tip, 
but it doesn't run with Insert either
   '   fntexc.Add(fntliste[i])
   ' Next

End

So my explanation is that I might need another string array which I 
declare within the calling Sub in module 1. But I cannot remember I have 
ever had a similar issue before. What confuses me most is that I can see 
the contents of the array when I enter the function, but it appears 
empty when I want to access it there.

Rolf


--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] String[] in Sub, what is going wrong

2016-04-27 Thread Daniel Lemke
I ran the code and I was able to populate fntexc with the array, but I
didn't see how you declared fntexc so I am unsure  what the difference is
between our implementations. For testing sake, I merely made fntexc a
public variable . If you were to provide more of the code, it would be a
lot easier to get a complete picture.

How are you declaring fntexc? If it is a locally scoped variable you will
need to either pass a reference to the sub or turn the sub into a function
to return data to fntexc.
On Apr 27, 2016 9:04 AM, "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
>
>
>
> --
> Find and fix application performance issues faster with Applications
> Manager
> Applications Manager provides deep performance insights into multiple
> tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] String[] in Sub, what is going wrong

2016-04-27 Thread Christof Thalhofer
Hello Rolf-Werner,

apart from the other ...

Am 27.04.2016 um 18:02 schrieb Rolf-Werner Eilert:

>For i = 0 To fontliste.count - 1
>  fntexc.Add(fontliste[i])
>Next

Easier would be:

fntexc.Insert(fontliste)


Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] String[] in Sub, what is going wrong

2016-04-27 Thread T Lee Davidson
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."

--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user