help! i have two files, one module, the other main, module..
Author |
Message |
r0ssar00
|
Posted: Fri Oct 15, 2004 9:12 am Post subject: help! i have two files, one module, the other main, module.. |
|
|
i need to have the variable's value exported from the main program so it can be accessed from the module, is there any way to do this? var name is |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Delos
|
Posted: Fri Oct 15, 2004 11:36 am Post subject: (No subject) |
|
|
Hmm....
code: |
module main
export nothing, thisIsMyVariable
var globalTest1 : int := 4
procedure nothing
put "Well, I'm a disaster!"
end nothing
function thisIsMyVariable
result globalTest1
end thisIsMyVariable
end main
|
You figure out the rest...and serisouly dude, please be a lot clearer when posting your questions. And a bit more code than "test1" would help to understand.
As it stands I'm not even sure of what you asked, but I hope that I answered it... |
|
|
|
|
|
beard0
|
Posted: Sat Oct 16, 2004 4:14 pm Post subject: (No subject) |
|
|
You can actually even put the variable in the export list, and if you like, by prefacing it with the keyword var, you can even change it's value outside of the module.
code: | module test
export test1, var test2
var test1, test2 := 3
end test
put test.test1
test.test2 := 5
put test.test2 |
Will return:
|
|
|
|
|
|
wtd
|
Posted: Sat Oct 16, 2004 6:20 pm Post subject: (No subject) |
|
|
In reality, of course, exposing the variables in a module is an exceptionally bad idea. Heck, just having global variables in a module is phenomenally bad design. |
|
|
|
|
|
beard0
|
Posted: Sun Oct 17, 2004 9:13 am Post subject: (No subject) |
|
|
very true wtd. However, I would argue that for someone starting out, that whatever works is what you go with. It's only through experimentation with the limits of what the constructs will allow you to do, that you can then determine what are the better methods to use. Sure someone can tell you "it's better to do it this way," but you'll learn so much more by experimenting. And that's what compsci is about - learning! |
|
|
|
|
|
wtd
|
Posted: Sun Oct 17, 2004 3:47 pm Post subject: (No subject) |
|
|
Ah yes, the joy of learning the best way of doing things by screwing up repeatedly.
Been there. I'm entirely self-educated in the field of programming. I've been screwing up gloriously for 6 years! |
|
|
|
|
|
r0ssar00
|
Posted: Mon Oct 18, 2004 7:09 am Post subject: (No subject) |
|
|
ive also been mainly self-educated over 1 year and am building a dos-like prompt, i am trying to figure out how to make multiuser a reality in it |
|
|
|
|
|
r0ssar00
|
Posted: Mon Oct 18, 2004 7:09 am Post subject: (No subject) |
|
|
the reason being, they don't give us either dos prompt at school or a file manager |
|
|
|
|
|
Sponsor Sponsor
|
|
|
beard0
|
Posted: Mon Oct 18, 2004 5:53 pm Post subject: (No subject) |
|
|
code: | var r:int
var prompt:string
loop
put ">"..
get prompt:*
system(prompt,r)
end loop |
This is the basics: the system command should come in quite handy! |
|
|
|
|
|
r0ssar00
|
Posted: Tue Oct 19, 2004 9:59 am Post subject: (No subject) |
|
|
yes, i have used it twice already, once to exec an external compiler and a second to execute commands in a way like linux |
|
|
|
|
|
|
|