FlexPro
HistoryBase
Ingénierie
Formation
Téléchargements
Assistance FlexPro
Connaissance
Communauté
À propos de nous
Références
Emplois
Contact général
Liste des revendeurs
Assistance FlexPro
FR
DE
EN
Porte-plaquette
Produits et solutions
Support et téléchargements
Entreprise
Magazine
Contact
Langue
MyWeisang

Paramètres du compte.

Topic

If-Condition with empty variable

Page d'accueil ' Communauté ' FPScript ' Condition If avec variable vide

Voir les messages de 4 - 1 à 4 (sur un total de 4)
  • Auteur
    Messages
  • #33658
    Leon D
    Participant

    Hey,

    I do have measurements with an Measurment number, but some Measurement number do not exist.

    For context, I have the following code. In general it works fine.

    Dim SourceData = [IC_I_U_RMS, IHV_Sys_ave, MeasNr, Record]
    Dim maxIHV, maxIC
    Dim Idx, _Event, _Event2, maxMeasNr, Idx2
    Dim Maxima, Idexes, baum
    Dim startIdx, endIdx
    maxMeasNr = Maximum(MeasNr.Y)
    
    
    For i = 1 To maxMeasNr Do
    
    _Event = ValuesInInterval(MeasNr, i, i, EVENT_INDEX)
    _Event2 = ValuesInInterval(Record, 1, 1, EVENT_INDEX)
    Idx = IndexAnd(_Event, _Event2)
    
    
    If Idx = ???  Then
    	maxIHV :="NaN"
    	maxIC :="NaN"
    Else
    	startIdx = Minimum(Idx)
    	endIdx = Maximum(Idx)
    	maxIHV := Maximum(IHV_Sys_ave[startIdx, endIdx], )
    	maxIC := Maximum(IC_I_U_RMS[startIdx, endIdx], )
    End
    
    Maxima = {maxIHV, maxIC}
    
    End

    My Problem is, that if “IndexAnd()” has no common indexes, it outputs an empty variable. This happens when the MeasNr doesnt exist. If the MeasNr doesnt exist the code is supposed to write down “NaN”. So if the variable Idx is empty the code should write “NaN” and if it isn`t empty it should write an value.

    What i can`t figure out is how to write the “if var Idx equals empty then…” = If Idx = ?EMPTY? Then…

    How can i solve this? I can`t put down: False, “”, 0 etc.

    Thanks in advance!

     

     

     

    #33659
    Stefan S.
    Maître des clés

    If the ValuesInterval doesn’t find an event, it returns a data series with zero values. So you can test this with the following code:

    If NumberOfRows(Idx) == 0 then

    FYI

    With the following code you can test if a variable is empty:

    If variable == EMPTY then

     

    #33660
    Leon D
    Participant

    It works great thanks a lot!

    Just now i noticed that you can`t write a string into a Dataset, is that correct or am i missing something?

     

     

    #33661
    Stefan S.
    Maître des clés

    This is correct. You cannot use FPScript to change another object (e.g. dataset). Use the result of a new FPScript formula instead of the dataset and work with this (e.g. in a diagram). If you really want to change the original object, you have to use VBA script.

     

Voir les messages de 4 - 1 à 4 (sur un total de 4)
  • Vous devez être connecté pour répondre à ce sujet.