It is the same in almost all languages. unsigned char i; for(i=0; i<255; i++){} and unsigned int i; for(i=0; i<4294967295U; i++){} in C will never terminate.
In Gambas, Dim i As Integer For i = 0 To 2147483647 Next will not terminate either. You might think that because you say the range 0 To X, you expect to get each of those values, but the truth is that the For i = 0 To X is actually interpreted as for(i=0; i<=X; i++) which obviously does not work when X is the max value of that integer type. 2012/9/30 RICHARD WALKER <richard.j.wal...@ntlworld.com> > Sinclair BASIC on the QL used to have a FOR loop epilogue which could > be used to handle this sort of thing. A simple FOR loop was > > FOR index = start TO stop > > > On 30/09/2012, Jussi Lahtinen <jussi.lahti...@gmail.com> wrote: > > I think all Basics work this way! > > > > Test with any basic: > > > > For ii = 1 to 10 > > Next > > > > Print ii > > > > What you expect? I think all basic languages gives 11 as result. > > > > Jussi > > > > > > > > > > > > On Sun, Sep 30, 2012 at 10:14 PM, Kevin Fishburne < > > kevinfishbu...@eightvirtues.com> wrote: > > > >> This one bit me a while back and the answer was the same and I confirmed > >> it through testing. Maybe the documentation for For...Next should > >> mention it. I suspect many BASIC dialects don't work this way, which > >> could lead to confusion for new users of GAMBAS. I could be wrong, but I > >> think even GAMBAS used to not work this way, which makes the issue even > >> more confusing. Then again, the root of the issue doesn't really have > >> anything to do with For...Next but in how variables deal with > >> assignments that are out of range. > >> > >> On 09/30/2012 11:40 AM, Jussi Lahtinen wrote: > >> > It is not bug, Richard is right. > >> > > >> > Jussi > >> > > >> > > >> > > >> > On Sun, Sep 30, 2012 at 6:32 PM, Tobias Boege <tabo...@gmail.com> > >> > wrote: > >> > > >> >> On Sun, 30 Sep 2012, Ru Vuott wrote: > >> >>> ...I have: > >> >>> > >> >>> [Gambas 3] > >> >>> Version=3.3.0 > >> >>> > >> >>> > >> >>> > >> >>> > >> >>> > >> >>> --- Dom 30/9/12, Ru Vuott <vu...@yahoo.it> ha scritto: > >> >>> > >> >>>> Da: Ru Vuott <vu...@yahoo.it> > >> >>>> Oggetto: [Gambas-user] Unending cycle "For...Next" with variable As > >> >> Byte > >> >>>> A: gambas-user@lists.sourceforge.net > >> >>>> Data: Domenica 30 settembre 2012, 16:57 > >> >>>> Hello, > >> >>>> > >> >>>> maybe I'm in the clouds.... but I don't understand why this > >> >>>> cycle: > >> >>>> > >> >>>> ********** > >> >>>> Public Sub Button1_Click() > >> >>>> > >> >>>> ? Dim j As Byte > >> >>>> > >> >>>> ? For j = 0 To 255 > >> >>>> > >> >>>> ???Print j > >> >>>> > >> >>>> ? Next > >> >>>> > >> >>>> End > >> >>>> ********** > >> >>>> > >> >>>> runs "ad infinitum" ! > >> >>>> > >> >>>> Regards > >> >>>> vuott > >> >>>> > >> >> Can confirm that with rev5189. Richard's guess sounds logical. "For > >> >> To" > >> is > >> >> inclusive: [0; 255] and that's everything you can represent with Byte > >> >> width. > >> >> You won't ever detect Byte > 255. > >> >> > >> >> > >> > >> -- > >> Kevin Fishburne > >> Eight Virtues > >> www: http://sales.eightvirtues.com > >> e-mail: sa...@eightvirtues.com > >> phone: (770) 853-6271 > >> > >> > >> > >> > ------------------------------------------------------------------------------ > >> Everyone hates slow websites. So do we. > >> Make your web apps faster with AppDynamics > >> Download AppDynamics Lite for free today: > >> http://ad.doubleclick.net/clk;258768047;13503038;j? > >> http://info.appdynamics.com/FreeJavaPerformanceDownload.html > >> _______________________________________________ > >> Gambas-user mailing list > >> Gambas-user@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/gambas-user > >> > > > ------------------------------------------------------------------------------ > > Everyone hates slow websites. So do we. > > Make your web apps faster with AppDynamics > > Download AppDynamics Lite for free today: > > http://ad.doubleclick.net/clk;258768047;13503038;j? > > http://info.appdynamics.com/FreeJavaPerformanceDownload.html > > _______________________________________________ > > Gambas-user mailing list > > Gambas-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://ad.doubleclick.net/clk;258768047;13503038;j? > http://info.appdynamics.com/FreeJavaPerformanceDownload.html > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://ad.doubleclick.net/clk;258768047;13503038;j? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user