简体   繁体   English

使用ProcessingJS将返回值从一个函数传递到另一个函数的语法?

[英]Syntax for passing a return value from one function to another with ProcessingJS?

With ProcessingJS, I have a function that determines a number that I would like to give to another function: 使用ProcessingJS,我有一个函数来确定我想要给另一个函数的数字:

int number;
int theNumbers() {
  // calculations for number

  int number = 10; // sample number
  return number;
}

void mousePressed() {
  // calculations for aLongNumber

  // pass theNumbers() number value
  theNumbers();
  long numberLong = aLongNumber + (number * aLongNumber);
}

For some reason, right now numberLong = aLongNumber and doesn't add (number * aLongNumber) because number has yet to pass to mousePressed() after calling theNumbers(); 出于某种原因,现在numberLong = aLongNumber并且没有添加(number * aLongNumber),因为在调用了Number()之后,number还没有传递给mousePressed();

Try this and see if you get the required results: 试试这个,看看你是否得到了所需的结果:

int number = 0;
int theNumbers() {

number = 10; // sample number
return number;
}

void mousePressed() {
number = theNumbers();
long numberLong = aLongNumber + (number * aLongNumber);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM