Dataflash example not compiling

Using 1.0.5 IDE
compiling for 328 Pro Mini

Error is -
dataflash_intro2:9: error: ‘Dataflash’ does not name a type
My question is why does this Lib example not compile?

There is an old post with mention of Wprogram.h being changed to Arduino.h , but the Dataflash.h , the Dataflash.cpp nor the example given with the Lib have this code.

I have tried the specific D version Dataflash code re;Blocko-s - no joy compiling even, it doesn’t seem to have worked for anyone who has then posted anywhere how they changed the code clearly and in situ, with a complete sketch.

#include <dataflash.h>

int lastpage=0; //last page written to
int pages=25; //total pages that will be used
Dataflash dflash;

void setup()
{
Serial.begin(115200);
Serial.print(‘h’);
Serial.print(‘i’);
Serial.print(’\n’);//debug
dflash.init(); //initialize the memory (pins are defined in dataflash.cpp
}

void loop()
{
int j = 0;
int i = 0;
char messageline = "this is only a test on page: ";
char lpstring = "lastpage: ";
char int_string[10];

itoa(lastpage, int_string, 10); // make string of the pagenumber
strcat(messageline, int_string); //append to the messagline string
//for (int i=0; messageline != ‘\0’; i++)
_ while (messageline != ‘\0’)_
* {*
_ Serial.print(messageline*); //just a check to see if the loop is working*
dflash.Buffer_Write_Byte(1, i, messageline*); //write to buffer 1, 1 byte at the time*
* j = i;
i++;
}
i=0;_

dflash.Buffer_Write_Byte(1, j+1, ‘\0’); //terminate the string in the buffer*

* Serial.print(’\t’);*
* dflash.Buffer_To_Page(1, lastpage); //write the buffer to the memory on page: lastpage*
* strcat(lpstring, int_string);
_ for(int i=0; lpstring != ‘\0’;i++)
{_

dflash.Buffer_Write_Byte(2, 20, lpstring); //write to buffer 2 the lastpage number that was used*

_ Serial.print(lpstring*); //write to serial port the lastpage number written to*
* }
Serial.println();
lastpage++;
if (lastpage > pages) //if we reach the end of the range of pages*

* {
lastpage = 0;
for (int i=0;i<=pages;i++)
{_

dflash.Page_To_Buffer(i, 1);//copy page i to the buffer*

* for(int j=0;j<32;j++) //32 depends on the amount of data on the page*
* // testing for a specific charater is also possible*
* {*
* Serial.print(dflash.Buffer_Read_Byte(1, j)); //print the buffer data to the serial port*
* }*
* Serial.print(" page: ");*
* Serial.println(i); //print the last read page number*
* }*
* }*
* delay(200); //slow it down a bit, just for easier reading*
}

Where did you get the DataFlash library?

Where did you learn to post code? Surely not be reading the threads at the top of the forum that you were supposed to read BEFORE you posted code incorrectly.

Here is the code from the Arduino Playground. And, here is the link where the library can be downloaded: http://arduino.cc/playground/Code/Dataflash

Re:including code in posts. I am so sorry. For some time now I have been unable to copy sketch code and get the button to work as instructed. I have contacted site about this with no response. I'm not keen to just close my account and start afresh with a new one, but may be the only way.

I have changed sketch so obviously no BYTE
I changed #include “Wconstants.h” that needs changing to <Arduino.h> and also “Arduino.h” in Dataflash.h
Apart from that change, as downloaded from link.

But still the same error
‘Dataflash’ does not name a type

I put library first time attempt in \My Documents\Arduino\Libraries\dataflash
Then tried C:\Documents and Settings\mark\My Documents\Arduino\arduino-1.0.5-r2-windows\arduino-1.0.5-r2\libraries\dataflash
Therefore in same place as Arduino core libraries, but not something I’ve ever had to do before and it didn’t make any difference to the error.

The example dataflash_intro is a Processing sketch.
It doesn’t work even with the BYTE code removed.
errors -
processing.app.SketchException: unexpected char: ‘i’
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:379)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:185)
at processing.mode.java.JavaBuild.build(JavaBuild.java:144)
at processing.mode.java.JavaBuild.build(JavaBuild.java:123)
at processing.mode.java.JavaMode.handleRun(JavaMode.java:120)
at processing.mode.java.JavaEditor$18.run(JavaEditor.java:468)
at java.lang.Thread.run(Unknown Source)

So, I was wrong to use this as a sketch.
but without a program already running on the Arduino, I don’t quite understand how anything would happen with this Processing sketch.

dataflash_intro.pde (1.98 KB)

So, I was wrong to use this as a sketch.

The code in the file you attached is Wiring (Arduino) - it has setup/loop, not setup/draw as it would if it were Processing.

Thanks AWOL.
That is what I thought when I first opened it in the IDE, having at first overlooked the pde icon.
Must have been my enthusiasm to see a tried and tested example running.

There is very little from google on using this or any other Arduino library with Dataflash chips, which have a working example.

So, this is an pde sketch that is supposed to open in the IDE and compile and upload to an Arduino?

I think that up until about the 0013 version of the IDE, Wiring (Arduino) sketches had the .pde extension, the same as Processing sketches, before being superseded by the .ino extension. Confusing, innit?

As I wrote, setup/loop says "Arduino", setup/draw says "Processing"

First step is to get rid of the BYTE keywords by changing Seriel.print(value, BYTE); to Serial.write(value);

Second step is to get rid of:

In file included from dataflash_intro.pde:1: /Users/john/Documents/Arduino/libraries/dataflash/dataflash.h:66:24: error: WConstants.h: No such file or directory

Do that by editing dataflash.h to change "WConstants.h" to "Arduino.h".

Then it compiles.

thanks John. I've tried Serial.print() and Serial.write() - 2nd case makes 'h' into binary, whatever, there is a more fundamental issue with compiling that has only appeared with this library. The library you created was named exactly ? and ?where did you put it within the Arduino folder. The error seems to indicate my compiler not finding the library, from your quick success with the example. It is not unusual for the Zip name and the library name to be completely different, or vary by one letter case.

thanks to all contributors, the problem has been found. I had once created a completely unrelated folder on the PC named libraries - for some reason the IDE had found it and 'locked on' - so having deleted that and got the Zip files installed afresh with the example code and updated IDE corrections - everything is fine. Seeing the serial monitor as expected with page increments. Now the real work begins.