newuser
1
Hello,
My code has something like this:
...
File handle;
handle=SD.open("some.txt");
dostuff(handle);
}
void dostuff(File han)
{
han.close();
}
...
I am having trouble setting the parameters right. I tried having:
...
File handle;
handle=SD.open("some.txt");
dostuff(&handle);
}
void dostuff(File *han)
{
(&han).close();
}
...
etc. but I get compile errors from IDE at compile time. I am used to using plain C function and structures.
system
2
void dostuff(File &hand);
void setup()
{
File myFile = SD.open("some.txt");
dostuff(myFile);
}
Knowing what the function signature needs to be will make writing the function trivial.
system
3
My code has something like this:
Why can't we see what it actually looks like, in code tags?
This does not produce error at compile:
void setup()
{
File myFile = SD.open("some.txt");
dostuff(myFile);
}
void dostuff(File &han)
{
han.close();
}
void loop()
{
}
How would I pass a NULL on dostuff() and test if han is NULL?
system
5
There is no such thing as a null reference.
Juraj
6
File has operator bool so you
newuser:
This does not produce error at compile:
void setup()
{
File myFile = SD.open("some.txt");
dostuff(myFile);
}
void dostuff(File &han)
{
han.close();
}
void loop()
{
}
How would I pass a NULL on dostuff() and test if han is NULL?
the File class has operator bool so you can test "if (myFile)"