# Exit not work. And License Processing

**URL:** <https://discourse.processing.org/t/exit-not-work-and-license-processing/12695>\
**Category:** Processing for Android\
**Created:** [July 13, 2019, 6:25am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695 "2019-07-13T06:25:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 13, 2019, 6:25am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/1 "2019-07-13T06:25:37Z")

</div>

Greetings. I am new in all this. There were several questions, I could not find a solution on the forum.

I am writing in APDE. Project for android.

1. How to exit the game?  
I tried through exit (); but it does not want, writes an error and looks for such a function. Am I doing something wrong?

2. What are permissions and licenses?  
I plan to release the product and sell it. Can I do it right away or do I need to get licenses? Pay for them immediately or with a percentage?  
Help with the information, please.

---

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [July 13, 2019, 6:39am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/2 "2019-07-13T06:39:46Z")

</div>

On 2nd question, yes, the licensing legally allows you to take what sketches you’ve made and run away with them, close all sources, never tell anyone you’ve even used Processing and deny anyone saying that, and sell them for thousands of dollars only to whoever you like, or whatever. See here: [https://github.com/processing/processing/wiki/FAQ#do-i-have-to-cite-processing-do-i-have-to-share-my-code-can-i-distribute-my-sketches](https://github.com/processing/processing/wiki/FAQ#do-i-have-to-cite-processing-do-i-have-to-share-my-code-can-i-distribute-my-sketches)

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 13, 2019, 7:15am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/3 "2019-07-13T07:15:12Z")

</div>

Does Java have a license? As I understand it, everything works through it.

---

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [July 13, 2019, 7:43am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/4 "2019-07-13T07:43:14Z")

</div>

Yes, but Java’s policy on this is pretty much the same. If it wasn’t, then Processing FAQ wouldn’t be allowed to say that you can do this with the sketches!

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 13, 2019, 7:50am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/5 "2019-07-13T07:50:53Z")

</div>

Many thanks for the answer and for the link!

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 13, 2019, 8:34am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/6 "2019-07-13T08:34:24Z")

</div>

@NoName ===  
have you tried with finish() - which kills the activity???  
or System.exit(0) (which kills the app)

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 13, 2019, 12:52pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/7 "2019-07-13T12:52:21Z")

</div>

Thank you very much, Akenaton! System.exit (0) really helped!)

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 13, 2019, 3:36pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/8 "2019-07-13T15:36:12Z")

</div>

I remembered more. In order not to create a new topic, I will ask you, maybe you know …  
How to expand the cache space for android? I put null files that I don’t use, everything works. But it would help me a lot and would make my work easier if I knew how to clear / increase the cache.

Tell me? You are welcome.

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 13, 2019, 4:34pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/9 "2019-07-13T16:34:29Z")

</div>

@NoName ===  
that is easy= you use context.getCacheDir() then with what is returned ( some folder let us say f) you create some method (delete(File f) for deleting it && all its children if they are.  
As for the other question that is not easy; most simple way is to add to your Manifest the tag android:largeHeap=“true”; yet, as it depends of the phone it’s possible that it changes nothing… Another solution is to use JNI but it’s much more complicated!

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 13, 2019, 5:32pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/10 "2019-07-13T17:32:49Z")

</div>

Thanks again))

Can I write another question?)  
And maybe not one. They occur as you write code.

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 13, 2019, 5:48pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/11 "2019-07-13T17:48:40Z")

</div>

@NoName ===  
ask; perhaps i am able: that is not sure!!! - though android is my job…

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 13, 2019, 5:59pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/12 "2019-07-13T17:59:46Z")

</div>

I need to be able to record in a text file and save, so that later you can take information from there during the sketch.

But it does not work for me.  
First I create an array with the name (conditional) NAME OF MASSIF.  
I used String NAME OF MASSIF = loadStrings (“NAME.txt”); but when I wrote (called) in the code NAME OF MASSIF [1], I was displayed on the screen null.

Yes, I use these numbers for the account in the game.

I not forget write:  
Line [] NAME OF ARRAY = new line [n];

Can you explain how (1) correctly call a line from a file, (2) write a line to a file?

Can you send a small example that will work?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 14, 2019, 7:25am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/13 "2019-07-14T07:25:31Z")

</div>

> [@NoName](#):
>
> Can you explain how (1) correctly call a line from a file, (2) write a line to a file?

no, that is NOT C / Python …  
in Processing you

- read the whole file to array
- write the whole array to file  
there is no file write append mode, must save / overwrite the whole thing

> [@NoName](#):
>
> new line [n]

array have a append command,  
anyhow you should first read about the different features of

- array  
[append() / Reference / Processing.org](https://processing.org/reference/append_.html)
- array lists ( example integer )  
[IntList / Reference / Processing.org](https://processing.org/reference/IntList.html)

> [@NoName](#):
>
> loadStrings (“NAME.txt”)

> **[loadStrings() / Reference](https://processing.org/reference/loadStrings_.html)**
>
> Reads the contents of a file and creates a String array of its individual lines. If the name of the file is used as the parameter, as in the above example, the file must be loaded in the sketch's "dat…

that creates a array of strings, where each entry contains ONE LINE from the file  
if that line contains words ( with “space” ) you can split that further…

> [@NoName](#):
>
> Can you send a small example that will work?

could, but also you could post your problem code here  
( reduced to file / array / read / write / part but as a testable MCVE )  
or you search for some ready file examples.

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 14, 2019, 10:05am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/14 "2019-07-14T10:05:16Z")

</div>

I have read information about arrays. And I tried to use loadStrings, but I did not write lines from the document, but wrote null;

Can I just have a sample code? You are welcome.  
I used loadStrings from References, but it doesn’t work …  
Perhaps I will solve my problem when I see it in another working example.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 14, 2019, 10:10am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/15 "2019-07-14T10:10:39Z")

</div>

pls. post your code AND your file content  
using the

```auto
</> code tag

```

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 14, 2019, 10:22am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/16 "2019-07-14T10:22:29Z")

</div>

```auto
int w; int h;
int fullFrame=40; PFont standartFont;
PImage gear1, logo1, ball1, shyriken1;
PShape gear2;
int score=335527890; String scoreAll="score "+score; String []scoreres=new String[20];
int gameStatus=1, menuStatus=1; int status=0; int prs=0;
float bgR=220, bgG=80, bgB=20, bgE=10, bgTurn=1;
float flx1, fly1, flx2, fly2;
int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5;
int var1, var2, var3, var4, var5, var6, var7;

void setup(){
  fullScreen(P2D); imageMode(CENTER); textureMode(NORMAL); frameRate(fullFrame); noStroke(); textAlign(CENTER);
  background(bgR,bgG,bgB);
  w=width; h=height;
  
 String[] scoreres=loadStrings("scoreres.txt");
  
  standartFont=loadFont("standart.vlw"); textFont(standartFont);
} 

void draw(){
  if(gameStatus==1){menu();}
  if(gameStatus==2){main();}
  } //void draw

void main(){} //void main
void gameplay(){} //void gameplay
void controlPrs(int xc,int yc,int ww,int hh,int method,int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
  if(method==1){
    if(mousePressed==true&&mouseX>xc-ww/2&&mouseX<xc+ww/2&&mouseY>yc-hh/2&&mouseY<yc+hh/2){mousePressed=false; prs=1;}else{prs=0;}}
  if(method==2){
    
  }
} //void controlPrs

void menu(){
  background(bgR,bgG,bgB);
  bgR=220+bgE; bgG=80+bgE; bgB=40+bgE;
  if(bgTurn==1){bgE+=0.5;}else{bgE-=0.5;}
  if(bgE<-20){bgTurn=1;} if(bgE>20){bgTurn=0;}
  
  if(var1==0){
    controlImage(1);
    controlShape(1,600,600);
    var1=1;}
  shape(gear2,w-300,h-300);
    gear2.translate(-300,-300);
    gear2.rotate(radians(1));
    gear2.translate(300,300);
  
  if(menuStatus==1&&status==0){
  controlImage(2);
  image(logo1,w/2,h/2,w/5*3,w/5*3);
  controlText("*press*",40, w/2,h/6*4);
  if(mousePressed){
    mousePressed=false;
    menuStatus=2;
    var2=0;
    flx1=w/2; fly1=h/2;
    x1=w+w/7*2; y1=h/10*4;
    x2=w+w/6*2; y2=h/10*5;
    x3=w+w/5*2; y3=h/10*6;
    x4=w+w/4*2; y4=h/10*7;
    x5=w/2+10; y5=h+h/2;
    }}
    
  if(menuStatus==2&&status==0){
    image(logo1,flx1,fly1,w/5*3,w/5*3);
       if(var2==0){fly1-=8;}else{fly1-=bgE/15;} if(fly1<h/5){var2=1;}
    controlText("PLAY",80,x1,y1);
       if(var3==0){x1-=8;} if(x1<w/2+10){var3=1;}
    controlText(scoreres[7],75,x2,y2);
    
    
       if(var4==0){x2-=8;} if(x2<w/2+10){var4=1;}
    controlText("ACHIEVEMENT",75,x3,y3);
       if(var5==0){x3-=8;} if(x3<w/2+10){var5=1;}
    controlText("INFO",75,x4,y4);
       if(var6==0){x4-=8;} if(x4<w/2+10){var6=1;}
    controlText("out",65,x5,y5);
       if(var7==0){y5-=8;} if(y5<h/10*9){var7=1;}
    if(var2>0&&var7>0){menuStatus=3; var2=var3=var4=var5=var6=var7=0;}}
   
   if(menuStatus==3&&status==0){
     image(logo1,flx1,fly1,w/5*3,w/5*3); fly1-=bgE/15;
    controlText("PLAY",80,x1,y1);
      controlPrs(x1,y1,w/3*2,h/7,1,0,0,0,0,0,0,0,0);
      if(prs==1){menuStatus=0; status=0; gameStatus=2;}
    controlText(scoreAll,75,x2,y2);
    controlText("ACHIEVEMENT",75,x3,y3);
    controlText("INFO",75,x4,y4);
    controlText("out",65,x5,y5);
      controlPrs(x5,y5,w/3*2,h/7,1,0,0,0,0,0,0,0,0);
      if(prs==1){
        System.exit(0);}}
} //void menu

void controlText(String text, int size, int x, int y){
  textSize(size);
  fill(1,1,1);
  text(""+text+"",x,y);
  noFill();
} //void text

void controlImage(int num){
  if(num==1){
    gear1=loadImage("gear.png");}else{gear1=null;}
  if(num==2){
    logo1=loadImage("logo.png");}else{logo1=null;}
  if(num==3){
    ball1=loadImage("logo.png");}else{ball1=null;}
  if(num==4){
    shyriken1=loadImage("logo.png");}else{shyriken1=null;}
} //controlImage

void controlShape(int num, int shapeX, int shapeY){
 if(num==1){
    gear2=createShape(); gear2.beginShape(); gear2.texture(gear1);
    gear2.vertex(0,0,0,0);
    gear2.vertex(shapeX,0,1,0);
    gear2.vertex(shapeX,shapeY,1,1);
    gear2.vertex(0,shapeY,0,1);
    gear2.endShape();}else{gear2=null;}
} //controlShape

```

 ![Screenshot_20190714-132122](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/77312accc3910d4c9896e9b7fc319c845e16de27.png)

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 14, 2019, 10:23am UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/17 "2019-07-14T10:23:44Z")

</div>

scoreres.txt

 ![Screenshot_20190714-132300](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a2e266527f396f3e54eadf1ac9a8cf9b515ada1a.png)

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 14, 2019, 12:27pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/18 "2019-07-14T12:27:00Z")

</div>

so if i reduce it to the array file code i found in it:

```auto
String []scoreres;

void setup() {
    scoreres=loadStrings("scoreres.txt");
    println(scoreres);
}

void draw() {}

```

scoreres.txt

```auto
2402
0404030
Rprpproeod
499$($)$9

```

that part is working (this way ), and what was the question?

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [July 14, 2019, 12:54pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/19 "2019-07-14T12:54:00Z")

</div>

Yes, it really works.  
I did something wrong and did not see the error, thanks for pointing it out)

How can I save an array in a text document? Write a similar line saveStrings? Right?  
Will it rewrite the document?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [July 14, 2019, 2:45pm UTC](https://discourse.processing.org/t/exit-not-work-and-license-processing/12695/20 "2019-07-14T14:45:03Z")

</div>

yes, it will overwrite the whole file.
