-
FlexPro
- Zoom sur FlexPro
- Fonctionnalités & Options
- Domaines d’application
- Tous les avantages
- Nouveau dans FlexPro 2021
- Testez FlexPro gratuitement
- FlexPro View OEM Freeware
- Conseils d’achat
- Login
- Langue
-
-
-
- +49 6894 929600
- infoweisang.com
- Google Maps
- Produits
- News
- Support
- Société
- Emplois
- Contact
- Login
- Langue
-
-
-
- +49 6894 929600
- infoweisang.com
- Google Maps
Accueil > Community > FPScript > Syntax Loop For > Reply To: Syntax Loop For
![Bernhard Kantz](https://www.weisang.com/wp-content/uploads/2016/09/default_avatar.jpg)
The syntax error is caused by the missing ‘End’ of the If-Then-Else statement. Correcting it reveals the deeper problems with the formula.
After Dim A,B both variables are initialized with the datatype Empty. To build a dataset, one can append values at the end (or at the beginning). If one already knows the desired length and datatype, a proper initialization is more efficient. For a dataset of e.g. 100 floating point values (set to the void value) one can use an expression like
Dim A = ? # 100
After that, one can access the elements by indices like in your first loop. But be aware, they will be truncated to integers so A[0] will hold 0.99, A[1] 1.99, and so forth. If you need a dataset with 10001 entry from 0 to 100 and increment 0.01, you can append the values like in the following For-loop:
Dim A
For i = 0 To 100 Step 0.01 Do
A := i // short for A = A : i, append value of i to dataset A
End
But there is already a FPScript function creating the same dataset with
Series(0, 100, 0.01)
Refering to your second For-loop the variable B has to be initialized first like A to access entries via the index operator. There maybe a typo: since B has no definite value it would make more sense to test if i is less than 0.1 than B. If you intent to build a dataset with 10001 entries, one may code as following:
Dim i = Series(0, 100, 0.01) // or reuse A
// set all entries for the second case
Dim B = 124.6 + 2.77 / i
// find all indices where i is not greater or equal 0.1
Dim idx = ValuesAboveLevel(i, 0.1, EVENT_INDEX + EVENT_COMPLEMENT)
// set those values to the fixed value
B[idx] = 160
To get into FPScript formula writing, we would suggest to look into the Reference chapter in the section ‘Analyzing Data Mathematically’ in the online help.