Exit not work. And License Processing

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.

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

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

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!

Many thanks for the answer and for the link!

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

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

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.

@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!

Thanks again))

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

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

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?

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

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

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…

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.

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.

pls. post your code AND your file content
using the

</> code tag
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

scoreres.txt

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

String []scoreres;

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

void draw() {}

scoreres.txt

2402
0404030
Rprpproeod
499$($)$9

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

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?

yes, it will overwrite the whole file.