Sometimes you're used to doing things this way or that way without thinking about what could be a better solution... :-)
Never realized that functions can return whole arrays! Thanks for that hint. Rolf Am 23.02.2012 21:51, schrieb nando: > felder as STRING[] is a parameter passed into sub > It is no good outside of SUB > > What you should do is make your sub > > PUBLIC FUNCTION ListeKundeFelder(schlysselnr AS String, felder AS String[]) > AS STRING[] > > and return the string[], assigning it to the original felder[] > > -Fernando > > > > ---------- Original Message ----------- > From: Rolf-Werner Eilert<eilert-sprac...@t-online.de> > To: mailing list for gambas users<gambas-user@lists.sourceforge.net> > Sent: Wed, 22 Feb 2012 17:41:53 +0100 > Subject: [Gambas-user] String array empty after SUB (Gambas 2) > >> 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@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/gambas-user > ------- End of Original Message ------- > > > ------------------------------------------------------------------------------ > 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@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user