简体   繁体   English

使用google-apps-script中的脚本,有什么建议吗?

[英]Working on script in google-apps-script, any suggestions?

Problem: I am creating an array, or multiple arrays, to write values, and continue doing so until a certain value is drawn. 问题:我正在创建一个或多个数组来写入值,并继续这样做,直到绘制了某个值。 The long view for this code is to, using these values to match one letter to another. 此代码的长远目的是要使用这些值将一个字母与另一个字母匹配。 (ie The Bombe used in WWII.) Except this will be completely digital. (即第二次世界大战中使用的Bombe。)除了这将是完全数字化的。 The Bombe was a decrypter that find that one letter is able to get mapped to another. Bombe是一个解密程序,它发现一个字母可以映射到另一个字母。 (Enigma example will be posted in comments.) I am trying to decrpyt any message using this. (谜题示例将在评论中发布。)我正在尝试使用它来隐瞒任何消息。

Understanding: I don't remember a lot of code especially since I have never used google-apps-script before. 理解:我不记得很多代码,尤其是因为我以前从未使用过google-apps-script。 I no basic ideas, but some of the syntax's are different I am getting lost. 我没有基本的想法,但是有些语法与我有所不同。 (ie: instead of System.out.print(); it would be Logger.log(data); . That's really all I have gotten from it so far. I have some code worked out which can be found here . (即:而不是System.out.print();它将是Logger.log(data);到目前为止,这实际上是我所获得的全部。我可以找到一些代码,可在此处找到。

Background: This is quite a lot of text to read I understand, but hear me out before you just flag me and move on. 背景:我理解了很多文字,但在您标记我并继续之前,请先听我说。 The hyperlink posted in the above comment under the words "Enigma example" shows the mapping that I am trying to do in reverse. 在上面的评论中,在“ Enigma example”一词下发布的超链接显示了我试图反向进行的映射。 I however need to create loops and variables that I do not remember how to create. 但是,我需要创建我不记得如何创建的循环和变量。 I have information on the Enigma and Bombe: Enigma & Bombe info . 我有有关Enigma和Bombe的信息Enigma&Bombe info I have done some searches on Google and the like, however nothing that I understand or benefit my end goal. 我已经在Google等设备上进行了一些搜索,但是我没有了解或受益于最终目标。 All I have gotten is another link, which I will post in the comments, that shows me a basic loop as they put it. 我所获得的只是另一个链接,我将在评论中发布该链接,该链接向我展示了他们所说的基本循环。

What I need help with: I am asking for help in the following: Looping, variables and arrays. 我需要帮助的内容:我在以下方面寻求帮助:循环,变量和数组。 Suggestions will be the most valuable to me, because I am here to learn, not get my stuff done done by asking. 建议对我来说是最有价值的,因为我是在这里学习,而不是通过提问来完成我的工作。

Ideas: Some ideas I have are, Garbage collectors, multi-dimensional array and/or just a sequence of possibilities. 想法:我有一些想法,垃圾收集器,多维数组和/或只是一系列可能性。 (See the "Enigma & Bombe info" link above. (请参见上方的“谜和Bombe信息”链接。

For easy 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);
     }

   }
 }

Here is the code I modified a little bit, just to show the Loop values in the Logger print out. 这是我修改的代码,只是为了显示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);
      };
    }

  }
}

Run it and see what you think. 运行它,看看您的想法。 I'm sure it's not what you need, but got to start somewhere. 我确定这不是您所需要的,但必须从某个地方开始。

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

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