'This is possibly faster than writing out an equivalent one-line If statement, but the reason its in asm is to
'avoid it being slower, I suspect any speed difference is minimal. This is a pretty convienient function when you're
'setting alot of variables based on simple conditions.
Sub IIf(cond As Int,IfTrue As Int,IfFalse As Int),Int
Dim ret As Int
'ret=ebp-4
'cond=ebp+8 | IfTrue=ebp+12 | IfFalse=ebp+16
_asm
cmp dword [ebp+8],0
je .false
mov dword eax,[ebp+12]
mov dword [ebp-4],eax
jmp .ret
.false:
mov dword eax,[ebp+16]
mov dword [ebp-4],eax
.ret:
_endasm
Return ret
EndSub
Dim i=0,j As Int
For j=1 to 50
Print i,"\t",
i=IIf(i+1<20,i+1,0)
Next j
'Print IIf(0>1,1,0)
'Print IIf(0<1,1,0)
Do:Until Inkey$<>""
I've been going to do this, now I don't have to.
Thanks.
Maybe an IIF statement could be part of the core IWB v2.0 ;)
The IIF function has been available for a minimum of 4+ years in Sapero's 'windowssdk.inc' include file.
I don't wite any of my programs without this line of code:
$include "windowssdk.inc"
LarryMc
I was wondering how this wayneA code will look written in IWB ?
I'll have to download spaero's files. I wonder what other little goodies are in there.
It would be nice if sapero's includes became part of the standard install of IWB; perhaps for v2.0.
Is there any reason that the SDK zip file is not hosted on Ionic Wind?
I am blocked form accessing "file sharing" sites at work and can not get to rapidshare or sendspace.com.
Go to sapero (http://www.ionicwind.com/forums/index.php/topic,4100.0/topicseen.html) and click on his signature line.
OOPS -- Sorry
Send me a PM with your postal address, and I will send you a CD. The Zip file is 11.4 Meg.
Quote from: REDEBOLT on June 17, 2010, 09:45:27 PM
Go to sapero (http://www.ionicwind.com/forums/index.php/topic,4100.0/topicseen.html) and click on his signature line.
which takes you to the where Sapero has links to where the files are stored which is where Guilect says he is not allowed to link to at his work. ;)
So, regardless of where you find the links, if your work blocks you from connecting to the links, it isn't much help.
LarryMc
First off let me apologize to WayneA for having the subject matter drift away from the his posted topic of an IIF command.
Second, thanks for the offer REDBOLT but, I will download the file eventually.