Does QB64pe already have a function like IFF ? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: QBJS, BAM, and Other BASICs (https://staging.qb64phoenix.com/forumdisplay.php?fid=50) +--- Thread: Does QB64pe already have a function like IFF ? (/showthread.php?tid=1723) Pages:
1
2
|
RE: Does QB64pe already have a function like IFF ? - CharlieJV - 06-05-2023 (06-05-2023, 04:26 PM)bplus Wrote: Hi Charlie what does BAM do here? The first expression in IFF can be anything that results in either TRUE (i.e. anything other than zero) or FALSE (i.e. zero). The second expression IFF will be the return value when the first expression yields "TRUE" (i.e. non-zero). The second expression can be anything at all that results in either a number or a string. The third expression in IFF will be the return value when "FALSE" (i.e. zero). The third expression can be anything at all that results in either a number or a string. RE: Does QB64pe already have a function like IFF ? - CharlieJV - 06-05-2023 (06-05-2023, 04:26 PM)bplus Wrote: I ask because IFF typically takes a numeric expression that evaluates to "True" or "False" numerically -1 or 1 and 0 for false. That's incorrect. The first parameter in IFF is an expression that results in an integer number (or any number, really; the number will get treated as an integer). The expression in the first parameter of IFF could be as simple as a literal number, or a numeric constant, or a numeric variable. Or it could be a function that returns a number. Or it could be any kind of complex expression that results in a number. RE: Does QB64pe already have a function like IFF ? - CharlieJV - 06-05-2023 (06-05-2023, 04:47 PM)CharlieJV Wrote:(06-05-2023, 04:26 PM)bplus Wrote: I ask because IFF typically takes a numeric expression that evaluates to "True" or "False" numerically -1 or 1 and 0 for false. Huh, and now I'm also incorrect. Just tried, and: If the first expression is a null string, then FALSE expression happens.. If the first expression is a non-null string, then TRUE expression happens. This has me thinking: potential use cases? Ooooooo: Code: (Select All) IFF( name$, name$, "Guest") RE: Does QB64pe already have a function like IFF ? - bplus - 06-05-2023 (06-05-2023, 04:47 PM)CharlieJV Wrote:So why are you saying IFF(string, ... ?(06-05-2023, 04:26 PM)bplus Wrote: I ask because IFF typically takes a numeric expression that evaluates to "True" or "False" numerically -1 or 1 and 0 for false. It should be IFF(integer, ... I quote you: "This IFF in BAM will only work with primitive types (string, integer, floating point)." RE: Does QB64pe already have a function like IFF ? - bplus - 06-05-2023 (06-05-2023, 04:53 PM)CharlieJV Wrote:(06-05-2023, 04:47 PM)CharlieJV Wrote:(06-05-2023, 04:26 PM)bplus Wrote: I ask because IFF typically takes a numeric expression that evaluates to "True" or "False" numerically -1 or 1 and 0 for false. Hi Charlie, could you show me a quick copy of BAM code for IFF? or are you using some Javascript jazz? RE: Does QB64pe already have a function like IFF ? - CharlieJV - 06-05-2023 (06-05-2023, 04:55 PM)bplus Wrote:(06-05-2023, 04:47 PM)CharlieJV Wrote:So why are you saying IFF(string, ... ?(06-05-2023, 04:26 PM)bplus Wrote: I ask because IFF typically takes a numeric expression that evaluates to "True" or "False" numerically -1 or 1 and 0 for false. Where and when did I ever say " IFF(string, ..." ? RE: Does QB64pe already have a function like IFF ? - CharlieJV - 06-05-2023 (06-05-2023, 05:01 PM)bplus Wrote:(06-05-2023, 04:53 PM)CharlieJV Wrote:(06-05-2023, 04:47 PM)CharlieJV Wrote: That's incorrect. BAM does not do javascript, and I can't ever see me allowing BAM to do javascript. New BASIC statements/functions that might not exist in other BASIC implementations, and often non-strict typing, but no javascript crap. RE: Does QB64pe already have a function like IFF ? - bplus - 06-05-2023 OK I read more into that line "I quote you" than was there, sorry. RE: Does QB64pe already have a function like IFF ? - bplus - 06-05-2023 (06-05-2023, 05:06 PM)CharlieJV Wrote:OK not javascript crap ;-))(06-05-2023, 05:01 PM)bplus Wrote:(06-05-2023, 04:53 PM)CharlieJV Wrote: Huh, and now I'm also incorrect. I was just wondering how you have IFF( ) coded for BAM, interesting that it allows both string and I assume numeric expressions for first parameter. Nevermind, I guess you went over all this at beginning of thread. I was surprised BAM not sticking strictly to types. RE: Does QB64pe already have a function like IFF ? - CharlieJV - 06-05-2023 (06-05-2023, 05:15 PM)bplus Wrote:(06-05-2023, 05:06 PM)CharlieJV Wrote:OK not javascript crap ;-))(06-05-2023, 05:01 PM)bplus Wrote: Hi Charlie, could you show me a quick copy of BAM code for IFF? or are you using some Javascript jazz? Well, making changes/additions to the interpreter (wwwBASIC.js), that is all javascript crap all the time. Drives me insane, but gotta deal with the pain to get this browser-based BASIC juuuuuust right. The javascript code to implement IIF: Code: (Select All) if (name=='iff') { |