for-next

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

for-next

Post by dobro »

please Fred !! :?

a hope of several years!!

to be able to make :

Code: Select all

a.f=20.2
b.f=2.5
c.f=2.2

for t.f=c.f to a step b.f
debug t
next t

WITH FOR-next not another thing!! :)


je prefere utiliser les boucle For-next comme dans le temps en Basic !!
vraiment si tu pouvait m'ajouter ça dans le Purebasic , pour apporter
une vraie touche basic au PureBasic :D, tu ferai un heureux !!!

ps: ne me donnez pas des façon de remplacement, c'est un For-next comme citée ci-dessus que j'aimerai .. Merci :D

google translate
I prefer to use the For-next loop as in time in BASIC!!
really if you that in Purebasic could add me, to bring
a true key BASIC in PureBasic Very Happy, you will make happy!!!

PS: do not give me a way of replacement, it is For-next as quoted above that I will like. Thank you :D
Last edited by dobro on Sat Sep 22, 2007 12:00 pm, edited 2 times in total.
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

If this suggestion will be taken into account,
I strongly request to keep the old For/Next statement for Integers absolutely unchanged for performance reasons.

@dobro
if you wrote in english, I would've been able to understand your argument (if it is one).
oh... and have a nice day.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post by dobro »

Kaeru Gaman wrote: @dobro
if you wrote in english, I would've been able to understand your argument (if it is one).

My message was addressed has God the Father “Fred”
and this one speaks French…
I will have write in araméen if I had wanted addressed to me has other God: lol:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Re: for-next

Post by Dreamland Fantasy »

dobro wrote:please Fred !! :?

a hope of several years!!

to be able to make :

Code: Select all

a.f=20.2
b.f=2.5
c.f=2.2

for t.f=c.f to a step b.f
debug t
next t
I must admit I do find it slightly annoying myself when using floating points or quads since I do prefer the For...Next rather than While...Wend or Repeat...Until loops, but it isn't that difficult to recode it as:

Code: Select all

a.f=20.2 
b.f=2.5 
c.f=2.2 

t.f=c.f
While t<a
  Debug t
  t+b
Wend
or:

Code: Select all

a.f=20.2 
b.f=2.5 
c.f=2.2 

t.f=c.f
Repeat
  Debug t
  t+b
Until t>=a

Kind regards,

Francis.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

dobro wrote:
Kaeru Gaman wrote: @dobro
if you wrote in english, I would've been able to understand your argument (if it is one).

My message was addressed has God the Father “Fred”
and this one speaks French…
I will have write in araméen if I had wanted addressed to me has other God: lol:
so adress him in the French forums or via PM.
It's simply unpolite.
I won't write German if I want to adress Freak, either.

If you have arguments, state it to the audience, and use english to adress the audience.
oh... and have a nice day.
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Re: for-next

Post by dell_jockey »

Dreamland Fantasy wrote:
dobro wrote:please Fred !! :?

a hope of several years!!

to be able to make :

Code: Select all

a.f=20.2
b.f=2.5
c.f=2.2

for t.f=c.f to a step b.f
debug t
next t
I must admit I do find it slightly annoying myself when using floating points or quads since I do prefer the For...Next rather than While...Wend or Repeat...Until loops, but it isn't that difficult to recode it as:

Code: Select all

a.f=20.2 
b.f=2.5 
c.f=2.2 

t.f=c.f
While t<a
  Debug t
  t+b
Wend
or:

Code: Select all

a.f=20.2 
b.f=2.5 
c.f=2.2 

t.f=c.f
Repeat
  Debug t
  t+b
Until t>=a

Kind regards,

Francis.
These suggestions are dangerous, as fractions in PB are not encoded as BCD, but are merely float approximations. The result is a loop that will run most of the time, but not neccesarily each and every time...

Been there, debugged that, foolish me... :(
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

The compiler may be able to know what type of for next to start based upon the type of numbers involved. I don't think it would need a different statement?
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Re: for-next

Post by Dreamland Fantasy »

dell_jockey wrote:These suggestions are dangerous, as fractions in PB are not encoded as BCD, but are merely float approximations. The result is a loop that will run most of the time, but not neccesarily each and every time...

Been there, debugged that, foolish me... :(
I've been there myself many a time! :)

If I need more precision I tend to use doubles instead of floats, but I hear what you say. I don't know of any way to avoid it.

Kind regards,

Francis.
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Re: for-next

Post by dell_jockey »

Dreamland Fantasy wrote:
dell_jockey wrote:These suggestions are dangerous, as fractions in PB are not encoded as BCD, but are merely float approximations. The result is a loop that will run most of the time, but not neccesarily each and every time...

Been there, debugged that, foolish me... :(
I've been there myself many a time! :)

If I need more precision I tend to use doubles instead of floats, but I hear what you say. I don't know of any way to avoid it.

Kind regards,

Francis.
Francis,

if you have an integer multiplicator - one that is also the loop controlling variable, and a float value that defines the stepsize / increment per loop, you could multiply these two inside the loop and use the result for further processing. Like in:

Code: Select all

a.f
StepSize.f = 0.5

for Index=1 to 100            ;  only integers or integer vars here...
   a.f = Index * StepSize     ;  step 0.5 here
   ; continue using a.f for further processing
   debug a.f
next Index
Last edited by dell_jockey on Sat Sep 22, 2007 10:31 pm, edited 4 times in total.
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

and this will again make a float-for/next obsolete.

... I think you mean the classic precision-problem, don't you?

Code: Select all

a.f = 10000000000
Debug a
a + 2
Debug a
a + 2
Debug a
a + 2
Debug a
oh... and have a nice day.
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

Kaeru Gaman wrote:and this will again make a float-for/next obsolete.

... I think you mean the classic precision-problem, don't you?
Quite so - in der Tat...
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Chris
User
User
Posts: 60
Joined: Wed Jun 11, 2003 4:54 pm
Location: Somewhere... But i can see you!

Post by Chris »

Kaeru Gaman wrote:
dobro wrote:
Kaeru Gaman wrote: @dobro
if you wrote in english, I would've been able to understand your argument (if it is one).

My message was addressed has God the Father “Fred”
and this one speaks French…
I will have write in araméen if I had wanted addressed to me has other God: lol:
so adress him in the French forums or via PM.
It's simply unpolite.
I won't write German if I want to adress Freak, either.

If you have arguments, state it to the audience, and use english to adress the audience.
Several persons who don't know French, comes on our forum, and wrote in English. They were always received correctly.

Can you to make the same thing?
My english is bad !!!... It's normal, i'm french :lol:
My english is not really the English.
It's the FrogLish (Froggy's English) ;)
Dräc
Enthusiast
Enthusiast
Posts: 150
Joined: Sat Oct 09, 2004 12:10 am
Location: Toulouse (France)
Contact:

Post by Dräc »

@Kaeru Gaman
Dobro’s humour is a little bit special so don’t be surprise. :)
But in my point of view, his post starts in English and he suggests a translation of the French part. It is not Shakespeare-writing (true for me too) but it isn’t impolite at all.
Notice that Dobro doesn’t pollute the English forum. Moreover I find that Dobro makes more and more effort in writing English. So I encourage him to persevere!
So no matter! :wink:
Dräc
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

They were always received correctly.

Can you to make the same thing?
I just told him that I didn't understand what he wrote in french.
I appreciate that he edited in the translation.

my second answer was to his nosy remark, he adressed Fred not me.
I just said, then, if you adress Fred, adress him only and not me, too.
that's all.
It wasn't meant as an offence, though I felt a little bit offended.


on the german forums we want to recieve english writing persons well, too.
we also help french people when using a translator.
Cpl.Bator presented one of his projects there a while ago and we had no problem at all.


but I think it's still a difference between writing "the international" language in a specific forum,
and writing a specific language in the international forum.

I don't understand french or spanish or italian well enough to follow such a posting,
and I don't expect anyone to understand german well enough to let me post in german.
oh... and have a nice day.
Post Reply