在 google-apps-script 中处理脚本,有什么建议吗?
Working on script in google-apps-script, any suggestions?
问题:我正在创建一个数组或多个数组来写入值,并继续这样做直到绘制出某个值。此代码的长远观点是,使用这些值将一个字母与另一个字母匹配。 (即二战中使用的炸弹。)除了这将是完全数字化的。 Bombe 是一个解密器,它发现一个字母能够映射到另一个字母。 (Enigma 示例将在评论中 post 编辑。)我正在尝试使用此解密任何消息。
理解: 我不记得很多代码,尤其是因为我以前从未使用过 google-apps-script。我没有基本的想法,但有些语法不同,我迷路了。 (即:而不是 System.out.print();
它将是 Logger.log(data);
。这就是我到目前为止从中得到的全部。我已经制定了一些代码可以找到 here.
背景: 这篇文章太多了,我明白了,但在你标记我并继续前进之前,先听我说完。 hyperlink post 在上面的评论中 "Enigma example" 字样下显示了我试图反向执行的映射。但是,我需要创建我不记得如何创建的循环和变量。我有关于 Enigma 和 Bombe 的信息:Enigma & Bombe info。我已经对 Google 等进行了一些搜索,但是没有任何我理解或有益于我的最终目标。我得到的只是另一个 link,我将在评论中 post,它向我展示了他们所说的 basic 循环。
我需要的帮助: 我在以下方面寻求帮助:循环、变量和数组。建议对我来说是最有价值的,因为我是来学习的,而不是通过询问来完成我的工作。
想法: 我有一些想法,垃圾收集器,多维数组 and/or 只是一系列可能性。 (参见上面的 "Enigma & Bombe info" link。
为了简单 Copy/Pasting:
function bombeCode1() {
var fastRotor = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z"];
var mediumRotor = fastRotor;
var slowRotor = fastRotor;
var rows = 26;
var columns = 26;
for (var i=0; i < rows ; i++) {
Logger.log('Outer Loop: value of i : ' + i);
// Logger.log("Partition for Outer Loop");
// Logger.log(" ");
var fastRotorValue = fastRotor[i];
for (var j=0; j < columns ; j++) {
Logger.log('-Inner Loop value of j : ' +j);
//var fastRotorValue = fastRotor[i];
var medRotorValue = mediumRotor[j];
// Logger.log("---- " + fastRotorValue + " " + medRotorValue);
for (var k=0; k < 26 ; k++) {
// Logger.log('---- XXXX Third Loop value of k : ' + k);
//var fastRotorValue = fastRotor[i];
//var medRotorValue = mediumRotor[j];
var slowRotorValue = slowRotor[k];
Logger.log("---- XXXX " + fastRotorValue + " " + medRotorValue + " " + slowRotorValue);
}; //var objectNumberValuePair = {"0":"A", "1":"B", "2":"C","3":"D","4":"E","5":"F","6":"G","7":"H","8":"I",
// "9":"J","10":"K","11":"L","12":"M","13":"N","14":"O","15":"P","16":"Q","17":"R",
// "18":"S","19":"T","20":"U","21":"V","22":"W","23":"X","24":"Y","25":"Z"}
// Logger.log(slowRotorValue = objectNumberValuePair);
// Logger.log(medRoterValue = objectNumberValuePair);
// Logger.log(fastRoterValue = objectNumberValuePair);
}
}
}
这是我稍微修改的代码,只是为了在 Logger 打印输出中显示 Loop 值。
function bombeCode1() {
var fastRotor = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z"];
var mediumRotor = fastRotor;
var slowRotor = fastRotor;
var rows = 3;
var columns = 6;
for (var i=0; i < rows ; i++) {
Logger.log('Outer Loop: value of i : ' + i);
Logger.log("Partition for Outer Loop");
Logger.log(" ");
for (var j=0; j < columns ; j++) {
Logger.log('----Inner Loop value of j : ' + j);
var fastRoterValue = fastRotor[i];
var medRoterValue = mediumRotor[j];
Logger.log("---- " + fastRoterValue + " " + medRoterValue);
for (var k=0; k < 6 ; k++) {
Logger.log('---- XXXX Third Loop value of k : ' + k);
var fastRoterValue = fastRotor[i];
var medRoterValue = mediumRotor[j];
var slowRotorValue = slowRotor[k];
Logger.log("---- XXXX " + fastRoterValue + " " + medRoterValue + " " + slowRotorValue);
};
}
}
}
运行 看看你的想法。我确定这不是您需要的,但必须从某个地方开始。
问题:我正在创建一个数组或多个数组来写入值,并继续这样做直到绘制出某个值。此代码的长远观点是,使用这些值将一个字母与另一个字母匹配。 (即二战中使用的炸弹。)除了这将是完全数字化的。 Bombe 是一个解密器,它发现一个字母能够映射到另一个字母。 (Enigma 示例将在评论中 post 编辑。)我正在尝试使用此解密任何消息。
理解: 我不记得很多代码,尤其是因为我以前从未使用过 google-apps-script。我没有基本的想法,但有些语法不同,我迷路了。 (即:而不是 System.out.print();
它将是 Logger.log(data);
。这就是我到目前为止从中得到的全部。我已经制定了一些代码可以找到 here.
背景: 这篇文章太多了,我明白了,但在你标记我并继续前进之前,先听我说完。 hyperlink post 在上面的评论中 "Enigma example" 字样下显示了我试图反向执行的映射。但是,我需要创建我不记得如何创建的循环和变量。我有关于 Enigma 和 Bombe 的信息:Enigma & Bombe info。我已经对 Google 等进行了一些搜索,但是没有任何我理解或有益于我的最终目标。我得到的只是另一个 link,我将在评论中 post,它向我展示了他们所说的 basic 循环。
我需要的帮助: 我在以下方面寻求帮助:循环、变量和数组。建议对我来说是最有价值的,因为我是来学习的,而不是通过询问来完成我的工作。
想法: 我有一些想法,垃圾收集器,多维数组 and/or 只是一系列可能性。 (参见上面的 "Enigma & Bombe info" link。
为了简单 Copy/Pasting:
function bombeCode1() {
var fastRotor = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z"];
var mediumRotor = fastRotor;
var slowRotor = fastRotor;
var rows = 26;
var columns = 26;
for (var i=0; i < rows ; i++) {
Logger.log('Outer Loop: value of i : ' + i);
// Logger.log("Partition for Outer Loop");
// Logger.log(" ");
var fastRotorValue = fastRotor[i];
for (var j=0; j < columns ; j++) {
Logger.log('-Inner Loop value of j : ' +j);
//var fastRotorValue = fastRotor[i];
var medRotorValue = mediumRotor[j];
// Logger.log("---- " + fastRotorValue + " " + medRotorValue);
for (var k=0; k < 26 ; k++) {
// Logger.log('---- XXXX Third Loop value of k : ' + k);
//var fastRotorValue = fastRotor[i];
//var medRotorValue = mediumRotor[j];
var slowRotorValue = slowRotor[k];
Logger.log("---- XXXX " + fastRotorValue + " " + medRotorValue + " " + slowRotorValue);
}; //var objectNumberValuePair = {"0":"A", "1":"B", "2":"C","3":"D","4":"E","5":"F","6":"G","7":"H","8":"I",
// "9":"J","10":"K","11":"L","12":"M","13":"N","14":"O","15":"P","16":"Q","17":"R",
// "18":"S","19":"T","20":"U","21":"V","22":"W","23":"X","24":"Y","25":"Z"}
// Logger.log(slowRotorValue = objectNumberValuePair);
// Logger.log(medRoterValue = objectNumberValuePair);
// Logger.log(fastRoterValue = objectNumberValuePair);
}
}
}
这是我稍微修改的代码,只是为了在 Logger 打印输出中显示 Loop 值。
function bombeCode1() {
var fastRotor = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z"];
var mediumRotor = fastRotor;
var slowRotor = fastRotor;
var rows = 3;
var columns = 6;
for (var i=0; i < rows ; i++) {
Logger.log('Outer Loop: value of i : ' + i);
Logger.log("Partition for Outer Loop");
Logger.log(" ");
for (var j=0; j < columns ; j++) {
Logger.log('----Inner Loop value of j : ' + j);
var fastRoterValue = fastRotor[i];
var medRoterValue = mediumRotor[j];
Logger.log("---- " + fastRoterValue + " " + medRoterValue);
for (var k=0; k < 6 ; k++) {
Logger.log('---- XXXX Third Loop value of k : ' + k);
var fastRoterValue = fastRotor[i];
var medRoterValue = mediumRotor[j];
var slowRotorValue = slowRotor[k];
Logger.log("---- XXXX " + fastRoterValue + " " + medRoterValue + " " + slowRotorValue);
};
}
}
}
运行 看看你的想法。我确定这不是您需要的,但必须从某个地方开始。