# "the function substring(int) does not exist"

**URL:** <https://discourse.processing.org/t/the-function-substring-int-does-not-exist/36757>\
**Category:** Coding Questions\
**Created:** [May 7, 2022, 10:29am UTC](https://discourse.processing.org/t/the-function-substring-int-does-not-exist/36757 "2022-05-07T10:29:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmberGoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ambergoop/32/16193_2.png) [@AmberGoop](https://discourse.processing.org/u/AmberGoop)\
**Post date:** [May 7, 2022, 10:29am UTC](https://discourse.processing.org/t/the-function-substring-int-does-not-exist/36757/1 "2022-05-07T10:29:53Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [May 7, 2022, 10:33am UTC](https://discourse.processing.org/t/the-function-substring-int-does-not-exist/36757/2 "2022-05-07T10:33:45Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![AmberGoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ambergoop/32/16193_2.png) [@AmberGoop](https://discourse.processing.org/u/AmberGoop)\
**Post date:** [May 7, 2022, 10:37am UTC](https://discourse.processing.org/t/the-function-substring-int-does-not-exist/36757/3 "2022-05-07T10:37:33Z")

</div>

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

```auto
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);
  }  
  image(textures[112],0,0);
  String fn = files[112].substring(98);
  println(fn);
  
}

```

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!

---

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [May 7, 2022, 10:50am UTC](https://discourse.processing.org/t/the-function-substring-int-does-not-exist/36757/4 "2022-05-07T10:50:41Z")

</div>

> [@AmberGoop](#):
>
> … and i’m sorry for wasting this time!

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. 🙂
