Requesting ELSEIF - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Requesting ELSEIF (/thread-8026.html) |
Requesting ELSEIF - toml_12953 - 03-24-2017 05:30 PM If you're taking suggestions for additions to HPPL, I'd like to propose the addition of ELSEIF (or ELIF). With lengthy IF-THEN structures, it can tighten up the code considerably. Tom L Current way (greatly trivialized example): Code: IF x>7 THEN Now improved with ELSEIF Code: IF x>7 THEN RE: Requesting ELSEIF - Han - 03-24-2017 05:38 PM (03-24-2017 05:30 PM)toml_12953 Wrote: CASE blocks have similar logic to nested ELSE-IF blocks (exiting the block once a condition is met and relevant actions are executed). It doesn't make your code any shorter but can provide improved legibility. Code: CASE RE: Requesting ELSEIF - compsystems - 03-24-2017 06:21 PM I like the version ELSEIF. instead of using CASE now with IFTE functional command version PHP Code: EXPORT elif(x) A small survey. you need an IFT() functional command? (without ELSE block) PHP Code: EXPORT ift(x) RE: Requesting ELSEIF - toml_12953 - 03-24-2017 06:52 PM (03-24-2017 06:21 PM)compsystems Wrote: I like the version ELSEIF. instead of using CASE I'm all for anything that makes my job easier. I actually make a living converting old programs (mostly BASIC) to run on Prime. I'd share them with the group but my employer owns everything I write relating to their business (even after hours!) I'd like both ELSEIF and IFTE. I'd also like user-defined datatypes (like records), printing and a whole bunch more. We can dream, can't we? Tom L RE: Requesting ELSEIF - compsystems - 03-24-2017 07:16 PM What kind toml_12953 of programs are you converting and where can you test them? RE: Requesting ELSEIF - toml_12953 - 03-24-2017 07:33 PM (03-24-2017 07:16 PM)compsystems Wrote: What kind toml_12953 of programs are you converting and where can you test them? I convert environmental programs. These were used for by our field workers for years on laptops and even some BASIC handhelds. We're equipping them with Primes now and I convert programs that monitor and analyze climate data (yes it really IS changing!) and do things like calculate how fast the liquid level in different shaped tanks such as underground tanks used by abandoned gas stations will go up or down based on the input or leakage (a lot of differential equations there). We also keep track of changing migratory patterns of birds and other animals. It's a lot of fun at times but sometimes converting the spaghetti code makes me want to hit the sauce! Gee, C, Pascal and other languages have GOTO. Why can't Prime? Tom L RE: Requesting ELSEIF - Carlos295pz - 03-24-2017 07:45 PM (03-24-2017 06:21 PM)compsystems Wrote: you need an IFT() functional command? (without ELSE block) IFTE can be defined without ELSE RE: Requesting ELSEIF - compsystems - 03-24-2017 08:16 PM (03-24-2017 07:45 PM)Carlos295pz Wrote:(03-24-2017 06:21 PM)compsystems Wrote: you need an IFT() functional command? (without ELSE block) but only HOME PRG, for CAS fails PHP Code: EXPORT iftHOME(x) iftHOME(8); returns "Done" iftCAS(8); returns "when(x>7,print(""true"")) in iftCAS(5) instruction #1 error, try debug(iftCAS(5)) Error: Bad Argument Type" RE: Requesting ELSEIF - toml_12953 - 03-25-2017 11:43 AM (03-24-2017 05:38 PM)Han Wrote: CASE blocks have similar logic to nested ELSE-IF blocks (exiting the block once a condition is met and relevant actions are executed). It doesn't make your code any shorter but can provide improved legibility. Just to show you, here's the actual ANSI/ISO BASIC statement statement I'm converting: PHP Code: IF (t = 1) OR (t = 2) OR (t = 3) THEN |