www.digitalmars.com         C & C++   DMDScript  

D - File identifier error

reply "Andrew Edwards" <crxace13 comcast.net> writes:
the following error:
   test.d(5): identifier 'File' is not defined
was generated when I trued to compile the following code:

import string;
import file;
int main (char[][] args)
{
    File file = new File;
    file.create('test.dat');
    int a = 0, b = 1;
    for (int i = 0; i < 1000; i++)
    {
        int c = a + b;
        file.write(c);
        a = b; b = c;
    }
    return 0;
}

how would I go about addressing this problem?
Sep 11 2002
next sibling parent Patrick Down <pat codemoon.com> writes:
"Andrew Edwards" <crxace13 comcast.net> wrote in news:aloj8o$1qjj$1
 digitaldaemon.com:

 the following error:
    test.d(5): identifier 'File' is not defined
 was generated when I trued to compile the following code:
 
 import string;
 import file;
 int main (char[][] args)
 {
     File file = new File;
     file.create('test.dat');
     int a = 0, b = 1;
     for (int i = 0; i < 1000; i++)
     {
         int c = a + b;
         file.write(c);
         a = b; b = c;
     }
     return 0;
 }
 

Don't have variable names the same as imports.
Sep 11 2002
prev sibling parent reply Pavel Minayev <evilone omen.ru> writes:
Andrew Edwards wrote:
 the following error:
    test.d(5): identifier 'File' is not defined
 was generated when I trued to compile the following code:
 
 import string;
 import file;

class File is defined in stream.d, not in file.d
Sep 11 2002
parent "Andrew Edwards" <crxace13 comcast.net> writes:
Thanks Pavel, I imported the wrong file. String vs Stream.  BTW the problem
with the unittest in stream.d is that the string "Testing stream.d:"
contains 17 characters, not 18.


"Pavel Minayev" <evilone omen.ru> wrote in message
news:alp2aq$29um$1 digitaldaemon.com...
| Andrew Edwards wrote:
| > the following error:
| >    test.d(5): identifier 'File' is not defined
| > was generated when I trued to compile the following code:
| >
| > import string;
| > import file;
|
| class File is defined in stream.d, not in file.d
|
Sep 12 2002