<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to create random alphanumeric string in flexscript? in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594626#M89712</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;An alternative:&lt;/P&gt;&lt;PRE&gt;string result;
Array mix=[3,3]; // 3 letters, 3 numbers
for (int n=mix[1];n&amp;gt;0;n--)
&amp;nbsp; &amp;nbsp; result+=strascii(duniform(97,122)); &amp;nbsp;// for capitals use 64-90
result+=string.fromNum(duniform(1,Math.pow(10,mix[2])-1),0).padStart(3,"0"); 
return result;&lt;/PRE&gt;&lt;P&gt;For both approaches you should add a stream to duniform. If this is to become a user command, pass one in as parameter.&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 06 Jul 2023 11:34:16 GMT</pubDate>
    <dc:creator>jason_lightfoot_adsk</dc:creator>
    <dc:date>2023-07-06T11:34:16Z</dc:date>
    <item>
      <title>How to create random alphanumeric string in flexscript?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594624#M89710</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 23.1.2 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;How to generate random string that contains alphanumeric characters with specified number of length of the string. Example are ckd938, jfp393 etc if we need the length of the string to be 6.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Jul 2023 23:29:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594624#M89710</guid>
      <dc:creator>preetdesai</dc:creator>
      <dc:date>2023-07-05T23:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create random alphanumeric string in flexscript?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594625#M89711</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi &lt;A rel="user" href="https://answers.flexsim.com/users/42530/preetdesai.html" nodeid="42530"&gt;@Preet&lt;/A&gt; ,&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/temp/70577-alphanumericdemo.fsm" target="_blank"&gt;alphanumericDemo.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P&gt;You could do something like this to make a six digit alphanumeric string randomly. You can adjust the numLetters and numNumbers variables depending on the length of the string you want. Example output below.&lt;/P&gt;
 &lt;PRE&gt;string letters = "abcdefghijklmnopqrstuvwxyz";
int numLetters = 3;
int numNumbers = 3;
string result = "";

//append the letters
for (int i = 0; i &amp;lt; numLetters; i++) {
    int randomIndex = duniform(1,26);
    string newChar = letters.charAt(randomIndex);
    result = result + newChar;
    //print(newChar);
}
//append the numbers
for (int i = 0; i &amp;lt; numNumbers; i++) {
    int randomNum = duniform(0,9);
    string newChar = string.fromNum(randomNum);
    result = result + newChar;
    //print(newChar);
}


print(result);&lt;/PRE&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1688614637530.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1518109i0EBDBBC32F37A6AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="1688614637530.png" alt="1688614637530.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;Hope that helps!&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Jul 2023 03:37:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594625#M89711</guid>
      <dc:creator>carter-walch</dc:creator>
      <dc:date>2023-07-06T03:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create random alphanumeric string in flexscript?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594626#M89712</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;An alternative:&lt;/P&gt;&lt;PRE&gt;string result;
Array mix=[3,3]; // 3 letters, 3 numbers
for (int n=mix[1];n&amp;gt;0;n--)
&amp;nbsp; &amp;nbsp; result+=strascii(duniform(97,122)); &amp;nbsp;// for capitals use 64-90
result+=string.fromNum(duniform(1,Math.pow(10,mix[2])-1),0).padStart(3,"0"); 
return result;&lt;/PRE&gt;&lt;P&gt;For both approaches you should add a stream to duniform. If this is to become a user command, pass one in as parameter.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Jul 2023 11:34:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594626#M89712</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2023-07-06T11:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create random alphanumeric string in flexscript?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594627#M89713</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi &lt;A rel="user" href="https://answers.flexsim.com/users/42530/preetdesai.html" nodeid="42530"&gt;@Preet&lt;/A&gt;, was Carter Walch's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.&lt;/P&gt;
 &lt;P&gt;If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 11 Jul 2023 14:21:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-random-alphanumeric-string-in-flexscript/m-p/13594627#M89713</guid>
      <dc:creator>natalie_white</dc:creator>
      <dc:date>2023-07-11T14:21:32Z</dc:date>
    </item>
  </channel>
</rss>

