Skip to content

Function that return a char array or a string function [imported] #655

Closed
@cmaglie

Description

@cmaglie

This is Issue 655 moved from a Google Code project.
Added by 2011-09-26T00:42:30.000Z by raul...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Invalid).

Original labels: Type-Defect, Priority-Medium

Original description

What steps will reproduce the problem?

  1. I create a string function that return a String object or an char array

2.If I write it and I don't call it, it is compiled without errors instead I call it inside the loop this is the output

sketch_sep26a.cpp: In function 'void loop()':
sketch_sep26a:15: error: 'LightStateRange' cannot be used as a function

3. This is the entire code

void setup() {
  Serial.begin(9600); // initializa output to pc 
}

void loop(){
char  LightStateRange[]="";
String _l="";
_l= LightStateRange(30);
Serial.println(_l.length());

}

String  LightStateRange(int light){

String  _lightState="";
 /\* 0-25 Dark 
   26-70 Dark with moon
   71-140 Night with near civil light
   140- 300 Early morning or became night
   300 - 500 morning or afternoon
   501- 800 light
   800  bright
   900  very bright
   _/
   /_
   if (light==0 || light<=25 )    _lightState="Dark";
   if (light>=25 || light<=70 )   _lightState="Dark with moon ";
   if (light>=71 || light<=140 )  _lightState="Night with near civil light";
   if (light>=140 || light<=300 ) _lightState="Early morning or becaming night";
   if (light>=301 || light<=500 ) _lightState="Morning or afternoon";
   if (light>=501 || light<=800 ) _lightState="Day and light";
   if (light>=801 || light<=900 ) _lightState="Bright";
   if (light>=901  )              _lightState=" Very Bright";
   */
  return _lightState;
## }

What is the expected output? What do you see instead?

What version of the Arduino software are you using? 0022
On what operating system? Windows Xp
Which Arduino board are you using? Arduino uno

Please May you explain why?
Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: InvalidOff topic for this repository, or a bug report determined to not actually represent a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions