Giter Club home page Giter Club logo

Comments (7)

ybakos avatar ybakos commented on June 19, 2024

Please post the entire contents of Thread.pde, since the error is being reported on line 49, and your snippet doesn't reflect this.

from processing-sublime.

ubidefeo avatar ubidefeo commented on June 19, 2024

@ybakos the whole program is not relevant to the specific error, but here it is.
as I said, this works inside Processing but not in Processing Sublime

//import java.lang.Thread;
SpeakThread runningThread;
void setup() {
  runningThread = new SpeakThread();
  
  // thread("readKeys");
}
void draw() {
}
void checkKeys() {
  println("checkKeys");
  if (keyPressed) {
    if (key == 'q') {

      println("QQQ");
      runningThread.isRunning = false;
      ;
    }
  }
}
void keyPressed() {

  println("Key");
  if (key == 'q') {
    runningThread.isRunning = false;
  }
  if (key == 't') {
  	runningThread.start();
    //runningThread.run();
  }
}

class SpeakThread extends Thread {
  public boolean isRunning;
  private int counter;
  public void stopRunning() {
    this.isRunning = false;
  }

  public void run() {
    this.isRunning = true;
    this.counter = 0;
    println("running");
    while (this.isRunning) {
      checkKeys();
      println("Sleeping...");
      try {
        counter++;
        Thread.sleep(100);
      }
      catch(InterruptException ie) {
        println("trouble sleeping");
      }
      if (counter > 30) {
        this.isRunning = false;
      }

      println("counter: " + counter);
    }
    println("done");
    return;
  }
}

from processing-sublime.

ybakos avatar ybakos commented on June 19, 2024

@ubidefeo Runs just fine for me in both Processing and from Sublime - assuming I fix the syntax error of InterruptException to InterruptedException.

from processing-sublime.

ubidefeo avatar ubidefeo commented on June 19, 2024

@ybakos even after fixing that I get the same error.

Thread.pde:49:0:49:0: The function sleep(int) does not exist.

I added "Interrupt" at a later time, the compiler won't complain about it being just an Exception, thinking it would help but it didn't.
On which OS are you?
Java version?

maybe it can help me figure out why I have this issue.
I'd much rather write my processing code in ST than the Processing editor :)

from processing-sublime.

ubidefeo avatar ubidefeo commented on June 19, 2024

@ybakos I found my issue, and I think it's relevant to everyone using Processing-Sublime

The compiler is not able to find imports/definitions for source which is not in the standard Processing documents folder.
On Mac, I keep my original Processing sketches in my Documents folder (same for Arduino), but when I use ST I tend to keep my projects in another folder.
I think the processing-java command fails to fully recognise things outside of its designated document folder (not sure why).

Now that I know I'll work in the standard sketch folder, but it would be great if a project could reside everywhere.

Thank you for your test

from processing-sublime.

ybakos avatar ybakos commented on June 19, 2024

@ubidefeo What operating system do you use?

We have never had a problem using the Processing Sublime plugin for projects that are not in the default sketches directory.

For example, I created an empty sketch on my Desktop (MacOS), pasted your code, ran it with the sublime plugin, and do not receive any error.

from processing-sublime.

ubidefeo avatar ubidefeo commented on June 19, 2024

I'm on Mac OS 10.12.6 (Sierra).
Java 8 (1.8.0_162)

same exact code works in Processing 3.3.6 and ST as long as the project resides in the ~/Documents/Processing folder.
If I move it anywhere else then imports fail and some classes are not found.
Not sure what to make of it.
I don't use Processing that often and never tried creating a Thread in Processing-Sublime before so it worked great for me so far.

I don't mind keeping the projects in the Documents folder now that I know, but I still wonder what causes this

from processing-sublime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.