Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do we need Functions?
#12
If you want to complicate your life further but absolutely hate the type sigils, especially for a string "function" then a "SUB" with "side-effects" could work. Have to declare variables "AS STRING" to keep avoiding that dollar sign...

Code: (Select All)
''Example:

DIM SA AS STRING
SA = ""
PRINT SA
CALLME "Hello!", SA
PRINT SA
END

SUB CALLME (SVAL AS STRING, SINP AS STRING)
  SINP = SVAL
END SUB

''as opposed to:

DIM SA AS STRING
SA = ""
PRINT SA
SA = CALLME$("Hello!")
PRINT SA
END


FUNCTION CALLME$ (SVAL AS STRING)
  CALLME$ = SVAL
END FUNCTION

I like to put "SUB" parameters at the end, those that will have the "side-effects".
Reply


Messages In This Thread
Why do we need Functions? - by PhilOfPerth - 08-19-2022, 01:00 AM
RE: Why do we need Functions? - by OldMoses - 08-19-2022, 01:44 AM
RE: Why do we need Functions? - by bplus - 08-19-2022, 02:05 AM
RE: Why do we need Functions? - by OldMoses - 08-19-2022, 02:12 AM
RE: Why do we need Functions? - by vince - 08-19-2022, 03:40 AM
RE: Why do we need Functions? - by PhilOfPerth - 08-19-2022, 05:40 AM
RE: Why do we need Functions? - by OldMoses - 08-19-2022, 12:58 PM
RE: Why do we need Functions? - by SMcNeill - 08-19-2022, 06:28 AM
RE: Why do we need Functions? - by SMcNeill - 08-19-2022, 06:42 AM
RE: Why do we need Functions? - by PhilOfPerth - 08-19-2022, 08:15 AM
RE: Why do we need Functions? - by bartok - 08-19-2022, 01:36 PM
RE: Why do we need Functions? - by mnrvovrfc - 08-20-2022, 11:59 AM
RE: Why do we need Functions? - by bartok - 08-20-2022, 01:54 PM
RE: Why do we need Functions? - by mnrvovrfc - 08-20-2022, 11:56 AM
RE: Why do we need Functions? - by TempodiBasic - 08-20-2022, 04:52 PM
RE: Why do we need Functions? - by bplus - 08-20-2022, 04:54 PM



Users browsing this thread: 4 Guest(s)