Another random number question

Say I only want values between 0 and 1
i.e 0.32, 0.56, 0.98
Using the Math.random() function
does the seed go in the ()'s like Math.random(1)
Will that work?
In the previous posting the num2 acted as the seed

To summarize:
1st option: Use Math.random() to get a float between .0 and 1.0 without the possibility to set the seed
2nd option: Create a new generator with
java.util.Random gen=new java.util.Random()or
java.util.Random gen=new java.util.Random(longValueHere)if you want to set the seed, and use gen.nextFloat() to get a float between .0 and 1.0.

Similar Messages

  • One more java random number question

    which of the following codes are correct to generate a random number between start and end inclusively. Both methods seem to be working for me but im pretty sure one would be incorrect
    int num = (int)(start + (Math.random() * (end-start)));
    int num = (int)(start+1 + (Math.random() * (end-start)));

    I say neither of them work. Let's use 5 and 8 as our start and end. In the Math class, random() is said to generate a random number, x, where 0 <= x < 1.
    The first one:
    First, multiply by 8 - 5 (3).
    0 <= x < 3
    Then, add 5.
    5 <= x < 8
    Then, casting to an int, we get a number 5 - 7.
    The second one:
    First, multiply by 8 - 5 (3).
    0 <= x < 3
    Then, add 6.
    6 <= x < 9
    Then, casting to an int, we get a number 6 - 8.
    The "correct" way:
    int num = (int) (Math.random() * (end - start + 1) + start);First, multiply by 8 - 5 + 1 (4).
    0 <= x < 4
    Then, add 5.
    5 <= x < 9
    Then, casting to an int, we get a number 5 - 8.

  • AppleScript Random Number Question.

    I know there are several "guess a random number" AppleScript examples on the web, but I tried writing my own to see if I could pull it off.  Works pretty good except for one bug.  If the random number is lower than 10 (single digit) and I guess a number 10 or higher, my script comes back saying my guess is too small!  Everything in my code looks reasonable to me, but obviously I'm overlooking something!  Here's my code:
    set rnd to (random number from 1 to 20)
    set rnd to rnd as string
    set num to 5
    repeat 5 times
              if num = 1 then
                        set anw to text returned of (display dialog "You have only 1 guess left!
    Pick a number from 1 to 10." default answer "" buttons {"OK"} default button 1)
              else
                        set anw to text returned of (display dialog "You have " & num & " guesses left!
    Pick a number from 1 to 20." default answer "" buttons {"OK"} default button 1)
              end if
              if anw < rnd then
      display dialog "Too Small!" buttons {"OK"} default button 1
              else
                        if anw > rnd then
      display dialog "Too Big!" buttons {"OK"} default button 1
                        else
                                  if anw = rnd then
      display dialog "Correct!" buttons {"OK"} default button 1
                                            return
                                  end if
                        end if
              end if
              set num to num - 1
    end repeat
    display dialog "You have run out of guesses!
    The number was " & rnd & "." buttons {"OK"} default button 1

    you need to convert the variable anw to an integer, otherwise your script will compare anw to rnd as text strings (and text strings beginning with 1 are always small).  add the following code before you do your comparisons:
              set anw to anw as integer
    also, your script will be cleaner if you use the 'else' command in your if statement:
              if anw < rnd then
                      display dialog "Too Small!" buttons {"OK"} default button 1
              else if anw > rnd then
                      display dialog "Too Big!" buttons {"OK"} default button 1
              else
                      display dialog "Correct!" buttons {"OK"} default button 1
                      return
              end if

  • Random Number Question

    while (true) {
    randomInt = (int) (Math.random() * 100);
    System.out.println(randomInt);
    I try to create random number from 0 -100. However, it always randomize to the same few integers. Why this happens?

    Math.random() uses the current time in milliseconds to
    form random numbers. So you need to have a delay in
    there before getting the next random number or you'll
    generate random numbers too fast, and end up with the
    same number(s).I don't think that's right. According to the docs:
    "When this method is first called, it creates a single new pseudorandom-number generator, exactly as if by the expression
    new java.util.Random
    This new pseudorandom-number generator is used thereafter for all calls to this method and is used nowhere else"

  • Another page number question...

    Hi (probably Paul again!),
    Getting the page number in a form seems pretty straightforward if you use the handy prefab button. I'm working on a general office form, and the assumption is that the actual print copy will have more pages stapled to it (like for a fax).
    I'd therefore like the option to add some page number padding to the xfa.host.numPages.
    Trying this:
    var numPages = 1;
    var xtraPages = 0;
    numPages.value = xfa.host.numPages;
    this.rawValue = parseInt(numPages.value)+ parseInt(xtraPages.value);
    when I app.alert it, it seems that the xfa.host.numPages isnt going into the numPages variable. Is there a trick to accessing the info in the xfa stuff?
    thanks,
    -jamie

    thanks Paul.
    that's making progress finally.
    Do you have any further thoughts on where to keep the
    numPages = xfa.host.numPages variable updated? I'm not getting it to recalculate with other events (like when the content flows to another page). I've tried it on layout:ready, calculate & form:ready. None of them are updating automatically, but if I tickle a different button on the form it will update to the correct value.
    Oh, and the buttons that add fields which cause another page to be added to have the xfa.form.recalculate(1) set currently.
    thanks again.
    -jamie

  • Generating random number within size of map problem (why me!!) ?

    Hi Guys,
    I'm trying to generator random numbers between 0 and a map width and another random number between 0 and a map height i.e if the map width was 3 i can generator 0,1,2.
    The coding i am using to do this is :
    int randomCol;
    int randomRow;
    randomCol = newMapWidth - 0 + 1;
    int itemp = generator.nextInt() % randomCol;
    if (itemp < 0)
          itemp = -itemp;
    randomCol = 0 + itemp;
    randomRow = newMapHeight - 0 + 1;
    int jtemp = generator.nextInt() % randomRow;
    if (jtemp < 0)
         jtemp = -jtemp;
    randomRow = 0 + jtemp;I've had a look at similar problems and searched penalty but can't seem to get it right for whatever way i implement. It leads to some array out of bound errors.
    If any can help me resolve this problem it would be greatly appreciated.
    Thanks A lot !

    Hippolyte wrote:
    randomRow = 0 + jtemp;I'll bite: what's the "0 + " voodoo for?It?s for clarity and Code readability, I guess. @OP: Random.nextFloat() generates numbers from 0.0f to 1.0f. Multiplying this number with your max value will generate a number between 0 and that given max value. BTW, you can generate numbers from -a to a by using (Random.nextFloat()- .5f) * (2 * a).
    Shazaam.

  • A simple question on random number generation?

    Hi,
    This is a rather simple question and shows my newbieness quite blatantly!
    I'm trying to generate a random number in a part of a test I have.
    So, I have a little method which looks like this:
    public int getRandomNumber(int number){
            Random random = new Random(number);
            return random.nextInt(number);
        }And in my code I do int random = getRandomNumber(blah)...where blah is always the same number.
    My problem is it always returns the same number. What am I missing here. I was under the impression that nextint(int n) was supposed to generate the number randomly!! Obviously I'm doing something wrong or not using the correct thing. Someone please point out my stupidity and point me in the right direction? Ta

    I think the idea is that Random will generate the same pseudo-random sequence over and over if you don't supply a seed value. (The better to debug with, my dear.) When you're ready to put an app into production, the seed value should be the current system time in milliseconds to guarantee a new sequence with each run.
    Do indeed move Random outside the loop. Think of it like a number factory - instantiate it once and let it pump out the random values for you as needed.

  • How to use a random number equal another number. (with my source code)

    hi, i'm having trouble with this assignment.
    3. Determine how many times a die must be rolled in order to
    win a prize. (This represents one trial.) Print this value to a
    text file.
    4. Conduct at least 1,000 trials.
    5. Read the data back in from all of the trials.
    6. Calculate the average number of times a die must be rolled in order to win a prize.
    7. Print the result to the screen
    This is what I have so far.
    But I get a "int cannot be dereferenced" error
    * Write a description of class BottleCapPrize here.
    * @author (your name)
    * @version (a version number or a date)
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Scanner;
    import java.util.Random;
    import java.io.File;
    public class BottleCapPrize
    public static void main (String [ ] args) throws IOException
    PrintWriter outFile = new PrintWriter(new File("bah.txt"));
    Random randomGenerator = new Random();
    int random = randomGenerator.nextInt(5);
    int count = 0;
    for (int loop = 1; loop <= 1000; loop++)
    if(random.equals("3"))
    outFile.println("Congratulations, both pairs matched.");
    count++;
    outFile.close ( );
    }

    And the random generator can only choose a 1 or 2 or 3 or 4 or 5. This is then randomly chosen 1000 times like 400 2s and 200 5s for example.I think you have still to appreciate that the task is not to roll a dice 1000 times and see how many of each number you get.
    Tackle it one step at a time:
    3. A - Determine how many times a die must be rolled in order to win a prize. (This represents one trial.)
    B - Print this value to a text file.
    Even the first part of the problem can be broken down into two parts. I strongly suggest to get step 3A working correctly before you move any further. Notice that this step does not involve 1000 rolls of the dice. Rather it asks you to roll the dice as many times as needed until you get a three. Start there: write a method that does no more than report the number of times it had to roll the dice in order to get a three.
    import java.util.Random;
    public class BottleCapPrize
        public static void main (String [ ] args) throws IOException
            Random randomGenerator = new Random();
            int count = 0;
             * Your code here.
             * At the end of it count should be equal to the number of
             * dice rolls it took to get a three.
            System.out.println("It took " + count + "dice rolls to get a three");
    }Once you have this method working correctly - that is you run it lots of times and it agrees with what you find experimentally with an actual dice - then you can move on to saving this result to a file (step 3B). The steps of the assignment provide a framework that makes sense - follow them one at a time.
    but only thing is that the random number is all a certain number.That's a fairly major defect in a randomly generated number ;). Read the API documentation for the [nextInt(n)|http://java.sun.com/javase/6/docs/api/java/util/Random.html#nextInt(int)] method. It should be clear that this is the method that randomly generates a number. So if you want lots of randomly generated numbers (rather than one randomly generated number lots of times) then you have to call this method lots of times. A call to nextInt(n) is the programming equivalent to rolling a dice.

  • SsRandom or another way to get a random number

    In iDocScript, I need to get a random number between 0 and 4, or it could be between 1 and 5. I found ssRandom, but am unsure how to use that number to get the range I want. Any other ways or advice?

    I found the answer, below is some iDocScript for generating random numbers.
    [!--$randomIndex = ssRandom()--]
    [!--$if randomIndex lt 0--]
    [!--$randomIndex = randomIndex * (-1)--]
    [!--$endif--]
    [!--$randomIndex = randomIndex % 5--];

  • Also Question about create Random number

    What's the best way to create random number in main method, which will allow the number (random) to be stored into content of queue. I was thinking somewhere along the road, is this the appropriate way to handle this?
    import java.util.*;
    public static void main(String[] args)
            Queue q=new Queue();
    Random random = new Random ();
            for(int i=0;i<12;i++)
               q.add(random);
              

    Close, but not quite. That will add the same random number number generator (no random numbers) to the queue 20 times.
    Look at the methods in the Random class to find the one that suits your needs for using the generator (the Random) to generate a random number.
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Random.html

  • How do I assign images to grid cells based on their random number value?

    Hello everyone!
         I need a good point (or shove) in the correct direction.
    Background
         I've created (with previous help from this forum) a 12 x 9 random number grid which cycles through the numbers 1 to 9 a total of twelve times each. I've then created a button which shuffles the current grid's cells each time it is clicked. I now want to use 9 images that I have imported as individual symbols into the library (I have given them each their own class titled "skin1," "skin2," ... "skin9") as cell labels or the equivalent. I have also set the images up as individual movie clips (using the .Sprite class as the extended base class but keeping the actual image class names in line with their object name, i.e. the "skin1" image is the "skin1.as" class).
    Question
         How do I assign these images to the grid cells based on their respective values (ranging from 1 to 9) and have them populate the grid each time I click the "shuffle" button? So for example, in my grid the numbers 1 through 9 randomly appear 12 times each. Every time the number 4 appears in a cell, I want it to be assigned to the image "skin4" (which is just a graphic that looks like a button and has a fancy number "4" printed on it). Below is a chunk of the code I am using to draw the grid cells with:
    // Creates a grid cell when called by generateGrid().
    private funciton drawCell(_numeral:int):Sprite
              This is the code I am currently implementing to populate the grids with (although I
              don't want to use text labels as I want to fill each grid with an image according
              to its numerical value (1 to 9).
         var _label:TextField = new TextField();
         _label.multiline = _label.wordWrap = false;
         _label.autoSize = "center";
         _label.text = String(_numeral);
         // Add numerical label to cell array.
         cellLabels.push(_label);
         var _s:Sprite = new Sprite();
         _s.graphics.lineStyle(2, 0x019000);
         _s.graphics.drawRect(30, 0, cellW, CellH);
         _s.addChild(_label);
         return _s;
         While the following isn't working code, it will hopefully demonstrate what I want to achieve inside this function so I don't have to use the above snippet for text labels:
         //This will "hopefully" create an array of all 9 images by calling their classes.      var _imageArray:Array = [skin1, skin2, skin3, skin4, skin5 , skin6, skin7, skin8, skin9];      // This is what I want to happen for each cell using the above image array:      for (i = 0; i < cells; i++)      {           if (_numeral == 1)           {                // Insert skin1 image for each instance of #1 in the grid.           }           if (_numeral == 2)           {                // Insert skin2 image for each instance of #2 in the grid.           }           ...           if (_numeral == 9)           {                // Insert skin9 image for each instance of #9 in the grid.           }      } 
         Again, I don't want to use text labels. I have a custom skin graphic that I want to go over each number on the grid based on its numerical value (1 to 9). Any help with this is much appreciated!

    kglad,
         Thank you for your help with this one. Using the code below, I have successfully populated my grid cells with the desired corresponding graphics. I noticed one thing though regarding my use of the shuffle button with this particular implementation: even though the numerical values residing in each cell get shuffled, the original images remain in the grid rather than being replaced by new ones. The first code snippet below is the revised cell drawing function including your help; the second snippet shows you my simple shuffle button function (where the problem lies, I think).
    Snippet #1:
         // Creates a grid cell when called by generateGrid().
         private function drawCell(_numeral:int):Sprite
              var _label:TextField = new TextField();
              _label.multiline = _label.wordWrap = false;
              _label.autoSize = "center";
              // Creates a label that represents the numerical value of the cell.
              cellLabels.push(_label);
              var _s:Sprite = new Sprite();
              _s.graphics.lineStyle(2, 0x019000);
              _s.graphics.drawRect(30, 0, cellW, cellH);
              // Physically adds the labels to the grid.
              _s.addChild(_label);
              // Assigns a graphic class to a cell based on its numerical value.
              var _classRef:Class = Class(getDefinitionByName("skin" + _numeral));
              // Undefined variable for holding graphic classes.
              var _image:* = new _classRef();
              // Lines the images up with the grid cells.
              _image.x = 30;
              // Physically adds a graphic on top of a cell label.
              _s.addChild(_image);
              return _s;
         So far so good (although I question needing text labels at all if they are just going to remain invisible underneath the images, but enough about that for now). This next part is the reason that the images won't shuffle with the cell values, I think.
    Snippet #2:
         // When shuffleButton is clicked, this event shuffles
         // the number array and fills the cellLabels with the new values.
         private function onButtonShuffleClick(e:MouseEvent):void
              // Shuffles the number array.
              shuffle(numbers);
              // Verifies the array has been shuffled.
              trace("After shuffle:", numbers);
              // Loop replaces old cellLabels with new number array values.
              for (var i:int = 0; i < cells; i++)
                   cellLabels[i].text = String(numbers[i]);
         As you can see, it never replaces the original images that populate the grid. I tried using the _s.removeChild(image) function but that didn't work, nor would copying/pasting some of the code from snippet #1 directly into this function as it would cause another instance of the images to be placed over top of the existing ones rather than actually swapping them out. Any continued help here is greatly appreciated!
         PS Is there a quicker method for posting code into these forums without having to type it all out by hand again (i.e. copy/paste or drag/drop from my .fla or Notepad file directly into this thread)?

  • Action conditional on random number

    Hi,
    I would like to execute actions conditional on some random number.
    E.g. I have
    Action #1
    Action #2
    Action #3
    My Automator app should in the end randomly execute one of those 3 actions.
    In php I would code as follows:
    $r=rand(1,3);
    if ($r==1)
    action1();
    else if ($r==2)
    action2();
    else
    action3();
    How can I do this within automator?
    Thanks,
    Tassilo

    ok, thanks.
    so it is 100% sure that I cannot start some specified action depending on a (random) variable?
    another question:
    sometimes my automator app gives an error dialog "watchmedo encountered an error".
    this blocks the app to be restarted automatically (I schedule my apps on a repeated basis), as the app still open.
    how can I suppress error dialogs like this? or can I quit the app once an error is encountered?
    those error dialogs (which only go away by clicking OK) kill the possibility to restart the app automatically ...
    thanks.

  • What algorithm does Excel 2010 use for Pseudo Random Number Generation (MT19937?)

    Does Excel 2010+ use the Mersenne Twister (MT19937) algorithm for Pseudo Random Number Generation (PRNG), implemented by the RAND() function?
    This has been a nagging question for some time now, with "hints" that it indeed does.  However, a relatively thorough search turns up no definitive documentation.  The most direct indication is perhaps given by Guy Melard [Ref 9] where
    he tests Excel 2010's RAND() function using the Crush battery of tests in TestU01 by L'Ecuyer & Simard.  Melard references a "semi-official" indication that Microsoft did indeed implement MT19937 for the RAND() function in
    Excel 2010, but this reference no longer seems to be available. http://office.microsoft.com/enus/excel-help/about-solver-HP005198368.aspx?pid=CH010004571033.
    The other references below [Ref 1-10] document the history of the statistical suitability of the PRNG and probability distributions in various versions of Excel.  This includes the Wichmann-Hill PRNG implementations supposedly (arguably) used in
    Excel 2003 & 2007 for random number generation.  But still, we have no answer as to which PRNG algorithm is used in
    Excel 2010 (and 2013 for that matter).
    Microsoft indicates that RAND() has been improved in Excel 2010; Microsoft states, "...and the RAND function now uses a new random number algorithm." (see https://support.office.com/en-ca/article/Whats-New-Changes-made-to-Excel-functions-355d08c8-8358-4ecb-b6eb-e2e443e98aac). 
    But no details are given on the actual algorithm.  This is critical for Monte Carlo methods and many other applications.
    Any help would be much appreciated. Thanks.
    [Ref 1] B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 97. 
    Computational Statistics & Data Analysis. Vol. 31 No. 1, pp 27-37. July 1999.
    http://users.df.uba.ar/cobelli/LaboratoriosBasicos/excel97.pdf
    [Ref 2]L. Knüsel.  On the accuracy of the statistical distributions in Microsoft Excel 97. Computational Statistics & Data Analysis. Vol. 26 No. 3, pp 375-377. January 1998.
    http://www.sciencedirect.com/science/article/pii/S0167947397817562
    [Ref 3]B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and Excel XP. 
    Computational Statistics & Data Analysis. Vol.40 No. 4, pp 713-721. October 2002.
    https://www.researchgate.net/publication/222672996_On_the_accuracy_of_statistical_procedures_in_Microsoft_Excel_2000_and_Excel_XP/links/00b4951c314aac4702000000.pdf
    [Ref 4] B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 2003. 
    Computational Statistics & Data Analysis. Vol.49. No. 4, pp 1244-1252. June 2005.
    http://www.pucrs.br/famat/viali/tic_literatura/artigos/planilhas/msexcel.pdf
    [Ref 5] L. Knüsel. On the accuracy of statistical distributions in Microsoft Excel 2003. Computational Statistics & Data Analysis, Vol. 48, No. 3, pp 445-449. March 2005.
    http://www.sciencedirect.com/science/article/pii/S0167947304000337
    [Ref 6]B. McCullough, D.Heiser.  On the Accuracy of Statistical Procedures in Microsoft Excel 2007. 
    Computational Statistics & Data Analysis. Vol.52. No. 10, pp 4570-4578. June 2008.
    http://users.df.uba.ar/mricci/F1ByG2013/excel2007.pdf
    [Ref 7] A. Yalta. The Accuracy of Statistical Distributions in Microsoft<sup>®</sup> Excel 2007. Computational Statistics & Data Anlaysis. Vol. 52 No. 10, pp 4579 – 4586. June 2008.
    http://www.sciencedirect.com/science/article/pii/S0167947308001618
    [Ref 8] B. McCullough.  Microsoft Excel’s ‘Not The Wichmann-Hill’ Random Number Generators. Computational Statistics and Data Analysis. Vol.52. No. 10, pp 4587-4593. June 2008.
    http://www.sciencedirect.com/science/article/pii/S016794730800162X
    [Ref 9] G. Melard.  On the Accuracy of Statistical Procedures in Microsoft Excel 2010. Computational Statistics. Vol.29 No. 5, pp 1095-1128. October 2014.
    http://homepages.ulb.ac.be/~gmelard/rech/gmelard_csda23.pdf
    [Ref 10] L. Knüsel.  On the Accuracy of Statistical Distributions in Microsoft Excel 2010. Department of Statistics - University of Munich, Germany.
    http://www.csdassn.org/software_reports/excel2011.pdf

    I found the same KB article:
    https://support.microsoft.com/en-us/kb/828795
    This was introduced (according to the article) in Excel 2003. Perhaps the references in notes 2 and 3 might help.
    The article describes combining the results of 3 generators, each similar to a Multiply With Carry (MWC) generator, but with zero carry. MWC generators do very well on the Diehard battery of randomness tests (mentioned in your references), and have
    very long periods. But using zero carry makes no sense to me.
    Combining the three generators only helps if the periods of the 3 are relatively prime (despite what the article implies). Then the period of the result will be the product of the 3 periods. But without knowing the theory behind these generators, I have
    no idea what the periods would be. The formulas for MWC generators fail here.
    Richard Mueller - MVP Directory Services

  • How to define "leading" random number in Infoset fpr parallel processing

    Hello,
    in Bankanalyzer we use an Infoset which consists of a selection across 4 ODS tables to gather data.
    No matter which PACKNO fields we check or uncheck in the infoset definition screen (TA RSISET), the parallel frameworks always selects the same PACKNO field from one ODS table.
    Unfortunately, the table that is selected by the framework is not suitable, because our
    "leading" ODS table which holds most of our selection criteria is another one.
    How to "convince" the parallel framework to select our leading table for the specification
    of the PACKNO in addition (this would be times 20 faster due to better select options).
    We even tried to assign "alternate characteristics" to the packnos we do not liek to use,
    but it seems that note 999101 just fixes this for non-system-fields.
    But for the random number a diffrent form routine is used in /BA1/LF3_OBJ_INDEX_READF01
    fill_range_random instead of fill_range.
    Has anyone managed to assign the PACKNO of his choice to the infoset selection?
    How?
    Thanks in advance
    Volker

    Well, it is a bit more complicated
    ODS one, that the parallel framework selects for being the one to deliver the PACKNO
    is about equal in size (~120GB each) to ODS two which has two significant field which cuts down the
    amount of data to be retreived.
    Currently we execute the generated SQL in the best possible manner (by faking some stats )
    The problem is, that I'd like to have a Statement that has the PACKNO in the very same table.
    PACKNO is a generated random number esp. to be used for parallel processing.
    The job starts about 100 slaves
    Each slave gets a packet to be processed from the framework, which is internaly represented
    by a BETWEEN clause on this PACKNO. This is joined against ODS2 and then the selective fields
    can be compared resultin in 90% of the already fetched rowes can be discarded.
    Basicly it goes like
    select ...
    from
      ods1 T_00,
      ods2 T_01,
      ods3 T_02,
      ods4 T_03
    where
    ... some key equivalence join-conditions ...
    AND  T_00.PACKNO BETWEEN '000000' and '000050' -- very selective on T_00
    AND  T_01.TYPE = '202'  -- selective Value 10% on second table
    I'd trying to change this to
    AND  T_01.PACKNO BETWEEN '000000' and '000050'
    AND  T_01.TYPE = '202'  -- selective Value 10%
    so I can use a combined Index on T_01 (TYPE;PACKNO)
    This would be times 10 more selective on the driving table and due to the fact,
    that T_00 would be joined for just the rows I need, about a calculated time 20-30 faster.
    It really boosts when I do this in sqlplus
    Hope this clearyfies a bit.
    Problem is, that I can not change the code either for doing the
    build of the packets or the one that executes the application.
    I need to change the Inofset, so that the framework decides to build
    proper SQL with T_01.PACKNO instead of T_00.PACKNO.
    Thanks a lot
    Volker

  • How to generate a unique random number in a MySQL db

    I'm creating a volunteer and also a separate vendor application form for an airshow. The volunteer and vendor info is stored in separate tables in a MySQL db, one row per volunteer or vendor. There will be about 100 volunteers and 50 vendors. When the application is submitted it should immediately be printed by the applicant, then signed and mailed in. This past year we had problems with some people who didn't immediately print their application so I'd like to still give them the option to immediately print but also send them an e-mail with a link to their specific row in the MySQL db. I have an autoincrement field as the primary key for each table, but I think sending this key to the applicant in an e-mail would be too easy for them to guess another id and access other people's info.
    I'm thinking I should add a column to each table which would contain a unique random number and I would then send this key in the e-mail to the applicant. So, can anyone suggest a simple way to do this or suggest a better way of giving the applicant a way to access their own application and no-one elses after they have submitted their form?
    Thanks all.
    Tony Babb

    Thanks so much, that was very helpful. I added the code you suggested to create and display the random number - I called it "vollink" and that worked fine. Then I added the hidden field toward the bottom of the form - it shows at line 311 when I do a "View Source in Int Explorer and then tried adding the code to add it to the table and when I tested it failed with "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1" . The test version of the page is here www.hollisterairshow.com/volunteerapp2.php . The changes I made to add it to the table is shown below , I must be missing something blindingly obvious, if you could suggest a fix I'd really appreciate it. I did add the field to the MySQL table also.
    Thanks again
    Tony
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO volunteers (firstname, lastname, email, thursday, friday, saturday, sunday, monday, activity, talents, specialrequests, tshirt, phone, street, city, st, zip, updatedby, vollink) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, $s)",
                           GetSQLValueString($_POST['firstname'], "text"),
                           GetSQLValueString($_POST['lastname'], "text"),
                           GetSQLValueString($_POST['email'], "text"),
                           GetSQLValueString($_POST['thursday'], "text"),
                           GetSQLValueString($_POST['friday'], "text"),
                           GetSQLValueString($_POST['saturday'], "text"),
                           GetSQLValueString($_POST['sunday'], "text"),
                           GetSQLValueString($_POST['monday'], "text"),
                           GetSQLValueString($_POST['activity'], "text"),
                           GetSQLValueString($_POST['specialtalents'], "text"),
                           GetSQLValueString($_POST['specialrequests'], "text"),
                           GetSQLValueString($_POST['tshirt'], "text"),
                           GetSQLValueString($_POST['phone'], "text"),
                           GetSQLValueString($_POST['street'], "text"),
                           GetSQLValueString($_POST['city'], "text"),
                           GetSQLValueString($_POST['st'], "text"),
                           GetSQLValueString($_POST['zip'], "text"),
            GetSQLValueString($_POST['vollink'], "text"),
                           GetSQLValueString($_POST['lastname'], "text"));
      mysql_select_db($database_adminconnection, $adminconnection);
      $Result1 = mysql_query($insertSQL, $adminconnection) or die(mysql_error());

Maybe you are looking for

  • I want to implement thems functionality in  my swing application

    Hi All... I want to implement the themes object in my swing application,How ,where to start and move that functionality,If anybody use this functionality in your program experience can u share with me. Than to Advance ARjun...

  • Write 2 chanel waveform data to text file

    I ever posted similar question. Based on helpful answers form that post, I narrowed down my purpose and now post again in order to get more focused discussions on it. In following VI, data from 2 channels are acquired, which need to be displayed and

  • Rg1 opening/closing bal

    Hi experts         we went live without making an entry in the table j_2irg1bal, so we were not getting ope/clo bal in rg1 register print.         I made an entry in our testing client and tested but i am not getting the previous entries in the rg1 r

  • Firefox freezes when ctrl + enter is pressed simultaneously

    Firefox freezes when ctrl + enter is pressed simultaneously.

  • Having some serious issues, help would be appreciated :)

    For the past week or so my MacBook Pro has been shutting itself off, the strange thing is the lights under the keyboard stay on but the on light doesnt. Below is the error code that comes up whenever i restart it: Interval Since Last Panic Report:  2