通过提示取号

Collect number through prompt

我正在尝试从用户那里收集一个数字,以便我可以设置图像的宽度。这是我的代码:

function setDefaultWidth() {
  var ui = DocumentApp.getUi();

  var result = ui.prompt(
      'New Width (must be a number):',
      ui.ButtonSet.OK_CANCEL);

  var button = result.getSelectedButton();
  var text = result.getResponseText();
  if (button == ui.Button.OK) {
    defaultImageWidth = Int32Array(text) //tried this but i get TypeError: Constructor Int32Array requires 'new'
  }
}

我该怎么做?我试过使用 Int32Array,但它不起作用。

@MetaMan:

Just us parseInt()

谢谢,成功了! (将此添加为答案以便更多人可以找到它)