-
FlexPro
- Auf einen Blick
- Features & Optionen
- Einsatzgebiete
- Alle Vorteile
- Neu in FlexPro 2021
- FlexPro gratis testen
- FlexPro View OEM Freeware
- Kaufberatung
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
- Produkte
- News
- Support
- Unternehmen
- Jobs
- Kontakt
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
Syntax Loop For
- Dieses Thema hat 1 Antwort sowie 2 Teilnehmer und wurde zuletzt vor vor 7 Jahren, 11 Monaten von Bernhard Kantz aktualisiert.
-
AutorBeiträge
-
Januar 18, 2017 um 5:30 pm Uhr #12374kamil ABDOUL MADJIDMitglied
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.Januar 19, 2017 um 9:00 am Uhr #12916Bernhard KantzTeilnehmerThe 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.
-
AutorBeiträge
- Du musst angemeldet sein, um auf dieses Thema antworten zu können.