Author Topic: Useless Arguments !  (Read 613 times)

Robert

  • Hero Member
  • *****
  • Posts: 1190
    • View Profile
Useless Arguments !
« on: June 28, 2023, 08:10:10 PM »
Code: [Select]
CALL TheSub()

SUB TheSub()
FOR INTEGER a = 1 TO ARGC - 1
  PRINT ARGV$[a]
NEXT
END SUB

ARGC and ARGV$[] file scope would be nice instead of being Exiled On 'main'.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2039
    • View Profile
Re: Useless Arguments !
« Reply #1 on: June 28, 2023, 08:54:23 PM »
In the meantime ....

Code: [Select]

DIM DYNAMIC Copy_ARGV$[1]
REDIM       Copy_ARGV$[ARGC]

GLOBAL Copy_ARGC

Copy_ARGC = ARGC

FOR INTEGER i = 1 TO Copy_ARGC - 1
    Copy_ARGV$ [i] = ARGV$[i]
NEXT



CALL TheSub()
PAUSE



SUB TheSub()
    FOR INTEGER a = 1 TO Copy_ARGC - 1
        PRINT Copy_ARGV$[a]
    NEXT
END SUB

« Last Edit: June 28, 2023, 09:26:57 PM by MrBcx »

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2039
    • View Profile
Re: Useless Arguments !
« Reply #2 on: July 13, 2023, 07:10:52 PM »
Robert -- This would make a useful example in BCXHelp under COMMAND$.


DIM i

WHILE NOTNULL (COMMAND$(i))
    PRINT COMMAND$(i)
    INCR i
WEND

PAUSE




C:\Temp>My_Example  000  111  222  333  444

My_Example
000
111
222
333
444

Press any key to continue . . .



Robert

  • Hero Member
  • *****
  • Posts: 1190
    • View Profile
Re: Useless Arguments !
« Reply #3 on: July 13, 2023, 07:55:24 PM »
Robert -- This would make a useful example in BCXHelp under COMMAND$.


DIM i

WHILE NOTNULL (COMMAND$(i))
    PRINT COMMAND$(i)
    INCR i
WEND

PAUSE




C:\Temp>My_Example  000  111  222  333  444

My_Example
000
111
222
333
444

Press any key to continue . . .


Nice !

A compact and elegant method to expose the argument vectors.

Your example will be Example 4 in the COMMAND$ section.