[Gambas-user] String array empty after SUB (Gambas 2)
Rolf-Werner Eilert
eilert-sprachen at ...221...
Thu Feb 23 09:09:53 CET 2012
That was it, Jussi, thanks a lot!
Here we can see what it is good for to know about OOP :-)
Regards
Rolf
Am 22.02.2012 18:49, schrieb Jussi Lahtinen:
> Just quick thought... maybe this "felder = feld.Copy()" gives new object
> reference feld to felder.
> And because feld is declared locally, the it is null after the sub and so
> is also felder.
>
> Perhaps you need to do "felder = feld.Copy()" manually with for each...
>
> Jussi
>
>
>
>
> On Wed, Feb 22, 2012 at 18:41, Rolf-Werner Eilert<
> eilert-sprachen at ...221...> wrote:
>
>> Now, this is a strange one :-) and I really have no idea what goes wrong
>> here.
>>
>> I've got a dialog which loads a list of names. I'm keeping such SUBs
>> that deal with files in a module called ldsv (brief for load-save).
>>
>> The dialog's part is simple, "ls" is the listbox:
>>
>> PRIVATE felder AS NEW String[]
>>
>> PUBLIC SUB ls_Click()
>>
>>
>> Label1.Text = "Nr. "& schlyssel[ls.Index]& ": "& ls[ls.Index].Text
>> 'here we jump into the SUB:
>> ldsv.ListeKundeFelder(schlyssel[ls.Index], felder)
>> 'now we should see the number of fields loaded:
>> lblTitel.Text = CStr(felder.Count)
>>
>> END
>>
>>
>> Now the SUB in module ldsv:
>>
>> PUBLIC SUB ListeKundeFelder(schlysselnr AS String, felder AS String[])
>> DIM t$ AS String
>> DIM feld AS NEW String[]
>>
>> felder.Clear
>>
>> t$ = File.Load(pfadKunden&/ schlysselnr& ".kunde")
>> t$ = Tag2Str(t$)
>>
>> feld = Split(t$, Chr$(10))
>>
>> IF feld[0] = "#!Stein3.1" THEN
>> feld.Delete(0, 2) 'das #! und die ID können weg
>> felder = feld.Copy()
>> END IF
>>
>> END
>>
>> When I put a stop at the END IF and watch the values, felder will have
>> 16 values from 0 - 15 containing strings just as expected. But when I
>> return to the dialog, felder is empty! This is especially weird as there
>> are other SUBs and FUNCTIONs en masse in my project that do it exactly
>> the same way.
>>
>> I cannot detect any mistake I made - or do you?
>>
>> Regards
>>
>> Rolf
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Virtualization& Cloud Management Using Capacity Planning
>> Cloud computing makes use of virtualization - but cloud computing
>> also focuses on allowing computing to be delivered as a service.
>> http://www.accelacomm.com/jaw/sfnl/114/51521223/
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> ------------------------------------------------------------------------------
> Virtualization& Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list