May 15, 2024, 08:08:31 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


IIf

Started by WayneA, June 14, 2010, 02:11:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

WayneA

'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$<>""
99 little bugs in the code,
99 bugs in the code,
Fix one bug,
Compile again,
104 little bugs in the code...

All code I post is in the public domain.

Guilect

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  ;)

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

I was wondering how this wayneA code will look written in IWB ?

Guilect

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.

REDEBOLT

June 17, 2010, 09:45:27 PM #5 Last Edit: June 17, 2010, 10:30:10 PM by REDEBOLT
Go to sapero 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.
Regards,
Bob

LarryMc

June 17, 2010, 09:56:40 PM #6 Last Edit: June 17, 2010, 09:59:01 PM by Larry McCaughn
Quote from: REDEBOLT on June 17, 2010, 09:45:27 PM
Go to sapero 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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Guilect

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.