No print() function on serLCD

I just wanted to point out that there is no print() function in the actual library on the serLCD in Playground, and was wondering if the author could be contacted to find out if this was just an oversight or if there was something malicious happening to his code.

It's in the documentation, but there's no mention of it in the library. Might it just need to be added?

Apologies if this isn't the right spot to get the author's attention, but I just wasn't sure how, since there doesn't seem to be any actual contact information beyond the attribution.

Link please?

Can you post code which demonstrates that print does not work?

serLCD is derived from SoftwareSerial:

class serLCD : public SoftwareSerial {

SoftwareSerial is derived from Stream:

class SoftwareSerial : public Stream

Stream is derived from Print:

class Stream : public Print

The Print class implements the print function.

Link: serLCD

Nonworking Code:

#include <serLCD.h>

// Set pin to the LCD's rxPin
int pin = 14;

serLCD lcd(pin);

void setup()
{
  lcd.print("Laser Outfitters");
  lcd.print("      Labs      ");
}

void loop(){
}

Error: 'class serLCD' has no member named 'print'

The phrase "should work" is not the same as "works".

Theory is not practice. Strange things happen. It's missing functionality... thus, a reference of some kind is needed.

If I knew how, I would fix it myself... it can't be that big of a deal to fix.

You are selectively quoting the error message. I tried your sketch and got:

In file included from sketch_jan13a.ino:1:
/home/nick/sketchbook/libraries/serLCD/serLCD.h:31:28: error: SoftwareSerial.h: No such file or directory
In file included from sketch_jan13a.ino:1:
/home/nick/sketchbook/libraries/serLCD/serLCD.h:67: error: expected class-name before ‘{’ token
sketch_jan13a.ino: In function ‘void setup()’:
sketch_jan13a:10: error: ‘class serLCD’ has no member named ‘print’
sketch_jan13a:11: error: ‘class serLCD’ has no member named ‘print’

Relevant line: SoftwareSerial.h: No such file or directory

You need to include all libraries.

This modified sketch compiles without errors.

#include <serLCD.h>
#include <SoftwareSerial.h>

// Set pin to the LCD's rxPin
int pin = 14;

serLCD lcd(pin);

void setup()
{
  lcd.print("Laser Outfitters");
  lcd.print("      Labs      ");
}

void loop(){
}

This is not a documentation or library problem. I'm moving this to Programming Questions.

The phrase "should work" is not the same as "works".

I never said it "should work". It does work, if you include all libraries.

As a general rule in programming, fix the first error message first. The others may follow from the first. Your question should have been:

How come I got this error: SoftwareSerial.h: No such file or directory

So... now I'm confused: it does specify that it needs that library, but the print() function doesn't actually relate to the declaration?

Also: the serLCD dependency is somehow related, but doesn't actually include that library already? (I thought it did, thus the reason I avoided including it.)

Those compiler errors didn't make sense. I'll try looking at the first ones next time instead of the ones that are just in the screen... as I don't usually get errors this early in the game, I thought it was the library's issue... sorry for being such a newb, those assumptions weren't actually reasonable, it was just my being lazy, which I didn't actually realize until reading through the reply.

Thank you for the help!

So... now I'm confused: it does specify that it needs that library, but the print() function doesn't actually relate to the declaration?

Now, I'm confused. What is "it" that needs what library? What print() function doesn't relate to what declaration?

The errors do make sense if you just think on them from another perspective...

First error is telling you a file called SoftwareSerial.h is missing: since you never mentioned it in your sketch that is a suggestion to add it. I'll not dig into how the .ino and pre processor work, just let's assume if you don't mention a file then it's not available, shall we? Where is located the include directive causing the issue? well, at line 31 of serLCD.h, as stated in the error... So serLCD.h does include SoftwareSerial.h, but the compiler doesn't know how to find it.

Second error is a syntax one and is telling you a class name is missing before an opening curly bracket... if you open your serLCD.h file and scroll down to line 67 you'll probably find there are two class names on that line: one of the two is SoftwareSerial, which should have been included by the include directive causing the first error... So the first error did generate the second one as a consequence.

Third error and subsequent are, guess what? The consequences of the second error: serLCD could not extend SoftwareSerial, which was inderectly providing the print function you were trying to use.

Does it make sense now?

RedHeron:
So... now I'm confused: it does specify that it needs that library, but the print() function doesn't actually relate to the declaration?

You need to read up on how C++ classes inherit functions from other classes. The print function was an inherited function. Just as an example, if Fido is a Labrador, and a Labrador is a dog, we assume Fido has legs, because all dogs have legs. In other words, the "has legs" is part of the "dog" definition, not the "Labrador" definition.

It's a quirk of the IDE that your main sketch has to mention (include) all libraries needed by it, even if those libraries are needed by other libraries*. In your case serLCD.h was a library which you (correctly) included. But since serLCD.h internally uses SoftwareSerial, that has to be included in the main sketch.

I have a bit of a discussion here.

  • Other IDEs tend to have "Project Files" which handle this stuff, which adds to the complexity of using them, but is a bit more specific. The Arduino IDE tries to deduce what your "project" needs by looking for #include directives.