f



Writing a application using "process"

Hi All,

In another programming language, I can use "processes"  to call IE and
a specific html address .

unit GetEE_JavaViaIEUnit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,  StdCtrls, ExtCtrls, FileCtrl;

type
  TForm1 = class(TForm)
    RadioGroup1: TRadioGroup;
    procedure RadioGroup1Click(Sender: TObject);
  private
    procedure Cprocess(sExecuteFile: string; Sender: Tobject);
    { Private declarations }
  public

    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.Cprocess(sExecuteFile: string; Sender: TObject);
var
  pi: TProcessInformation;
  si: TStartupInfo;
begin
  FillMemory(@si, sizeof(si), 0);
  si.cb := sizeof(si);
  CreateProcess(nil, PChar(sExecuteFile), nil, nil, false,
NORMAL_PRIORITY_CLASS, nil, nil, si, pi);
  // close up shop...
  closeHandle(pi.hProcess);
  closeHandle(pi.hThread);
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
var
  Str1, Str2, Totalcmdline: string;
begin
  Str1 := 'C:\Program Files\Internet Explorer\IEXPLORE.EXE';
  if RadioGroup1.ItemIndex = 0 then
  begin
    Str2 :=
'http://oldlook.experts-exchange.com/Programming/Programming_Languages/Java/';
  end;
  if RadioGroup1.ItemIndex = 1 then
  begin
    Str2 :=
'http://www.experts-exchange.com/Programming/Programming_Languages/Java/';
  end;
  Totalcmdline := str1 + ' "' + str2 + ' "';
  Cprocess(Totalcmdline, Self);
end;
end.

 Is it possible using the term "process" to write this above  in Java
language? a demo  would be appreciated.

I do have this program with the term "process" to reset my computer's
time getting the correct time from NIST.   Here it is:


import java.net.*;
import java.io.*;
import java.util.*;


/**
 * <p>Title: Reset Computer's Time Using Java</p>
 * @version 1.0
 */
//  Message from NIST appears as String
// 51863 00-11-15 00:50:05 00 0 0 938.7 UTC(NIST) *

public class resetComputersTimeUsingJava {

  public static void main(String[] args) throws Exception
  {
    int tl, t2, TimeZone, HourAdjusted;
    String inputTimeLine, DateStatement, TimeStatement,
HourAdjustedStr;
    inputTimeLine = " ";
    HourAdjustedStr = " ";
    // with socket address

    java.net.Socket s = new java.net.Socket("132.163.4.102", 13);

    // in May 2005: URL NIST = new URL("http:// updated url
"132.163.4.102:13"); in 2005


    // URLConnection NISTConnection = NIST.openConnection();
    // BufferedReader in = new BufferedReader(
    // new InputStreamReader(NISTConnection.getInputStream()));


    BufferedReader in =  new BufferedReader(new
InputStreamReader(s.getInputStream()));
    DateStatement = " ";
    TimeStatement = " ";
    while ((inputTimeLine = in.readLine())!= null)
    {
      System.out.println( inputTimeLine );
      System.out.println( inputTimeLine.length() );
      tl = inputTimeLine.length();
      if (tl > 5 ) // one of the input forms came in with a blank line
before DateTime

      {
        TimeZone = 4 ; // Eastern Time
        //  not sure of this ????
        HourAdjusted =
Integer.parseInt(inputTimeLine.substring(15,17))- TimeZone;
        if (HourAdjusted < 0){
          switch (HourAdjusted) {
            // incomplete... for hour only error does NOT include day
error...
            case -7: HourAdjusted  =  17; break; // Pacific Time
            case -6: HourAdjusted  =  18; break; // Mountain Time
            case -5: HourAdjusted  =  19; break; // Central Time
            case -4: HourAdjusted  =  20; break; // Eastern Time
            case -3: HourAdjusted  =  21; break; // Eastern Time - 1
            case -2: HourAdjusted  =  22; break; // Eastern Time - 2
            case -1: HourAdjusted  =  23; break; // Eastern Time - 3
          }
        }

        HourAdjustedStr = Integer.toString(HourAdjusted);
        DateStatement = "date " +  inputTimeLine.substring(9, 11) + "/"
+ inputTimeLine.substring(12, 14) + "/" + "20" +
inputTimeLine.substring(6, 8) ;
        TimeStatement = "time " + HourAdjustedStr + ":" +
inputTimeLine.substring(18,20) + ":"+ inputTimeLine.substring(21,23);
        System.out.println(DateStatement);
        System.out.println(TimeStatement);
        Date today = new Date();

        try
        {
          Process p3 = Runtime.getRuntime().exec("cmd /c " +
DateStatement);
          InputStream inDate = p3.getInputStream();
          int r3;
          while((r3 = inDate.read()) != -1)
          {
            p3.waitFor();
            System.out.write(r3);
          }
        }
        catch (Exception e2)
        {
          System.out.println("Here DateStatement Exception");
        }


        try {
          Process p4 = Runtime.getRuntime().exec("cmd /c " +
TimeStatement);
          InputStream inDate = p4.getInputStream();
          int r4;
          while((r4 = inDate.read()) != -1)
          {
            p4.waitFor();
            System.out.write(r4);
          }
        }
        catch (Exception e3)
        {
          System.out.println("Here TimeStatement Exception");
        }
      }
    }
  }
}


Bob

0
bherbst65 (267)
12/9/2005 6:34:52 AM
comp.lang.java.help 13340 articles. 0 followers. Post Follow

12 Replies
677 Views

Similar Articles

[PageSpeed] 14

On 8 Dec 2005 22:34:52 -0800, bherbst65@hotmail.com wrote, quoted or
indirectly quoted someone who said :

>In another programming language, I can use "processes"  to call IE and
>a specific html address .

see http://mindprod.com/jgloss/exec.html
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
12/9/2005 6:58:45 AM
Hi Roedy,
Thanks for you help. I appreciate it.

Here below is the program that was shown above in another language, now
translated to Java. Very slick how java 'seems'? to wait until IE is
loaded before inserting the additional line. This method is a lot
easier to use than an applet or fighting with a troublesome url
as noted in another recent Google post of:

http://groups.google.com/group/comp.lang.java.help/browse_frm/thread/743e63889a6881d1/e

a2f94287c074909?hl=en#ea2f94287c074909
and the difficulty the author  was having  to show the url :
"http://www.google.com/search?hl=en&q=help+me&btnG=Google+Search"

Thanks again,
Bob


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/* A runtime program to get IE
 * and then a specific htrml address
 * is  placed  into IE to complete the lookup.
 * used Win2k with NT and  jdk1.5.0_05
 */

public class RuntimeIEBttns extends JPanel
  implements ActionListener {
  public JButton bOL, bNL, bCL,bGG;

  public RuntimeIEBttns() {

    bOL = new JButton("Old Look at EE");
    bOL.setActionCommand("oldlook");

    bNL = new JButton("New Look at EE");
    bNL .setActionCommand("newlook");

    bGG = new JButton("Google Help Me");
    bGG .setActionCommand("gogoogle");

    bCL = new JButton("Close Application");
    bCL.setActionCommand("close");

    //Listen for actions on buttons bOL , bNL and bCL.
    bOL.addActionListener(this);
    bNL.addActionListener(this);
    bCL.addActionListener(this);
    bGG.addActionListener(this);

    //Add Components to this container, using the default FlowLayout.
    add(bOL);
    add(bNL);
    add(bGG);
    add(bCL);
  }

  public void actionPerformed(ActionEvent e) {
    String Str1 = "C:/Program Files/Internet Explorer/IEXPLORE.EXE";
    if (e.getActionCommand().equals("oldlook")) {
      try{
        String Str2

="http://oldlook.experts-exchange.com/Programming/Programming_Languages/Java/";

        Runtime rt = Runtime.getRuntime();
        rt.exec(new String[] {Str1,Str2});
      }
      catch (Exception e3) {System.out.println("ERR");}
    }

    if (e.getActionCommand().equals("newlook")) {
      try{
        String Str3

="http://www.experts-exchange.com/Programming/Programming_Languages/Java/";

        Runtime rt = Runtime.getRuntime();
        rt.exec(new String[] {Str1,Str3});
      }
      catch (Exception e3) {System.out.println("ERR");}
    }

    if (e.getActionCommand().equals("gogoogle")) {
      try{
        String Str4
="http://www.google.com/search?hl=en&q=help+me&btnG=Google+Search";



        Runtime rt = Runtime.getRuntime();
        rt.exec(new String[] {Str1,Str4});
      }
      catch (Exception e3) {System.out.println("ERR");}
    }

      if (e.getActionCommand().equals("close")) {System.exit(0);}
  }

  public static void main(String[] args) {
    JFrame frame = new JFrame("Runtime Buttons Demo");
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });

    frame.getContentPane().add(new RuntimeIEBttns(),
BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
  }
}

0
bherbst65 (267)
12/11/2005 6:02:30 PM
On 11 Dec 2005 10:02:30 -0800, bherbst65@hotmail.com wrote, quoted or
indirectly quoted someone who said :

> String Str4
>="http://www.google.com/search?hl=en&q=help+me&btnG=Google+Search";

this is a bad name.  First it starts with a capital letter. variables
should start with lower case.  Next is it meaningless. Call it
"googleSearch"
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
12/11/2005 8:18:32 PM
On 11 Dec 2005 10:02:30 -0800, bherbst65@hotmail.com wrote, quoted or
indirectly quoted someone who said :

>Runtime rt = Runtime.getRuntime();
>        rt.exec(new String[] {Str1,Str4});
>      }
>      catch (Exception e3) {System.out.println("ERR");}

all this could be factored:

     private void showWithIE( String url )
      {
     try {
      Runtime.getRuntime().exec(new String[] {INVOKE_IE, ,url});
     catch ( Exeception e )
       {
       System.out.println("IE failed to render "
        + url 
        + " "
        +  e.getMessage() );
       }
      }
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
12/11/2005 8:24:28 PM
Roedy,
I am puzzled why you changed my title of the Q to what it is now.

Looking at your help immediately above, there are a few more items:

1. Why go to this trouble println  System.out.println("IE failed to
render " when the error will come after mounting IE? I tried to make it
happen with  a incorrect html and the error is reported at the browser
level not at the level of the actual  URL.

2 For the error that you report with my work you mention that variables
 should start with lower case, I have made the changes and renamed them
accordingly. And I have edited the program to reflect your suggestions
about screening the URL for correctness,
however, there is an error in your gift spelling Exception which I have
corrected.
  ( Runtime.getRuntime().exec(new String[] {INVOKE_IE, ,url});
     catch ( Exeception e )
       {
Further, if an error did happen with the url it would be reported on
the IE page, not in the java program. I tried to error the url and  it
was reported on the IE page and not in the java program.

Bob

0
bherbst65 (267)
12/12/2005 2:41:50 AM
On 11 Dec 2005 18:41:50 -0800, bherbst65@hotmail.com wrote, quoted or
indirectly quoted someone who said :

>  ( Runtime.getRuntime().exec(new String[] {INVOKE_IE, ,url});
>     catch ( Exeception e )
>       {

the more serious error is the double comma.  
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
12/12/2005 3:46:27 AM
On 11 Dec 2005 18:41:50 -0800, bherbst65@hotmail.com wrote, quoted or
indirectly quoted someone who said :

>Further, if an error did happen with the url it would be reported on
>the IE page, not in the java program.

True, if all works according to plan.  But if all works according to
plan no exceptions will be thrown.  In real life it often does not.
That is why I dumped out all the relevant details. The wording is
misleading. You are right it should say something like "failed to
launch" rather than "failed to render"
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
12/12/2005 3:48:36 AM
On 11 Dec 2005 18:41:50 -0800, bherbst65@hotmail.com wrote, quoted or
indirectly quoted someone who said :

>I am puzzled why you changed my title of the Q to what it is now.

Have you ever seen the movie "The Gods Must Be Crazy".  A man manages
through misadventure to winch his Land Rover high into a tree.  His
sidekick says, "Why did you do that, Boss?".


-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
12/12/2005 3:49:51 AM
Hi Roedy,
While you are on the line about my runtime program, here is a bit of
the program rewritten:
I still have a couple of questions.
.......................
public void actionPerformed(ActionEvent e) {
    String urlEEOldlook

="http://oldlook.experts-exchange.com//Programming_Languages/Java/";
    String urlEENewLook  =

"http://www.experts-exchange.com/Programming/Programming_Languages/Java/";
    String urlGoogleSearch

="http://www.google.com/search?hl=en&q=help+me&btnG=Google+Search";
    if (e.getActionCommand().equals("oldLookAtEE")) {
      showWithIE (urlEEOldlook ) ;}
    else if (e.getActionCommand().equals("newLookAtEE")) {
      showWithIE (urlEENewLook  ) ;}
    else if  (e.getActionCommand().equals("helpmeGoogleSearch")) {
      showWithIE (urlGoogleSearch) ;}
    else if (e.getActionCommand().equals("close")) {System.exit(0);}
  }

  private void showWithIE( String url ){
    String INVOKE_IE = "C:/Program Files/Internet
Explorer/IEXPLORE.EXE";
    {
      try {
        Runtime.getRuntime().exec(new String[] {INVOKE_IE, url});
      }
      catch ( Exception e )
      {
        System.out.println("IE failed to launch url  "  +  url + " "  +
 e.getMessage() );
      }
    }
  }
........................

Question:

1. Is the "else if" arrangement ok?

2. We were on the issue of  variables and writing style..... what does
this mean:
"INVOKE_IE" ?  Is it a string or not? If it is a string then
"invoke_IE"?   If not then please 
explain. 

Bob

0
bherbst65 (267)
12/12/2005 2:14:01 PM
On 12 Dec 2005 06:14:01 -0800, bherbst65@hotmail.com wrote, quoted or
indirectly quoted someone who said :

>1. Is the "else if" arrangement ok?
It looks syntactically correct. The compiler is better at matching {}
than my eyes are.

I prefer the new line style of brace, but that's something you can
globally configure in Eclipse to flip back and forth.
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
12/12/2005 10:15:55 PM
On 12 Dec 2005 06:14:01 -0800, bherbst65@hotmail.com wrote, quoted or
indirectly quoted someone who said :

>
>2. We were on the issue of  variables and writing style..... what does
>this mean:
>"INVOKE_IE" ?  

 see http://mindprod.com/jgloss/codingconventions.html

private static final String INVOKE_IE is a constant, hence all caps.

you moved that back to being an ordinary String variable.

I find it better to collect together constants in one place where they
are easy to find rather than dotted in the code. You might as well use
the String literal the way you did it.

-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
12/12/2005 10:18:26 PM
Hi Roedy,

I will use this program that is well formed as a model for further
modifications.

For starters, enhancements will probably include imageicons on the
buttons.
URL picURL = getClass().getResource("Bird.gif");
ImageIcon icon = new ImageIcon(picURL);

I didn't include it here as it would only clutter the main thought.

You wrote:
>It looks syntactically correct. The compiler is better at >matching {} than my eyes are.

For me, it is just great to use editor that has  a connecting colored
band  to identify the start to the end of a matching pair of { }'s .
  
Thanks very much, 

Bob

0
bherbst65 (267)
12/13/2005 12:27:18 AM
Reply:

Similar Artilces:

When to use "." and when to use "!"
I'm still confused about this and I can't find anywhere that explains it properly. I have the MS book "Access 2003" in front of me and I'm reading Part 5 about VB and so on. It's telling me about how to refer to a specific database and has the example:- Dim dbMyDb As DAO.Database Set dbMyDb = DBEngine.Workspaces(0).Databases(0) but, but, but, but - what do those dots (periods, full stops, call them what you will) mean? (OK, it appears to be the same usage as C/C++/Java when referring to class/structure members, but I wish it would tell me that somewhere) ...

help with "timefmt" and "using"...
Hi, is it possible to plot a data file like the following fragment without rebuild the archive? #DATE TIME-BEG TIME-END VALUE 7/03/2001 15:15:00 16:15:00 40115 7/03/2001 16:15:00 17:15:00 39960 7/03/2001 17:15:00 18:15:00 39990 8/03/2001 09:15:00 10:15:00 39985 8/03/2001 10:15:00 11:15:00 39855 8/03/2001 11:15:00 12:15:00 40310 I need to use as X data the 1st and the 3th columns, Y the last. I've spent a lot of time to try but with no result... Thanks a lot!!! Ciao, Francesco. Francesco <odiolaspam@tin.it> wrote: > Hi, > is it possible to plot a data file like the following fragment > without rebuild the archive? Sort of. You'll have to filter the file, but you can do that on-the-fly if you're on Unix or something sufficiently like it: plot '< awk "{print $1,$3,$4}" datafile' using 1:3 For other than timefmt data, that wouldn't be so much of a hassle, but unfortunately, the strptime() function that is the bases of 'set timefmt' offers no way of ignoring parts of the input. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain. On 23 Oct 2003 09:01:23 GMT, Hans-Bernhard Broeker <broeker@physik.rwth- aachen.de> wrote: > if you're on Unix or something sufficiently like it: > > plot '< awk "{print $1,$3,$4}" datafile' using 1:3 > > For other than timefmt data...

Help for write VBA code using "Command" function and "GoToRecord" action
I working on a GIS project, with Access link which just need a little routine in VBA, but I haven't knowledges in VBA language. It's very simple, and it looks like that in a TPascal way : .... Var RecordNb : integer ; .... {Command : function of Access} .... {GoToRecord : method of Acces} Begin If Command=Null then RecordNb:=1 Else RecordNb:=Command; GoToRecord(RecordNb); End. Could someone write me how it looks like in VBA ? I don't understand what it is you are trying to do. Move to a record on a form? In a Recordset? Automate Access from another appl...

Urgent JAVA Requirement in """"""NEW YORK"""""""""
Hello Partners, How are you ? Please find the requirement below. Location : NY Duration : 8 mnths Rate :Open Job description: Java/J2EE Web Service Developer =B7 (4+ years of application development experience in Java/J2EE and Web service technologies. =B7 Experience with spring & Hibernate. =B7 Experience with J2EE Application Server (preferably Web logic). =B7 Preferable Aqua logic DSP Experience =B7 Preferable Sonic ESB Composite Service experience Experience w...

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

When to use "document" and when to use "this"
Hello all, Can anyone explain when one should use the "document" object and when one should use the "this" object? Also, is the "self" object the same as the "document" or "this" object? ...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

How can I pass "-verbosegc" to a java application which is launched by "Java Web Start"
I have a JAVA Application, which is launched by "Java Web Start". Now I want to get Information about Gabage Collction. Normally in JAVA I just set the JVM-option "-verbosegc" to activate logging. But How can I pass that option to my JVM through "Java Web Start". Is there any to set tis option whitin my ".jnlp" File ??? Thanks for any help Willi ...

when to use "conv2", when to use "fft"->"multiplication"->"ifft"?
Hi all, I am doing 2D image filtering with sometimes filter size larger than image size. I am wondering which of the following scheme is the fastest, using Matlab: 1) conv2, 2D convolution directly; 2) conv2, but decompose the filter into two separable filters and then conv2 will first convolve along X axis and then convolve along Y axis; 3) fft2, multiplication, ifft2, all in 2D domain; 4) fft, multiplication, ifft, all in 1D case and work on convolutions of separable filters along X axis and Y axis; (similar to 2, but do 1D convolution all in frequency domain). Images and filters are...

Pressing "Help" or "F1" crashes application
How is it possible that f.e. with Multimedia Configuration (\MMOS2\STPM.EXE) this application crashes (like a few others here, Mozilla or E.exe with OS2\HELP\EHXHP.HLP being two prominent ones) when the Help button or F1 is pressed on the very first page, which invokes \MMOS2\HELP\STPMH.HLP, but not when the "Help" button on the 2. or 3. page of the CD drive tab accesses MMOS2\HELP\STDLH.HLP, according to the File->Information of NewView? And apparently pressing "F1" crashes at those pages as well, if not previously the page's "Help" button...

Using "Your ..." vs. "My ..." in software and web applications
Hello, I am torn between using "Your ..." vs. "My ..." in labels for various portions of a web application. For instance, should I use "Your Home" or "My Home" when labeling a button or a link that takes a user to his home page on a particular web site? I am wondering whether there is a consensus about this, or whether there are studies related to this. Thank you. OtisUsenet wrote: > Hello, > > I am torn between using "Your ..." vs. "My ..." in labels for various > portions of a web application. >...

SGI Java issue "Exception in thread "main" java.lang.UnsatisfiedLinkError: poll0"
Hello all; I'm trying to debug an issue with a java script called, SelectSockets. It appears to be a fairly common one found on the web. I downloaded the SGI Java v1.4.1 installation from SGI's webpage and installed it using SGI's swmgr application. The installation was very straight forward and there were no errors when I installed the package. Then I ran /usr/java2/bin/javac SelectSockets.java to make the SelectSockets.class file. Then I ran /usr/java2/bin/java SelectSockets, and got the following error message: =================================================...

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net and Oracle (good to have). Req #4: Title : Java Developer (MSA Project) Duration : 6+ months Rate : open Location : NY Note : Please send your updated resume along with contact no karthik@bhaninfo.com : No phone calls please. Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

how inject "own help" in "Matlab help"
i have done create a many program and want this m file add in 1 packet to inject in Matlab "Help". thanks .... please help me regards ...

When to use "document" and when to use "this" #2
Hello all, Can anyone explain when one should use the "document" object and when one should use the "this" object? Also, is the "self" object the same as the "document" or "this" object? Bryan wrote on 23 sep 2006 in comp.lang.javascript: > Can anyone explain when one should use the "document" object and when > one should use the "this" object? IMHO: "window" is the default and top element of the DOM tree. So: document defaults to window.document. [However parent.document could mean the framse page.] &q...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"If then; if then;" and "If then; if;"
I have a raw data set which is a hierarchical file: H 321 s. main st P Mary E 21 F P william m 23 M P Susan K 3 F H 324 S. Main St I use the folowing code to read the data to creat one observation per detail(P) record including hearder record(H): data test; infile 'C:\Documents and Settings\retain.txt'; retain Address; input type $1. @; if type='H' then input @3 Address $12.; if type='P' then input @3 Name $10. @13 Age 3. @16 Gender $1.; run; but the output is not what I want: 1 321 s. main H 2 321 s. main P Mary E 21 F 3 321 s...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

Urgent Requirement for """""""""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting ...

Using "save" and "load" in GUI standalone application
Hi, In the GUI standalone application, I am trying to use "save" to save some data from the calculation, for example save data xx load data This is working OK when I am coding the GUI. However, after compiling it into a standalone application, the program stops at the points where I need to save the data. Any clues? Thanks! ...

Web resources about - Writing a application using "process" - comp.lang.java.help

Resources last updated: 3/9/2016 7:53:17 PM