Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need help converting old style def fn functions
#8
(07-09-2022, 11:55 PM)TempodiBasic Wrote: Hi
very strange code

DEF FNB(Q)=Q+8*((Q=9)-(Q=0))
this function returns Q for all value of Q except for 9 that returns 1  and  for 0 that returns 8
Is it better using an IF THEN ELSEIF THEN ELSE  that seems less cryptic!

and this other
DEF FNC(Q)=-Q*(Q<19)-18*(Q>18)
it returns Q + 18 if Q>18  or -Q if Q<19

moreover
DEF FND(Q)=64*(Q-1)+8*(X-1)+Y
translated in Function must get X and Y to do a correct calculation
Dim Shared  versus Function parameters

and at last
DEF FNE(Q)=Q+100*(Q>99) 
this FN returns Q if Q <=99  and it returns Q-100 for Q value > 99

However creativity is the first tool of a programmer|

Indeed. 
I think this may have been created waaay back in the day, maybe in GW-BASIC or BASIC A?
Reply


Messages In This Thread
RE: need help converting old style def fn functions - by madscijr - 07-14-2022, 07:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting a MIDI file to text (csv, tab-delimited, etc.) and back again? madscijr 7 2,304 03-11-2025, 11:00 PM
Last Post: madscijr
  Date functions dritter 31 5,004 05-20-2024, 04:22 PM
Last Post: dano
  Declaring Functions AS TYPEs TerryRitchie 14 2,868 08-17-2023, 12:41 AM
Last Post: bplus
  Questions on style justsomeguy 23 4,445 06-28-2023, 08:31 PM
Last Post: CharlieJV

Forum Jump:


Users browsing this thread: 1 Guest(s)