Can someone spot the coding error?

Hey everyone,
A friend and I are making a rain gauge for our graduation project, and we are using a hall sensor with a magnet, that measures every time the magnet comes by. And out of this measurements we calculate the rainfall. Only, the problem is, we’re not really stars when it comes to programming, and we have two errors in our code, so maybe someone can help us, btw, my apologies for some mistakes in English, it’s not our native language, thanks in advance
This is our code:

/*
script do to time measurements (number of pulses within an interval. 
- every second, a measurement (as integer) is written over the Serial line
- every 5 seconds, a measurement (as integer) is published to the Cloud
- the function "readPulses" is call-able from the Cloud. A measurement (as integer!)
  is returned. 
*/

//the interval used to measure, in milliseconds
int measureTime = 1000;

//the interval used to measure, in milliseconds
int measureTimeOnline = 60000;
//the name of the event.
String eventName = "measurement/Regenmeter";

//the pin to use for measuring.
int inPin = D1;

//some constants and constructs
int measuredPulsesSerial = 0;
int measuredPulsesOnline = 0;
int measuredPulsesSerialPrevious = 0;
int status = 0;

Timer measureTimer(measureTime, readAndSerial);
Timer measureTimerOnline(measureTimeOnline, readAndPublish);

void setup(){
  //start Serial communication
  Serial.begin(9600);

  //set analogPin to INPUT
  pinMode(inPin, INPUT);

  //attach an interupt for handling counting the pulses

  //start timer that calls measurement en sends results over Serial
  measureTimer.start();
  measureTimerOnline.start();
  

  //make measuredPulsesSerialPrevious available online
  Particle.variable("measurement",measuredPulsesSerialPrevious);

  //make readAnalogValue available online, returns measurement as integer
  Particle.function("readPulsesPerSecond",readPulses);
}

void loop(){
    if ((digitalRead(inPin)==HIGH) & (status == 0)){
        Serial.println("pulse");
        measuredPulsesSerial++;
        measuredPulsesOnline++;
        status = 1;
        delay(50);
    } else if ((digitalRead(inPin)==LOW) & (status == 1)){
        status = 0;
    }
}

void readAndSerial(){
  Serial.println(measuredPulsesSerial);
  measuredPulsesSerialPrevious=measuredPulsesSerial;
  measuredPulsesSerial=0;
}

void readAndPublish(){
  Serial.println("publish!");
  float x = (float) measuredPulsesOnline;
  float MM = ((0.0201*x*x)+(0.9038*x))/39.8;
  Particle.publish(eventName, (String) MM);
  measuredPulsesOnline=0;
}

//readPulses only returns the nr of pulses from the previous second.
int readPulses(String Command){
  return measuredPulsesSerialPrevious;
}

And the errors:

regenmeter.cpp:2:1: error: 'script' does not name a type
 
 ^
------------------------------------------------------------------------------------------------------------------------------------------
regenmeter.cpp:26:20: error: 'measureTime' was not declared in this scope
 int inPin = D1;
                    ^
----------------------------------------------------------------------------------------------------------------------------------------------
In file included from ../wiring/inc/spark_wiring.h:48:0,
                 from ./inc/application.h:36,
                 from regenmeter.cpp:3:
../wiring/inc/spark_wiring_cloud.h: In instantiation of 'static bool CloudClass::function(const T&, Types ...) [with T = char [20]; Types = {int (*)(String)}]':
regenmeter.cpp:47:53:   required from here
../wiring/inc/spark_wiring_cloud.h:188:9: error: static assertion failed: 

In Particle.function, name must be less than 12 characters


         static_assert(!IsStringLiteral(name) || sizeof(name) <= USER_FUNC_KEY_LENGTH + 1,
         ^
make[1]: *** [../build/target/user/platform-6regenmeter.o] Error 1
make: *** [user] Error 2
Error: Could not compile. Please review your code.

No need to be a programming genius to understand that error :wink:

That appears to be a glitch of the Wiring preprocessor.
Try using line comments (//) instead of block comments (/* ... */) to get rid of the first error.
That might already solve the measureTime error too.

The other error is quite explicit

Refering to this

Particle.function("readPulsesPerSecond",readPulses);

Oh woops, didn’t see that, hahaha, thanks

In the first line of my code I changed the /* to //, and now the first error is gone, but it didn’t solve the measureTime and now this error:

regenmeter.cpp:2:1: error: expected unqualified-id before ‘-’ token
#include “application.h”
^

appeared

I rather meant that should be changed to this

//script do to time measurements (number of pulses within an interval. 
//- every second, a measurement (as integer) is written over the Serial line
//- every 5 seconds, a measurement (as integer) is published to the Cloud
//- the function "readPulses" is call-able from the Cloud. A measurement (as integer!)
//  is returned. 

Oh nevermind, it’s already solved, thanks a lot;)

yes, it was something with my keyboard that didn’t work exactly how i wanted, but it’s solved, thank you very much