QB64 Phoenix Edition
_IIF limits two questions - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: _IIF limits two questions (/showthread.php?tid=3309)



_IIF limits two questions - doppler - 12-20-2024

1.
Is the new _IIF limited to only numerics ?  Or can I play with strings too ?

2. Can this statement be on one line:     p=_iff(p=instr(thing$,"\"): p <= 10, p, p=0)
  re: position of "\" must be less than 11 else make it zero

Question two in my mind very iffy.  If question #1 is true.
Don't need an code answer for question 2.  I could do that in my sleep.
Just thought sub-coding might be possible in a coded line.


RE: _IIF limits two questions - Petr - 12-20-2024

Hi,

In the last two parameters of the function you set its output values. The first for true, the second for false.

Code: (Select All)

a$ = "YES"

result = _IIf(a$ = "YES", 100, 0)

Select Case result
    Case 0: Print "a$ is not YES"
    Case 100: Print "a$ is YES"
End Select



RE: _IIF limits two questions - bplus - 12-20-2024

(7 hours ago)doppler Wrote: 2. Can this statement be on one line:     p=_iff(p=instr(thing$,"\"): p <= 10, p, p=0)
  re: position of "\" must be less than 11 else make it zero

How about:
p=_iff(instr(thing$,"\") <= 10, instr(thing$,"\"), 0)


RE: _IIF limits two questions - Pete - 12-20-2024

If iff works with strings why didn't they just name it _stiff?

Pete

- We missed _hitkey by that much!


RE: _IIF limits two questions - Pete - 12-21-2024

Petr's example as a string I think would be...

Code: (Select All)
Dim result as String
a$ = "Yes"
result = _IIf(a$ = "YES", "a$ is YES", "a$ is not YES" )
Print result

I say think because I haven't downloaded and installed the new version yet.

Someone please correct Steve if I am wrong. Big Grin

Pete


RE: _IIF limits two questions - doppler - 12-21-2024

(5 hours ago)bplus Wrote:
(7 hours ago)doppler Wrote: 2. Can this statement be on one line:     p=_iff(p=instr(thing$,"\"): p <= 10, p, p=0)
  re: position of "\" must be less than 11 else make it zero

How about:
p=_iff(instr(thing$,"\") <= 10, instr(thing$,"\"), 0)
Yes that is the basis of the line.  My real question, can I mini sub-code the first parameter of the IFF (test comparison).  I thought I could be fancy on the first statement.  Since the IFF statements are separated by comma's.  Only the last minicoding result is the real test.  ie: (p<=10).  I only happened to use instr as a question example.  The minicoding could be almost anything  and referencing other variables to manipulate.  Hell for all intended purposes the first statement could be a sub-function call out. ie:

dim share x, p

p=_iff(test,p,p=0)

sub test
x=instr(thing$,"\")
if x<=10 the p=x
end sub

The whole idea of a sub maybe washed up