[Gambas-user] no IF ... THEN ... ELSE ... in one line?

Charlie Reinl Karl.Reinl at ...2345...
Wed Oct 10 13:04:08 CEST 2012


Am Mittwoch, den 10.10.2012, 12:59 +0200 schrieb Rolf-Werner Eilert:
> Hm! Ok, I tried both, and in THIS case here, I cannot feel any 
> difference in speed. So I stay with IIF.
> 
> Rolf
> 
> 
> Am 10.10.2012 12:47, schrieb Fabien Bodard:
> > Yes
> > Le 10 oct. 2012 12:13, "Rolf-Werner Eilert"<eilert-sprachen at ...221...>  a
> > écrit :
> >
> >> As you might guess, I managed to re-write the things with IIF like
> >>
> >> mesVon.Add(IIF(teil.Count>  1, teil[1], ""))
> >>
> >> which is even shorter than the one-liner I wanted to use first.
> >>
> >> My only worry is speed - is IIF much slower than a pure IF ELSE
> >> construction?
> >>
> >> Rolf
> >>
> >>
> >> Am 10.10.2012 10:46, schrieb Rolf-Werner Eilert:
> >>> Hi,
> >>>
> >>> just stumbled over this one:
> >>>
> >>>          IF teil.Count>   1 THEN mesVon.Add(teil[1]) ELSE mesVon.Add("")
> >>>          IF teil.Count>   2 THEN mesStatus.Add(teil[2]) ELSE
> >> mesStatus.Add("")
> >>>          IF teil.count>   3 THEN mesPri.Add(teil[3]) ELSE mesPri.Add("")
> >>>          IF teil.Count>   4 THEN mesRef.Add(teil[4]) ELSE mesRef.Add("")
> >>>          IF teil.Count>   5 THEN mesText.Add(teil[5]) ELSE
> >>> mesText.Add("Fehler: Defekte Message-Datei")
> >>>
> >>> Doesn't seem to be possible in Gambas, so I would have to write
> >>>
> >>>          IF teil.Count>   1 THEN
> >>>            mesVon.Add(teil[1])
> >>>          ELSE
> >>>            mesVon.Add("")
> >>>          END IF
> >>>
> >>> for all of the above cases - a bit roundabout and not so well readable,
> >>> isn't it?
> >>>
> >>> Regards
> >>>
> >>> Rolf
> >>>

Salut Rolf,

personally I prefer 
if ..then
... do this
else
... do that
end if 
for debugging reasons


-- 
Amicalement
Charlie





More information about the User mailing list