
-----------------------------------
r0ssar00
Fri Oct 15, 2004 9:12 am

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 test1

-----------------------------------
Delos
Fri Oct 15, 2004 11:36 am


-----------------------------------
Hmm....


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
Sat Oct 16, 2004 4:14 pm


-----------------------------------
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.
module test
    export test1, var test2
    var test1, test2 := 3
end test
put test.test1
test.test2 := 5
put test.test2
Will return:
3
5

-----------------------------------
wtd
Sat Oct 16, 2004 6:20 pm


-----------------------------------
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
Sun Oct 17, 2004 9:13 am


-----------------------------------
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!  :D

-----------------------------------
wtd
Sun Oct 17, 2004 3:47 pm


-----------------------------------
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
Mon Oct 18, 2004 7:09 am


-----------------------------------
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
Mon Oct 18, 2004 7:09 am


-----------------------------------
the reason being, they don't give us either dos prompt at school or a file manager

-----------------------------------
beard0
Mon Oct 18, 2004 5:53 pm


-----------------------------------
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
Tue Oct 19, 2004 9:59 am


-----------------------------------
yes, i have used it twice already, once to exec an external compiler and a second to execute commands in a way like linux
