Claytons' Conundrum With Reading & Writing Complete Type Records To File
Author |
Message |
ClayWall
|
Posted: Tue Jan 04, 2011 1:51 pm Post subject: Claytons' Conundrum With Reading & Writing Complete Type Records To File |
|
|
What is it you are trying to achieve?
I have created a type inside of a module, which I'm trying to write to file with another module, by calling a procedure outside of itself. Then I try to read that
file. I am only reading and writing the variable of said type, not each of the variables inside the record .
What is the problem you are having?
When I run the program it writes to file, I then try to read the file and get and warning saying "'whateverVar' is read-only in this scope and cannot be modified by 'read'"
Describe what you have tried to solve this problem
I run the program anyways, and output the data which shows that it has in fact read the data just fine and placed it in the proper variables with no errors, but the problem is
the warning message will interfere every time I run the program, so I'm not sure if maybe I'm missing something or have things in an improper order.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
% Example
module Data
type Info
record
example : string
end record
var newInfo : Info
newInfo.example := "Original"
end Data
module File
proc Save
write : stream, Data.newInfo
end Save
proc Load
read : stream, Data.newInfo % will cause warning, but still reads file and loads values into "newInfo" variables
end Load
end File
put Data.newInfo.example % outputs "Original"
File.Save
Data.newInfo.example := "Something else" % I know this is wrong, but I'm trying to keep it short
put Data.newInfo.example % outputs "Something else"
File.Load % causes warning, but will continue to run
put Data.newInfo.example % outputs "Original", even though it claims 'read' can't modify Data.newInfo
|
Please specify what version of Turing you are using
4.1.1
Final note
If this seems to hard to understand I will post proper code, but I tried to remain short and sweet. Thanks in advance. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TokenHerbz
|
Posted: Tue Jan 04, 2011 3:04 pm Post subject: RE:Claytons\' Conundrum With Reading & Writing Complete Type Records To File |
|
|
Have you looked into export/import. these are useful things to know when working with modules or classes. |
|
|
|
|
|
DemonWasp
|
Posted: Tue Jan 04, 2011 3:39 pm Post subject: RE:Claytons\' Conundrum With Reading & Writing Complete Type Records To File |
|
|
Answer: Turing is probably poorly-implemented.
You can probably skip the warning with export var newInfo. |
|
|
|
|
|
ClayWall
|
Posted: Tue Jan 04, 2011 7:04 pm Post subject: RE:Claytons\' Conundrum With Reading & Writing Complete Type Records To File |
|
|
TokenHerbz: That was just a pseudo-code example, sorry I should have made better mention of that.
DemonWasp: Aha, something so simple, as always. That did the trick, I never thought to add "var". Thanks for the help. |
|
|
|
|
|
|
|