This can be especially useful for compression programs: I can have the programs gzip, and gunzip, that are actually the same binary file (so, the compression algorithm is stored on the hard drive only once), and depending on the name used, they compress or uncompress.
Actually, all the examples I mentioned (cmp, diff, gzip, gunzip... but also cat, ls, wget and so on) can be implemented by a single file, named BusyBox, that on some embedded or light distributions of Linux provides all the system utilities.
Since programs compiled with FreeBasic can contain some runtime code that bloat them (not much, but still more than an equivalent program written in C, and on embedded or minimalist systems this can still be an issue), if the program is supposed to be very small sometimes it might be useful to combine several programs into a single multi-call binary. In FreeBasic it can be done using the Command(0) function:
Code: Select all
dim c as string=command(0)
dim c1 as string
do 'strip the path info
c1=c
c=mid(c,instr(c,"/")+1)
loop until c1=c
select case c
case "test"
print "this is the test program"
case "game"
print "this is the game program"
end select
Code: Select all
ln multicall test
ln multicall game