Multiple source small project compilation:
For smaller projects it's enough to compile each source individualy with 'dc source'. Each
source, that doesn't contain the main() procedure should have enables the OPT NOEXE, because
else will appear an error, that there is no main() procedure. In our case, it's enough to
add just a module of the given source:
Main Source called main.d:
MODULE '*read','*save'
PROC main()
read()
save('ram:file.txt')
ENDPROC
first source called read.d:
OPT NOEXE
DEF str[32]:STRING
PROC read()
WriteF('Enter a string: ')
ReadEStr(stdout,str)
ENDPROC
and second source called save.d:
OPT NOEXE
MODULE '*read'
PROC save(name)
DEF f
IF f:=Open(name,NEWFILE)
Write(f,str,StrLen(str))
Close(f)
ENDIF
ENDPROC
Now our sources are finished. Main source, resp. main() function use both the save() function
from the save.d file and the read() function from the read.d source, so we have to define both
modules. First source read.d contains the definition of the variable str. The read() function
writes a string ans waits for You to enter some text. Second source save.d opens a file with
given name ('ram:file.txt') and saves there the contents of the str variable, which isn't here
defined. That's why we have there the module '*read', because there is defined the variable
reference.
Now we have to compile our sources. First we have to compile the read.d source, because it is
used in both next sources. Enter:
1.> dc read gm
Now (if everything is ok) You can see, that there is a new file called read.m and it contains:
OPT LINK='*read.o'
EPROC read()
EDEF str:PTR TO CHAR
Now enter:
1.> dc save gm
Now (if everything is ok) You can see, that there is a new file called save.m and it contains:
OPT LINK='*save.o'
EPROC save(name)
Now enter:
1.> dc main
And if everything is ok, enter main, and when it asks, enter some string:
1.> main
Enter a string: hello world
Now, there is a file in ramdisk called file.txt, that contains the string You entered.