Quote:The upload error, is using the code posted which is a string sample from the Arduino site. Question for that, how can I upload that in VS2015 with VM
Yes. I already explained previously that you ticked the menu item "vMicro>Always upload using programmer" by mistake.
I asked you to un-tick it so that when you attempt to upload the usb cable is used.
Did you read my response about "vMicro>Always upload using programmer"?
Quote:The other problem, string.toLowerCase.indexOf("error"); is from another sketch method, shown below, which shows no intellisense erros but doesnt compile, and you've seen the error text already
I explained that the same code fails to compile in the Arduino Ide for me with the same error.
Reading the Arduino string documentation I do not see how your code would work.
The arduino documentation shows that the method toLowerCase() changes the string variable. It does not work like you might expect in other languages where by toLowerCase() returns a lower case copy of the string.
You can clearly see this in their example code from the documentation page
https://www.arduino.cc/en/Tutorial/StringCaseChanges // toUpperCase() changes all letters to upper case:
String stringOne = "<html><head><body>";
Serial.println(stringOne);
stringOne.toUpperCase();
Serial.println(stringOne);
Here is the documented description for the case change functions
Quote:The String case change functions allow you to change the case of a String. They work just as their names imply. toUpperCase() changes the whole string to upper case characters, and toLowerCase() changes the whole String to lower case characters. Only the characters A to Z or a to z are affected.
Summary To avoid confusion I made the following code based on your snippet. You didn't answer the question about which Arduino Ide version you are using so I tested with Arduino.cc 1.6.7 and Arduino.org 1.7.8. Both gave the same error. Here is the full code:-
#include <SD.h>
#include <SPI.h>
char tempString[50];
void setup() {}
void loop() {}
boolean writeToFileOnSD(File fileObj, String fileName, String textToWrite) {
int fileSize;
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return false;
}
//good to go, open the file
fileObj = SD.open(fileName, FILE_WRITE);
if (fileName.toLowerCase.indexOf("error") > 0)
{
//create error string
}
if (fileName.toLowerCase.indexOf("data") > 0)
{
//create data string
}
fileSize = fileObj.size();
fileObj.println(tempString);
fileObj.close();
if (fileObj.size() > fileSize)
{
return true;
}
return false;
}