My program keeps crashing; STRING (file) to INT

There a re few things you can do yourself before asking for help.

First, you can isolate the problem: Trying running the culprit lines in a sketch by themselves.

Second: Use print() to see what the values you are converting

Third: Always check you dont have a null case

Fourth: Base on the error, do a search online and in the forum

If the issue persist, share your code and tell us what you tried.

Now, I have to add that you are doing something you suppose not to do. In the code you provided above, you are adding code outside setup and draw functions. For instance, the proper way to do it:


String wLen ;
int intA ;

void setup(){
  size(100,100);  
  String wLen = loadStrings("besede.txt")[0];
  int intA = int(wLen); //trying to change String to Int, i'vs seen it work

  ... //Rest of the code

Please check the second bullet in the Troubleshooting guide under the section: Common Issues (That Are Not Bugs).

Kf

1 Like