For Next Step

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: For Next Step

Post by charvista »

@Tenaja
This is in fact exactly my idea with the PRECISION n.

Code: Select all

Precision=2
n=12345
Debug n/Pow(10,Precision)
:D
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: For Next Step

Post by STARGÅTE »

beautiful, and then we are back at the beginning that it is sufficient to have integers in For:Next :lol:

Code: Select all

Precision=2
For n = 12300 To 12345 Step 15
	Debug n/Pow(10,Precision)
Next
sorry, but I just do not understand the necessity of floats in For:Next loops
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: For Next Step (with integer variable instead of constant

Post by charvista »

OK Stargate :D
But IdeasVacuum's main request:
The Step of a For Next loop is limited to an integer constant. There are occasions where an integer is required instead of a constant.
is still a good request, because:

Code: Select all

Precision.i=2
A.d=123.00
Z.d=123.45
S.d=1.5

Start.i=A*Pow(10,Precision)
Stop.i =Z*Pow(10,Precision)
Stap.i =S*Pow(10,Precision)

For n = Start To Stop Step Stap
    Debug n/Pow(10,Precision)
Next
The variable Stap should be an integer variable, instead of an integer constant.
So, for IdeasVacuum's request, I still vote a +1
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: For Next Step

Post by chris319 »

so, no For:To:Next with float or doubles!
Add STEP to that list. That's the most elegant solution and easily worked around with WHILE or REPEAT if the calculation involves floats or doubles.
Post Reply