Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 9th, 2006, 11:07 PM   #1
RandomRetard
Newbie
 
RandomRetard's Avatar
 
Join Date: Oct 2005
Location: Behind you
Posts: 8
Rep Power: 0 RandomRetard is on a distinguished road
Send a message via MSN to RandomRetard
EInOutError

I was taught Pascal in my 6th form and at the time, I hated it! It seemed so rubbish! Until I tried to learn a few different languages including python and java (both of which I'm continuing with, incidentally) and found them much harder than Pascal. And then thinking back, I realised that through all the teasing and joking, deep down, I loved Pascal. This has encouraged me to start with Delphi as I'm patially familiar with it anyway.

Well now you all know my life story, time for my problem...

I've been working through the delphi tutorials here to refresh my memory of the syntax and get to grips with the features of delphi that weren't in pascal. I got to this tutorial and this is where my problem arose. I followed the guide fully (I think!) but then I came to this section of the guide....

Quote:
Before you can run that, you need to provide a WriteLineToFile procedure.

Just after the var c1:byte; near the start of procedure TDD02f1.FormCreate... add:

procedure WriteLineToFile(sTmp:string);
var c1,c2:byte;(*Don't try to do away with any of the three uses
........of c2... the complier won't like it!*)
begin
for c1:=1 to length(sTmp) do
begin
c2:=ord(sTmp[c1]);(*sTmp[2] returns the second character of the string sTmp*)
write(df,c2);
end;
c2:=13;write(df,c2);(*This plus next will allow editing datafile*)
c2:=10;write(df,c2);(*with Notepad, which is sometimes useful*)
end;

(*Notepad files do not always have the 13/10 pair after the last line, by the way.*)

If you load HighS.txt into Notepad, you should see a bunch of lines consisting of a number and a hyphen followed by 'NoNameABCDEFGHIJKLMNOPQR'.
When running the code, I get the error 'Project DD02.exe raised exception class EInOutError with message 'File access dened'.
The error happens (I think) on the like which says 'write(df,c2);' although there is no line reference so I'm not 100% on this.

Is it anything to do with the fact that the guide was written for delphi 1 and 2 but I'm using 2005? Or have I missed out something obvious and stupid?:o
RandomRetard is offline   Reply With Quote
Old Jan 10th, 2006, 2:35 AM   #2
Klipt
Hobbyist Programmer
 
Join Date: Dec 2005
Posts: 118
Rep Power: 0 Klipt is an unknown quantity at this point
Where is df defined?

I personally think Pascal is a very elegant language (if not as flexible as Python...) but it looks even more elegant if you indent your code :p
Klipt is offline   Reply With Quote
Old Jan 10th, 2006, 12:01 PM   #3
RandomRetard
Newbie
 
RandomRetard's Avatar
 
Join Date: Oct 2005
Location: Behind you
Posts: 8
Rep Power: 0 RandomRetard is on a distinguished road
Send a message via MSN to RandomRetard
Quote:
Originally Posted by Klipt
Where is df defined?

I personally think Pascal is a very elegant language (if not as flexible as Python...) but it looks even more elegant if you indent your code :p
LOL mine is indented! That was taken from the tutorial so blame them:p

df is defined as 'df : file of byte;' and it's defined globally, just before 'implimentation' as instructed

*runs to check the instructions!*

yup, it says...
Quote:
Just after 'var' and 'DD02f1: TDD02f1;', add...
df:file of byte; (*df for 'Data File'*)
One thing I did notice, however, is later it says the following...
Quote:
After df:bytefile; add
sSN:array [0..9] of string[28];(*Score plus Name*)
df:bytefile?? I wasn't told to write that anywhere. As it's been a while since I used Pascal's file handling, I don't remember much about it. And as my code is not available at the moment, I can't even compare it to what I'm doing now so I'm really stuck!


One last thing whilst I'm here... this part had me a little confused...
Quote:
Make the second line {$R+}. NB::: DON'T turn the line {$R *.DFM} into {$R+ *.DFM}!! {$R followed by a file spec has a completely different function, and putting the + in is disasterous!
For me, line 2 is in between 'unit DD02u1;' and 'interface' but it warns against changing {$R *.DFM} which is on line 30 in my program. It makes me wonder where I should actually put it as it seems crazy that somebody could misread line 2 as line 30.

Maybe you could help me shed some light on these little errors. Especially as I wrote a very simple ascii game in pascal whilst I should have been working on my project in 6th form and I'm dying to make it 32bit and actually finish it with graphics and all that
RandomRetard is offline   Reply With Quote
Old Jan 10th, 2006, 2:12 PM   #4
Klipt
Hobbyist Programmer
 
Join Date: Dec 2005
Posts: 118
Rep Power: 0 Klipt is an unknown quantity at this point
Er ... if you PM me the entire source file I can try pinpoint the error, otherwise I'm afraid I have very little idea what's going on here.
Klipt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:45 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC