Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. JavaScript
  4. is it possible?

is it possible?

Scheduled Pinned Locked Moved JavaScript
javajavascriptvisual-studiohelpquestion
40 Posts 4 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D dusty_dex

    Quote:

    For those who can be bothered to look.

    Yes, strange how this in-built desire to find out *new* stuff (a do it yourself attitude) is lacking in some people. Is it a modern disease of the internet age?

    H Offline
    H Offline
    Hakan Bulut
    wrote on last edited by
    #12

    import javax.swing.*;
    public class RandomNumber {

    /\*\*
     \* @param args
     \*/
    public static void main(String\[\] args) {
        int IsToken\[\]  = {
                9,10,38,40,46,48,
                11,40,42,45,47,48,
                1,19,26,30,31,48
                };
        int lucky\[\];
        int column;
        final int MAX\_DATA = 49;
        int\[ \] arLotto = new int\[MAX\_DATA\];
        for(var i=0; i<MAX\_DATA; i++){
            if(private static boolean\[\] IsToken\[\] == true){
                else if(arLotto\[rnd\] != Istoken\[\]){
                    arLotto\[rnd\] = lucky\[column\]
                    column++;
    
            }
        }
    
        int rnd = (int) Math.round(49 \* Math.random());
        //JOptionPane.showmessageDialog(null, "rnd")
        System.out.print(lucky\[column\]);
    }
    

    }

    D L 2 Replies Last reply
    0
    • H Hakan Bulut

      import javax.swing.*;
      public class RandomNumber {

      /\*\*
       \* @param args
       \*/
      public static void main(String\[\] args) {
          int IsToken\[\]  = {
                  9,10,38,40,46,48,
                  11,40,42,45,47,48,
                  1,19,26,30,31,48
                  };
          int lucky\[\];
          int column;
          final int MAX\_DATA = 49;
          int\[ \] arLotto = new int\[MAX\_DATA\];
          for(var i=0; i<MAX\_DATA; i++){
              if(private static boolean\[\] IsToken\[\] == true){
                  else if(arLotto\[rnd\] != Istoken\[\]){
                      arLotto\[rnd\] = lucky\[column\]
                      column++;
      
              }
          }
      
          int rnd = (int) Math.round(49 \* Math.random());
          //JOptionPane.showmessageDialog(null, "rnd")
          System.out.print(lucky\[column\]);
      }
      

      }

      D Offline
      D Offline
      dusty_dex
      wrote on last edited by
      #13

      I think you will have problems with CP admins if you start posting Java code in a Javascript forum. :doh: I will take look at this new attempt, and change my name to Claire Voyant. :java:

      H 1 Reply Last reply
      0
      • D dusty_dex

        I think you will have problems with CP admins if you start posting Java code in a Javascript forum. :doh: I will take look at this new attempt, and change my name to Claire Voyant. :java:

        H Offline
        H Offline
        Hakan Bulut
        wrote on last edited by
        #14

        :))) This is funny. I am really not be hip this. I am trying to translate to codes from javascript to java :)

        D 1 Reply Last reply
        0
        • H Hakan Bulut

          :))) This is funny. I am really not be hip this. I am trying to translate to codes from javascript to java :)

          D Offline
          D Offline
          dusty_dex
          wrote on last edited by
          #15

          Hakan Bulut wrote:

          :) )) This is funny. I am really not be hip to this.

          Ya don't say. :-\ :omg: Well I can be thankful you are using array of numbers now. :)

          H 1 Reply Last reply
          0
          • D dusty_dex

            Hakan Bulut wrote:

            :) )) This is funny. I am really not be hip to this.

            Ya don't say. :-\ :omg: Well I can be thankful you are using array of numbers now. :)

            H Offline
            H Offline
            Hakan Bulut
            wrote on last edited by
            #16

            yeah it is.. but i need some help on linked variable for IsToken numbers .txt *.js or any file extension to use it database record numbers to IsToken numbers a file integrated with Java language. At first i need to this file connected record numbers to do combination then. Do you know API or sample code about on this topic? Forexapmle: http://maverick.8m.net/loto.htm a little bit complete.. I'm using to this link. Any file to use it record database integrated with Java language. is it possible?

            D 3 Replies Last reply
            0
            • H Hakan Bulut

              import javax.swing.*;
              public class RandomNumber {

              /\*\*
               \* @param args
               \*/
              public static void main(String\[\] args) {
                  int IsToken\[\]  = {
                          9,10,38,40,46,48,
                          11,40,42,45,47,48,
                          1,19,26,30,31,48
                          };
                  int lucky\[\];
                  int column;
                  final int MAX\_DATA = 49;
                  int\[ \] arLotto = new int\[MAX\_DATA\];
                  for(var i=0; i<MAX\_DATA; i++){
                      if(private static boolean\[\] IsToken\[\] == true){
                          else if(arLotto\[rnd\] != Istoken\[\]){
                              arLotto\[rnd\] = lucky\[column\]
                              column++;
              
                      }
                  }
              
                  int rnd = (int) Math.round(49 \* Math.random());
                  //JOptionPane.showmessageDialog(null, "rnd")
                  System.out.print(lucky\[column\]);
              }
              

              }

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #17

              Most of that code makes no sense at all. I would suggest you spend some time with your Java reference manual.

              Use the best guess

              H 1 Reply Last reply
              0
              • L Lost User

                Most of that code makes no sense at all. I would suggest you spend some time with your Java reference manual.

                Use the best guess

                H Offline
                H Offline
                Hakan Bulut
                wrote on last edited by
                #18

                Yeah bit of a problem free time..

                L 1 Reply Last reply
                0
                • H Hakan Bulut

                  Yeah bit of a problem free time..

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #19

                  That is real basic Java; you could work through the online tutorial in an hour or two.

                  Use the best guess

                  1 Reply Last reply
                  0
                  • H Hakan Bulut

                    yeah it is.. but i need some help on linked variable for IsToken numbers .txt *.js or any file extension to use it database record numbers to IsToken numbers a file integrated with Java language. At first i need to this file connected record numbers to do combination then. Do you know API or sample code about on this topic? Forexapmle: http://maverick.8m.net/loto.htm a little bit complete.. I'm using to this link. Any file to use it record database integrated with Java language. is it possible?

                    D Offline
                    D Offline
                    dusty_dex
                    wrote on last edited by
                    #20

                    Thanks for the link. You can now remove it from Code Project if you like. :) I was going to post the code back and lost it all because my computer died just as I tried to save the file. :( As you can see I am now back online again. ;P I'll have to start again. tomorrow.

                    1 Reply Last reply
                    0
                    • H Hakan Bulut

                      yeah it is.. but i need some help on linked variable for IsToken numbers .txt *.js or any file extension to use it database record numbers to IsToken numbers a file integrated with Java language. At first i need to this file connected record numbers to do combination then. Do you know API or sample code about on this topic? Forexapmle: http://maverick.8m.net/loto.htm a little bit complete.. I'm using to this link. Any file to use it record database integrated with Java language. is it possible?

                      D Offline
                      D Offline
                      dusty_dex
                      wrote on last edited by
                      #21

                      The database problem should be dealt with by the Web Server solution you choose. Which brings me to the next question. Why Java? (How) do you intend to get Java code working? :confused: That option should also be part of your Web Server solution. Specifically Java Server Pages, and I think you should look at learning web *server side* features first. So that you aren't trying to solve problems which are already provided for you in a server solution. What type of options did you get with your website? :)

                      1 Reply Last reply
                      0
                      • J Jasmine2501

                        That's kind of like wanting to translate Beethoven's 5th into French. Javascript and Java aren't related. There are ways to write executable programs in Javascript, but there's no reason to translate that JS to Java before making it executable... Create desktop apps with JS - Javascript-EXE[^] Write executables using JScript.Net[^]

                        H Offline
                        H Offline
                        Hakan Bulut
                        wrote on last edited by
                        #22

                        Thanks for advance..

                        1 Reply Last reply
                        0
                        • H Hakan Bulut

                          yeah it is.. but i need some help on linked variable for IsToken numbers .txt *.js or any file extension to use it database record numbers to IsToken numbers a file integrated with Java language. At first i need to this file connected record numbers to do combination then. Do you know API or sample code about on this topic? Forexapmle: http://maverick.8m.net/loto.htm a little bit complete.. I'm using to this link. Any file to use it record database integrated with Java language. is it possible?

                          D Offline
                          D Offline
                          dusty_dex
                          wrote on last edited by
                          #23

                          Here's the Java & Javascript, both identical, for you to compare. Ignore the fact that there is no random number generated yet. I just want to get arrays with difference between IsToken and all numbers NOT in that array. I have split it back into 3 x 6 so that it will be easier to manage if you then store them in a database. This is output from the Java version:

                          >java RandomNumber

                          lucky numbers: (without duplicates)
                          9 10 38 40 46 48 11 42 45 47 1 19 26 30 31
                          used numbers:
                          1 0 0 0 0 0 0 0 9 10 11 0 0 0 0 0 0 0 19 0 0 0 0 0 0 26 0 0 0 30 31 0 0 0 0 0 0 38 0 40 0 42 0 0 45 46 47 48 0
                          unused numbers:
                          2 3 4 5 6 7 8 12 13 14 15 16 17 18 20 21 22 23 24 25 27 28 29 32 33 34 35 36 37 39 41 43 44 49

                          import java.util.*;
                          import javax.swing.*;

                          public class RandomNumber {
                          /**
                          * @param args
                          */
                          public static void main(String[] args) {

                               int IsToken\[\]\[\]  = {
                                     { 9,10,38,40,46,48},
                                     {11,40,42,45,47,48},
                                     { 1,19,26,30,31,48}
                                   };
                          
                               int items      = 0; // column (???)
                               int items2     = 0;
                               int MAX\_DATA   = 50;
                               int\[\] duplicates = new int\[MAX\_DATA\];
                               int\[\] lucky      = new int\[MAX\_DATA\];
                               int\[\] arrLotto   = new int\[MAX\_DATA\];
                          
                               //====== Required by Javascript =====
                               for (int i=0; i < MAX\_DATA; i++) {
                                   duplicates\[i\]=0;
                               }
                               //===================================
                          
                               for (int week=0; week < 3; week++) {
                               //System.out.println("column= "+ column);
                          
                                 for (int j=0; j < 6; j++) {
                                     int x = IsToken\[week\]\[j\];
                                          
                                     if(duplicates\[x\] == 0) {
                                         //System.out.println("yes: "+ x+" "+ column);
                                         duplicates\[x\]  = x; // replaces boolean with actual value (non-zero == used)
                                         lucky\[items\] = x;
                                         items++;
                                     } else {
                                         //System.out.println("no: "+ x);
                                     }
                          
                                 } // loop-j
                          
                               } // loop-week
                          
                                  
                               /\* copied from IsToken\[\]\[\] with any duplicates removed \*/
                               System.out.print("\\nlucky numbers: (without duplicates)\\n");
                               for (int i=0; i < items; i++) {
                                  System.out.print(lucky\[i\] +" ");
                               }
                          
                               /\* array use for tracking duplicates, int instead of boolean \*/
                               System.out.print("\\nused numbers:\\n");
                               
                               for
                          
                          H 1 Reply Last reply
                          0
                          • D dusty_dex

                            Here's the Java & Javascript, both identical, for you to compare. Ignore the fact that there is no random number generated yet. I just want to get arrays with difference between IsToken and all numbers NOT in that array. I have split it back into 3 x 6 so that it will be easier to manage if you then store them in a database. This is output from the Java version:

                            >java RandomNumber

                            lucky numbers: (without duplicates)
                            9 10 38 40 46 48 11 42 45 47 1 19 26 30 31
                            used numbers:
                            1 0 0 0 0 0 0 0 9 10 11 0 0 0 0 0 0 0 19 0 0 0 0 0 0 26 0 0 0 30 31 0 0 0 0 0 0 38 0 40 0 42 0 0 45 46 47 48 0
                            unused numbers:
                            2 3 4 5 6 7 8 12 13 14 15 16 17 18 20 21 22 23 24 25 27 28 29 32 33 34 35 36 37 39 41 43 44 49

                            import java.util.*;
                            import javax.swing.*;

                            public class RandomNumber {
                            /**
                            * @param args
                            */
                            public static void main(String[] args) {

                                 int IsToken\[\]\[\]  = {
                                       { 9,10,38,40,46,48},
                                       {11,40,42,45,47,48},
                                       { 1,19,26,30,31,48}
                                     };
                            
                                 int items      = 0; // column (???)
                                 int items2     = 0;
                                 int MAX\_DATA   = 50;
                                 int\[\] duplicates = new int\[MAX\_DATA\];
                                 int\[\] lucky      = new int\[MAX\_DATA\];
                                 int\[\] arrLotto   = new int\[MAX\_DATA\];
                            
                                 //====== Required by Javascript =====
                                 for (int i=0; i < MAX\_DATA; i++) {
                                     duplicates\[i\]=0;
                                 }
                                 //===================================
                            
                                 for (int week=0; week < 3; week++) {
                                 //System.out.println("column= "+ column);
                            
                                   for (int j=0; j < 6; j++) {
                                       int x = IsToken\[week\]\[j\];
                                            
                                       if(duplicates\[x\] == 0) {
                                           //System.out.println("yes: "+ x+" "+ column);
                                           duplicates\[x\]  = x; // replaces boolean with actual value (non-zero == used)
                                           lucky\[items\] = x;
                                           items++;
                                       } else {
                                           //System.out.println("no: "+ x);
                                       }
                            
                                   } // loop-j
                            
                                 } // loop-week
                            
                                    
                                 /\* copied from IsToken\[\]\[\] with any duplicates removed \*/
                                 System.out.print("\\nlucky numbers: (without duplicates)\\n");
                                 for (int i=0; i < items; i++) {
                                    System.out.print(lucky\[i\] +" ");
                                 }
                            
                                 /\* array use for tracking duplicates, int instead of boolean \*/
                                 System.out.print("\\nused numbers:\\n");
                                 
                                 for
                            
                            H Offline
                            H Offline
                            Hakan Bulut
                            wrote on last edited by
                            #24

                            Ok thanks this is right java dublicates method.. I have already compiled your code as .jar http://maverick.8m.net/myApps/Dusty_dex_randomnumber.jar[^] but an corrupted jar is that file for giving error should have some library or file existing in IDE. Well do you compile jar file valid as phone? needs to any definition or adding library to compile it as phone or tablet? Thanks a lot for help and coding.

                            D 1 Reply Last reply
                            0
                            • H Hakan Bulut

                              Ok thanks this is right java dublicates method.. I have already compiled your code as .jar http://maverick.8m.net/myApps/Dusty_dex_randomnumber.jar[^] but an corrupted jar is that file for giving error should have some library or file existing in IDE. Well do you compile jar file valid as phone? needs to any definition or adding library to compile it as phone or tablet? Thanks a lot for help and coding.

                              D Offline
                              D Offline
                              dusty_dex
                              wrote on last edited by
                              #25

                              I think you messed up the jar by renaming it Dusty_dex_, just name it RandomNumber.java (it should be same name as the Class in the file). OK, this code is using System.out.println but if you want to see output via graphical UI (java.swing) then you will have to \\comment out the System.out.println bits. And learn more about developing for phone. It has never been an area I was bothered about, so I can't help you with phone development. You can post the original errors and I'll see what could be missing. (besides developer knowledge) Let me know if the javascript is any use. I could still work with that code, and convert it without a problem.

                              H 1 Reply Last reply
                              0
                              • D dusty_dex

                                I think you messed up the jar by renaming it Dusty_dex_, just name it RandomNumber.java (it should be same name as the Class in the file). OK, this code is using System.out.println but if you want to see output via graphical UI (java.swing) then you will have to \\comment out the System.out.println bits. And learn more about developing for phone. It has never been an area I was bothered about, so I can't help you with phone development. You can post the original errors and I'll see what could be missing. (besides developer knowledge) Let me know if the javascript is any use. I could still work with that code, and convert it without a problem.

                                H Offline
                                H Offline
                                Hakan Bulut
                                wrote on last edited by
                                #26

                                Okay it is right I did not think it so.. Ok there is no problem in Javascipt code

                                D 1 Reply Last reply
                                0
                                • H Hakan Bulut

                                  Okay it is right I did not think it so.. Ok there is no problem in Javascipt code

                                  D Offline
                                  D Offline
                                  dusty_dex
                                  wrote on last edited by
                                  #27

                                  NO. I mean yes, I know the javascript works. All of it works. You can test java without using phone tools. But is the code doing what you want it to? compared to your own code that you posted. (which is a mess) The java code needs modification in order to work with a GUI and not command line interface (CLI), which I use for compile & run. Can we concentrate on JAVASCRIPT first. Worry about Java later. ;) :)

                                  H 2 Replies Last reply
                                  0
                                  • D dusty_dex

                                    NO. I mean yes, I know the javascript works. All of it works. You can test java without using phone tools. But is the code doing what you want it to? compared to your own code that you posted. (which is a mess) The java code needs modification in order to work with a GUI and not command line interface (CLI), which I use for compile & run. Can we concentrate on JAVASCRIPT first. Worry about Java later. ;) :)

                                    H Offline
                                    H Offline
                                    Hakan Bulut
                                    wrote on last edited by
                                    #28

                                    In where is to the Javascript Runner to run it at notepad++?

                                    1 Reply Last reply
                                    0
                                    • D dusty_dex

                                      NO. I mean yes, I know the javascript works. All of it works. You can test java without using phone tools. But is the code doing what you want it to? compared to your own code that you posted. (which is a mess) The java code needs modification in order to work with a GUI and not command line interface (CLI), which I use for compile & run. Can we concentrate on JAVASCRIPT first. Worry about Java later. ;) :)

                                      H Offline
                                      H Offline
                                      Hakan Bulut
                                      wrote on last edited by
                                      #29

                                      Yes JavaScript is not give an output

                                      D 2 Replies Last reply
                                      0
                                      • H Hakan Bulut

                                        Yes JavaScript is not give an output

                                        D Offline
                                        D Offline
                                        dusty_dex
                                        wrote on last edited by
                                        #30

                                        Have you used the very first version? I posted it again, and that version does work. It should look like this

                                        lucky numbers: (without duplicates)
                                        9 10 38 40 46 48 11 42 45 47 1 19 26 30 31
                                        used numbers:
                                        1 0 0 0 0 0 0 0 9 10 11 0 0 0 0 0 0 0 19 0 0 0 0 0 0 26 0 0 0 30 31 0 0 0 0 0 0 38 0 40 0 42 0 0 45 46 47 48 0
                                        unused numbers:
                                        2 3 4 5 6 7 8 12 13 14 15 16 17 18 20 21 22 23 24 25 27 28 29 32 33 34 35 36 37 39 41 43 44 49

                                        It was this and a few minor {} [] differences I overlooked. I had converted Java code back to javascript and posted it without checking. Sorry.

                                             //===== Required by Javascript ======
                                             for (int i=0; i < MAX\_DATA; i++) {
                                                 duplicates\[i\]=0;
                                             }
                                             //===================================
                                        

                                        :) I will send you an email.

                                        1 Reply Last reply
                                        0
                                        • H Hakan Bulut

                                          Yes JavaScript is not give an output

                                          D Offline
                                          D Offline
                                          dusty_dex
                                          wrote on last edited by
                                          #31

                                          I had a look at your web server code and tried to figure out Random bits. You do understand these are not finished code? Just "Work in progress", but I'm not getting much response as usual. :doh:

                                          function RandomNumber() {
                                          var IsToken = [
                                          [ 9,10,38,40,46,48],
                                          [11,40,42,45,47,48],
                                          [ 1,19,26,30,31,48]
                                          ];

                                          var MAX\_WEEKS  = 3; // array can now be extended, avoids (future) problems ;)
                                          var MAX\_DATA   = 50;
                                          var items      = 1;
                                          var items2     = 1;
                                          var scope;
                                          var dups       = new Array(MAX\_DATA); 
                                          var nodups     = new Array(MAX\_DATA); // \*\* NEW \*\*
                                          var lucky      = new Array(MAX\_DATA);
                                          var arr        = \[\];
                                          
                                          //===================================
                                          for (var i=0; i < MAX\_DATA; i++) {
                                               dups\[i\]=0;
                                          }
                                          //===================================
                                          
                                          // ArrIns can be dealt with in exactly the same way
                                          // as before it's just easier to manage changes
                                          for (var week=0; week < MAX\_WEEKS; week++) {
                                          //document.write("items= "+ items);
                                          
                                            for (var j=0; j < 6; j++) {
                                                var x = IsToken\[week\]\[j\];
                                                          
                                                if(dups\[x\] == 0) {
                                                    //document.write("yes: "+ x +" "+ items);
                                                    dups\[x\]  = x; // replaces boolean with actual value (non-zero == used)
                                                    nodups\[items\] = x;
                                                    items++;
                                                } else {
                                                    //document.write("no: "+ x);
                                                }
                                          
                                            } // loop-j
                                          
                                          } // loop-week
                                          
                                          // \*\*\* NEW \*\*\* - no duplicates, now sort them
                                          nodups.sort(function(a,b){return a-b;});
                                                  
                                          /\* copied from IsToken\[\]\[\] with any duplicates removed \*/
                                          document.write("  
                                          

                                          numbers: (without duplicates)
                                          ");
                                          for (var i=0; i < items-1; i++) {
                                          document.write(nodups[i] +" ");
                                          }

                                          /\* array used for tracking duplicates & used by random.
                                             int instead of boolean.
                                          \*/
                                          document.writeln("  
                                          

                                          ");
                                          document.write("
                                          used numbers:
                                          ");

                                          for (var i=1; i < 50; i++) {
                                               if (dups\[i\] == 0) {
                                                  arr\[items2++\] = i;
                                               } else {
                                                  arr\[items2++\] = 0;
                                               }
                                              document.write(dups\[i\] +" ");
                                          }
                                          
                                          document.writeln("  
                                          

                                          ");
                                          document.writeln("
                                          unused numbers:
                                          ");

                                          for (var i=1; i < items2; i++) {
                                              document.write(arr\[i\] +" ");
                                          }
                                          
                                          document.writeln("  
                                          

                                          ");

                                          /\* watch when arr\[q\] = 0 (gets value of q which is in IsToken\[\])
                                           \* 
                                           \* NEW :
                                          
                                          H 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups