"the function substring(int) does not exist"

i’m having a peculiar issue here - and it’s in the title.
i’m trying to use substring() to cut the first chunk of a long string off, but processing (4.0b2) is telling me that “The function substring(int) does not exist.”
what is going on here? do i need to import something? the function very clearly exists on the documentation…

Hello, @AmberGoop, and welcome to Processing Foundation Discourse!

Please post your code, so we can help identify the problem.

ahh - i’ve identified the problem, apologies… i’ll still post my code:

File dir; 
File [] files;
PImage[] textures;

void setup() {
  dir= new File(dataPath("C:/Users/User/AppData/Roaming/.minecraft/resourcepacks/SimpleSyrup/assets/minecraft/textures/block"));
  files= dir.listFiles();
  textures = new PImage[files.length];
  for (int i = 0; i <= files.length - 1; i++)
    String path = files[i].getAbsolutePath();
      println(path.toLowerCase(), i);
      textures[i] = loadImage(path);
  String fn = files[112].substring(98);

the problem is that i was trying to call substring() on a file, rather than a string…
adding .getAbsolutePath() between files[112] and substring() has fixed this, since that function grabs the path of the file as a string.

thank you for the quick response, though - i really appreciate it, and i’m sorry for wasting this time!

1 Like

No worries, you did not waste anyone’s time.

Thanks for the code; as an example, it will help others.

We all hope you continue to enjoy this forum. :slight_smile: