-
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
Syntax Loop For
- This topic has 1 reply, 2 voices, and was last updated 7 years, 10 months ago by Bernhard Kantz.
-
AuthorPosts
-
January 18, 2017 at 5:30 pm #12374kamil ABDOUL MADJIDMember
Hello,
I’m new with FlexProDim A, B
For j = 0 To 100 Step 0.01 Do
A[j] = j
EndFor i = 0 To 100 Step 0.01 Do
If B < 0.1 then B[i]= 160 else B[i]= 124.6 + (2.77/i) End Signal ( B, A) [/code] I have an error and don't know what is it. What's wrong with my code. Thank you for your help.January 19, 2017 at 9:00 am #12916Bernhard KantzParticipantThe 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 likeDim 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.
-
AuthorPosts
- You must be logged in to reply to this topic.