eggmatters 21 Junior Poster in Training

the issue is nothing to do with JavaScript, but how the web server handles requests

This is what I was attempting to get at by adding the "text/html" content type in your ajax request. Unfortunately, I'm not too familiar with Nginx so, I can't provide much value in configuration there.

I am however, thoroughly convinced that your ajax request is either sending the wrong content type (text/txt) or none at all and Nginx is defaulting to text/txt.

For troubleshooting purposes I would not mess with the rewrite rules. They'll just complicate things. Remember that Ajax requests are redirects themselves. I would investigate the headers of your GET / POST ajax requests (in developer tools or firebug) and at the very least, rule out the content-type requested. Then, look around for resources on how Nginx handles or assigns default content types.

P.S I've had this very same issue with apache.

eggmatters 21 Junior Poster in Training

What is the content type of your request? If it's text/txt or a mime type that typically doesn't engage the PHP preprocessor, than you would see the behavior you're getting.

What happens if you add the following to your ajax? (where lformController is defined)

$.ajax({
 . . .
 contentType: "text/html"
 . . .
 });
eggmatters 21 Junior Poster in Training

Cool thanks a lot! I thought of doing that as well. I actually wound up doing just that and creating the structs objects as their own class, just like any other. That's what I should have done in the first place. OOP is all about where you put things. For the IDE, I think you're right. The tooltips and gui extensions are grabbing their meta-data either from global structures defined in main or your header files.

eggmatters 21 Junior Poster in Training

Umm, false alarm. That is exactly how it's done.

eggmatters 21 Junior Poster in Training

Hi all,

My cpp is rusty as all get out and I'm wondering why this doesn't seem to work. I've basically created a .cpp file with all of the structs and lower level data types in it. One of these is an enumerated type. The file. structs.cpp is as follows:

#include <cstdlib>

using namespace std;

struct pos
{
       int x;
       int y;
       pos(int i, int j) 
       {
               x = i;
               y = j;
       }
};

enum Resources {wood, stone, metal, crops, animals, none};

My compiler is Dev-C++ v4.9.9.2 for windows. Other files that include structs.cpp can see the pos struct (or any other struct for that matter) but nobody can see the enumerated type. The same applies if I place it in my main.cpp before

int main(int argc, char *argv[])

Since the pos struct is visible, why isn't the enum? anyone? (I can workaround to just create a struct to contain the enumerated data and assign name value pairs but - I am curious as to why enums don't work. Thanks!

eggmatters 21 Junior Poster in Training

I posted this on Oracle Forums to the sound of crickets chirping. This question entails more Oracle specific tasks then java but since my code is in java, here goes"

Hello,

I have a java package where I am attempting to implement a database Change notification registration and listener. I can create a registration but my listener fails to notify the operating thread when a change occurs on the registered table. For my example, I can successfully register a change notification on a table named "<user>.CUSTOM_TESTER". When I call getTables() from my registration object, it returns: "<user>.CUSTOM" omitting the rest of the table name following the underscore. I can only assume that the listener is awaiting changes on a table that does not exist. Is this a bug? Is there some implementation detail I am ommitting here? The following code implements the issue I have just described:

OracleConnection conn4 = dbConnect(dbURL, dbUser, dbPwd);
Properties prop = new Properties();

prop.setProperty(OracleConnection.DCN_NOTIFY_ROWIDS,"true");
prop.setProperty(OracleConnection.DCN_QUERY_CHANGE_NOTIFICATION,"true");

DatabaseChangeRegistration dcr = conn4.registerDatabaseChangeNotification(prop);

try{
// add the listener:
DCNListener list = new DCNListener(this);
dcr.addListener(list);

// second step: add objects in the registration:
Statement stmt = conn4.createStatement();
// associate the statement with the registration:
((OracleStatement)stmt).setDatabaseChangeRegistration(dcr);
ResultSet rs = stmt.executeQuery("select phone_num from custom_tester where phone_num = '5551239876'");
rs.next();

String[] tableNames = dcr.getTables(); // wrong table named returned here

for(int i=0;i<tableNames.length;i++) 
System.out.println(tableNames+" is part of the registration."); 

rs.close();
stmt.close();
}
catch(SQLException ex) . . .

More code is available but is essentially adopted from here:
http://www.filibeto.org/sun/lib/nonsun/oracle/11.1.0.6.0/B28359_01/java.111/b31224/dbmgmnt.htm

eggmatters 21 Junior Poster in Training

Hi all,
UDATE:
Let's not hastily rush into this. I may have found my problem. BTW, my result set is populated with all of the required data.

Yep. I have found it. Will mark as solved. What I didn't and never had to anticipate with my query was the possibility of a null value. I was testing a different data set which did just that. This is perfectly acceptable for the DB constraints, it just is rare. Sure enough, when the table populates, it will only display the fist set of valid values returned by said row. Oracle Sql Developer catches this and populates that field with the string "(null") I will do the same.

eggmatters 21 Junior Poster in Training

Hi all,
UDATE:
Let's not hastily rush into this. I may have found my problem. BTW, my result set is populated with all of the required data.

I have a custom renderer which renders table cell values from a query. The result data is populated into a 2 dimensional array. Then it is rendered to fit into a Jtable and accompanying Frame. My application calls this class for 3 different tables. One has lately started throwing exceptions from getClass an override from AbsractTableModel:

@Override
        public Class getColumnClass(int c) {
            return getValueAt(0, c).getClass();
       //Exception thrown here

        public Object getValueAt(int row, int col) {
            return data[row][col];
        }
       //Because a null was populated here.

This leads me to believe that my jdbc connection isn't returning data fast enough to populate the data[][] object. Will step-through-debug to pinpoint the issue. The table will recover from the exception and display 3 or 4 values from one row. Many rows may be returned. Other days it works fine. Other queries call the same overriden table model, renderer, and data[][] object, without issue. Those queries only contain a handful of data however. The query that bombs actually isn't very top-heavy. It will return only a handful of records as well.

Also, I can run oracle sql developer from my desktop (the same location as the application) and return accurate results from the same query.

Let me know what code you will need to see in addition to this. There's a lot …

eggmatters 21 Junior Poster in Training

Hey there, I'm getting ready to release my Beta version of a java project you've all been so helpful with. There is one problem though. I haven't the foggiest idea how to package the jnlp. Where do the compiled libraries reside? Are they part of a binary? What is launched from the web? What is launched from what is launched from the web? Do I need a remote repository for my code or jars? I developed this in Net Beans instead of Eclipse as I wanted to use the Swing IDE pallete design functionality offered by NetBeans. Looking up NetBeans help on Building a JNLP application merely creates a JNLP java icon which doesn't seem to do anything. Is there a good tutorial written about this whole process that someone can direct me to?

eggmatters 21 Junior Poster in Training

Hi EggMatters,

To make your code work on either Windows or *nix platforms, use the constant DIRECTORY_SEPARATOR in place of a slash. For example:

$stuff = file_get_contents("some_dir". DIRECTORY_SEPARATOR."another_dir". DIRECTORY_SEPARATOR.$filename);

The constant DIRECTORY_SEPARATOR represents "/" on *nix systems and "\" on Windows systems.

Excellent suggestion. Thanks!

eggmatters 21 Junior Poster in Training

Hi all,
I am rather new to PHP, but have a fairly ok grasp of software design. My question arises from the fact that I'm getting ready to deploy some scripts etc. to my website which is hosted on a *nix type server. My home / work computer that I'm developing on is windows. My apache server is: Apache HTTP Server Version 2.2 running on my windows XP sp2 desktop. So when I port all of my php code over, do I have to changeall of my directory slashes from whacks to slashes when I do that?

eggmatters 21 Junior Poster in Training

Oh so you don't think *nix is not just a bunch of hacked together programs??? After I installed Ubuntu and Fedora 11 they both went to their respective web sites and downloaded updates. Even after that I couldn't get the sound to work right, but I found a tutorial that explained how to uninstall something (I forget what) then download something else. It was quite a lengthy tutorial -- but worked. Even after all that I still can not play movies that are on DVD, I understand that's because the drivers are not installed with the os.

I have Windows 7 Home Prem and everything worked perfectly after installing the os. Perfect sound, plays both blue-ray and normal DVD movies, youtube videos (with sound ;)

Now tell me who has the hacked operating system.:P

Lol, I'm not going to argue with you there. I've had all those "issues" as well. Linux is not marketed as a "plug-and-play" system. Until somebody can provide a distro that does that, it will not be marketable at all. But, once you get all of that to work, you will have a much more stable, secure and efficient OS. Hands down. Linux is not for the faint of heart. It's for people who A. Aren't afraid of getting their hands dirty and doing some low-level work, installing drivers, configuring hardware etc. B. People (like me) who could use some humility.
I mean, put together a bunch of ad-hoc components, get your elbows dirty and …

eggmatters 21 Junior Poster in Training

Dont immediately discount things before trying them, and also i bet your girlfrends laptop cost a lot more money then you are running the XP system on. If you payed the same amount of money as you did for the mac i think you would find it would be closer to 35 - 40 seconds, that was what it was for me on a $500 netbook.

Um, did you happen to read the part about my Linux box taking 45 seconds. I paid $100 for the box, the software was <gulp> free.
And not discounting things before trying them - listen, name one product that Microsoft has put out that isn't a complete hack. The only one I can think of is solitaire. Why would I want to give my loyalties to a company with such a poor track record with quality? Especially when a faster alternative is free? If I go out and by a pair of shoes from Nike, and they fall apart after 2 weeks, and then I go out and by another pair of shoes and they fall apart - How many pairs of crappy shoes do I have to buy, hoping that Nike can make a decent product. We've been dealing with crappy products from microsoft for the last 18 years! They should have just stuck with DOS.

eggmatters 21 Junior Poster in Training

I tried the following code which is inline with the pseudo code in the original code which works fine.
I dont see any errros in the pseudo code.

int count = 11;
		int x = -1;
		if(count > 10) {
			while( x < 0) {
			try {
					x = x - 1;
					System.out.println("inside while ");
			      } catch (Exception ioe) {
			         System.out.println("IO error trying to read your name!");
			         
			      }
			}
		}

The code wasn't in "error" so to speak. He was asked to find the inefficiencies with it. When you ran your program, how did you end it? Did the program exit gracefully?

eggmatters 21 Junior Poster in Training

Well, you seem to know a lot more after 2 years than I did. As a comparitor, we typically know how operators behave on primitive types. But I think we both have the same understanding when the types are complex. An equals sign can't "magically" grab all of the data an object has and figure out if they are equal or not. That has to be implemented somewhere.
I was just digressing more out of boredom than anything. I guess I'm like a baseball purist when it comes to programming. Plus, 98 percent of all my coding errors come from improperly implemented loop conditions. As a matter of fact, that reminds me. I have some bugs to clean up. Hopefully LKH figured out how to implement his / her multiplication table.

BestJewSinceJC commented: I agree; his strategy logically makes sense, but doesn't work in Java. != doesn't call equals() +4
eggmatters 21 Junior Poster in Training

In c++ the "!=" operator when used with container from std does not compare address like the "==" in java ( at times), it only compares
the values. The standard C++ library was implemented with generic in
mind.

Well, if that is the case, those operators would have had to have been overloaded for those operations, otherwise the comparitors would compare addresses. I would have to go and look at the library code, (I use DevC++) to check and see if that's the case. I'm pretty sure that for any object regardless if it's in a collection or not will have to have the comparitors overloded in addition to providing a deep copy constructor. Come to think of it, if you call something to the effect of:

someCollection<someClass> someObject[] = new someCollection<someClass>()[2];
someObject[0] = someData;
someObject[1] = otherData;

if (someObject[0] != someObject[1])
{
   std::cout << "AHHHHHH!!!! Run for your lives!!! ";
}

that operator will be called from the overloaded operator defined in someClass, not someCollection. What I was saying, without knowing if someObject overloads !=, you have no guarantee that you are comparing someData and otherData. If not you will be comparing the dereferenced addresses of each object. So in java, this is one of the reasons that all classes derive from Object. That way, they can implement the equals() method to ensure that you are comparing by value and not by reference.
Also, c++ calls generic types template types. But you knew that.

eggmatters 21 Junior Poster in Training

hi eggmatters, thanks for your reply.

but that is not what i am looking for..

this involves some kind of biwise operation.

everything together should become a 16byte string.

Ok, you've lost me there. you are creating strings. Strings are arrays of characters. Characters are bits. Ultimately, anything you code is a 'bitwise' operation. The term 'bitwise operation' explicitly means a comparison of two strings of bytes. Namely XOR and XAND.
Could you be more specific about how your data is typed? is it all character arrays? is it that you need to convert your ints to bytes? Do you want to convert all of your data into a hexidecimal string? Do you have sample code or some type of data structure that you can provide?

eggmatters 21 Junior Poster in Training

Load on startup means: Power on to: Desktop displayed, Icons loaded, system in idle process, all daemons / devices running, connected to LAN / Internet.

Time it takes my Linux box to load on startup:
~45 seconds to one minute (and it has issues)
Time it taks my gf's Macbook to load on startup:
30 seconds.
Time it takes my IBM thinkpad T61 windows XP sp2 to load on startup:
7 - 15 minutes.

c'mon, is windows 7 going to be any faster? Are their crappy applications (Office?) going to run any smoother or glitch free? Have they been compiling all of their "error reports" from crashed applications and really trying to work on a more stable system? Maybe if they knew what they were doing. The most stable product Microsoft ever released was win2K and I'm only a fan of it since it was the least error prone product they've put out. It's not better than Unix, it's not better than OSx or leopard or snow leopard - whatever mac runs now. I mean, fool me once, shame on you, fool me like, eleven times . . . .?!

eggmatters 21 Junior Poster in Training

i'm a junior poster in training! I'm a junior poster in training!

eggmatters 21 Junior Poster in Training

Lol, I loved the comment about the guy who thinks it's a precursor to the world ending. In the grand scheme of things, It's a somewhat common event, although, still spectacular. If the earth is 6 billion years old and has been covered by oceans for 2.5 billion years. Typical lifespan of an ocean is 100 million years, that's 25 oceans we've had on this planet. It's kind of like one of those baseball statistics "This is the seventh player in major league history to fly out while having his pants fall off"
Don't get me wrong, it's a massively cool article.

eggmatters 21 Junior Poster in Training

however, if one was to search for a phrase "google better than limewire youtube" that may be interesting. I personally have found a middle of the road option, mp3Panda which i pay about a nickel per song and a quarter for albums I download. i loaded $20 in February and have like 15 left. I think it's fair compromise. BTW, whenever you DL illegal music via file sharing or bit torrents, you are just asking - begging for malware. I don't think it's worth it, although I believe that the record industry is wrong for charging for downloads. My rationale is, CD's are price-fixed because they are greedy bung lords who give anywhere from .5 to 3 cents on the dollar to the artists who feed their BS business ethics. I would happily pay for music if went directly to the artist.

eggmatters 21 Junior Poster in Training

What have i been smoking? I probably looked at that icon 20 times yesterday. Thanks!

eggmatters 21 Junior Poster in Training

In Design mode in NetBeans IDE, I had a palette with all of my AWT and Swing controls and some netbeans that I can drag and drop onto the Jframe I'm designing, I accidentally closed it. I am not seeing a menu option anywhere to add that palette back as an IDE pane. there's tools->palette, but that just brings up the set of controls for a specific component.

eggmatters 21 Junior Poster in Training

IF count > 10 THEN
WHILE x < 0 DO
INPUT x
ENDWHILE
ENDIF

My understanding:
Count is evaluated. If count is <10, the app moves onto the next section. If count is > 10, X is evaluated. Until x is <0, the user will keep being prompted to input x. Once they input x>=0, the loop finishes.

Also, what I'm seeing is that if count has an inital value less than 10, it looks like it will stay that way. Look at the code again and ask, "How will my final condition (count being greater than or equal to 10) be satisfied? Because I don't see it in this sample. (hint: where is count incremented?)

eggmatters 21 Junior Poster in Training

cast your IP address as a string if it isn't already. Cast your ints as Int objects, then you'll just need to concatenate them:

Integer one = integerone //your initial value;
Integer two = integertwo
Integer three = integerthree
String myChunk = ipstring.concat(all of your Ints to strings);

Is that what you are asking?

eggmatters 21 Junior Poster in Training

interesting point. I haven't seen the non-equals operator used as a loop conditional before. I have to admit that what you said makes sense. I would have never thought of it in that way before. But . . . what guarantee do you have that you are actually comparing values in c++? wouldn't a statement like objecta != objectb be interpreted as: The address where objecta resides is not equal to the address where objectb resides?
Besides, c++ allows you to overload your operators so there is no ambiguity. The classes you are talking about may have just implemented that.
But as far as comparing primitives? Sure != 5 looks hunky dory. I've been using comparison operators for the last 15 years, so I don't thnink I'll all of the sudden switch though.

eggmatters 21 Junior Poster in Training

Ahh ok. Well, what I can tell you is that even though JAR and EXE files are both binary, the JARs run on the JRE which (correct me if I'm wrong) even has dedicated hardware. I understand your hands may be tied but maybe you may want to port your code over the the .NET architecture if you can't run on a JRE. There is a decent free C# compiler provided by microsoft and the diffferences are subtle.
If that is not an option, then you really may be painting yourself into a corner. The way the InputStream is implemented in your exe is obviously different then how it is implemented in your JAR. I know that I couldn't alter the linker to make it work, but that would need to happen, or override the inputStream class in such a way the exe file works. But who knows? There may be an easier way. Let me know if .NET is an option for you.

eggmatters 21 Junior Poster in Training

Your connection appears to be refused:
java.net.ConnectException: Connection refused: connect
I tested your url, and I think it worked. I just wrote "Hey there" as the message arguments, so you may get an email with that or maybe not. I would attempt a step-by-step debugging of your code and try to determine exactly where the exception was thrown.

eggmatters 21 Junior Poster in Training

Ahh yes that worked excellently. The only issue that I had was declaring a datatable globally in the main frame. I had already created the data table in a method in main. It seemed a bit excessive to have such a large object to merely transport a few bytes of data. Lol, too late to refactor the code though. It works and I learned how to implement an interface which I am pleased with.
So I will mark this thread as solved. Thank you much. Your code sample was much more lucid than any of the Sun tutorials or documents (too abstract) as far as the implementation I originally had, there was a pre-defined Interface (ListSelection, I think) an event handler (ListSelectionEvent) But there wasn't an add method defined in the ListSelectionEvent that suited my needs. There probably was but it didn't jump out at me from the java docs. At any rate, if you're bored, I have one other question:
In the DataTable class, I have a method with a signature:

public void addSelectionListener(SelectionListener listener)

And it is called from Main thusly:

dataTable.addSelectionListener(this);

So it is my understanding that in this context the this pointer is a pointer to the main frame. The main frame implements SelectionListener but it also contains all of the objects implemented in the main frame (viewports, buttons, text fields etc.) this seems like a type incompatibility. Yes, the required type data is there, but how does java resolve that from …

eggmatters 21 Junior Poster in Training

Here is a "bare bones" mockup of how such an event model can be implemented. I've retained your names so it might be a little clearer

import java.util.ArrayList;
import java.util.List;

public class MainFrame implements SelectionListener {

    DataTable dataTable;
    String mainData;

    public MainFrame() {
        dataTable = new DataTable();
        // Add this as a listener to the DataTable objectd
        dataTable.addSelectionListener(this);
    }

    /** simulate the events and notification */
    public void run() {
        // initial state
        mainData = dataTable.getData();
        System.out.println(mainData);

        // data table gets updated (in reality this represents a user action,
        // but I have to simulate here)
        dataTable.updateSomeData();

        // verify our new data
        System.out.println(mainData);
    }

    /** implementation of SelectionListener interface */
    public void selectionChanged() {
        // get the updated data
        mainData = dataTable.getData();
    }

    public static void main(String[] args) {
        MainFrame mFrame = new MainFrame ();
        mFrame.run();
    }
}

class DataTable {

    private String someData = "initial data here";
    
    // list of listeners
    private List<SelectionListener> selectionListeners = new ArrayList<SelectionListener>();

    /** Add a SelectionListener */
    public void addSelectionListener(SelectionListener listener) {
        selectionListeners.add(listener);
    }

    /** notify SelectionListeners of change*/
    private void fireSelectionChanged() {
        for (SelectionListener listener : selectionListeners) {
            listener.selectionChanged();
        }
    }

    public String getData() {
        return someData;
    }

    /** This method just represents some operation that alters the data */
    public void updateSomeData() {
        // doing stuff...
        someData = "new data here now";
        
        // done, so let all the listeners know
        fireSelectionChanged();
    }
}

interface SelectionListener {

    void selectionChanged();
}

That's how I've come to understand it. I'm already implementing a predefined selection …

eggmatters 21 Junior Poster in Training

. Your main frame can then query the info that it needs.

I think you understand what I was getting at pretty well. It sometimes is difficult asking about something you don't really know too much about. But essentially the quoted element above is the meat and potatoes of the matter. I need to figure out how the main frame can do just that. I've already implemented a selectionListener in the data table class, that's how the selected values get populated in the array. I have an accessor method in the data table that can pass the array, but here is the deal, my main frame can't explicitly know when that array is populated with the data it needs that can only happen after the user has selected the button on the data frame. So when that event occurs, I want to somehow tell the main frame, "I'm done here, go ahead and call the accessor method if you want to"

eggmatters 21 Junior Poster in Training

Not really sure how to phrase the question. Essentially my issue is this:
I have a Form that when the user clicks a button, it invokes a JFrame that populates a datatable with a sql query. The datable frame also has a button. The user can select a cell in the frame and then press the "Select" button. What I need to have happen is to somehow populate a text field with a value from the selection on the parent form. The datatable is invoked from a method in my Main Form class. There is an action event listener associated with the button on the datatable form. Provided is the code from Main:

private void MTHSelectAlertTypeActionPerformed(java.awt.event.ActionEvent evt) {                                                   
// TODO add your handling code here:
    showPreviousAlertTypes();
}                                                  



private void showPreviousAlertTypes()
{
    String query = "select distinct dc_alert_type_id from  custom_alert order by dc_alert_type_id";
    String labels [] = {"Alert Type", "Select" };
    ArrayList selections = new ArrayList();
    
    JFrame frame = new JFrame("Existing Alert Types ");
    //DataTable is a class I defined based on the Sun Tutorial on how to create Swing Tables. It is pretty robust and I am happy with it.
    DataTable existingAlertTypesTable = new DataTable(query, labels, conn, "Existing Alert Types", "Selections", true, frame);
    //Draw and render the frame:
    existingAlertTypesTable.setOpaque(true);
    frame.setContentPane(existingAlertTypesTable);
    
    frame.pack();
    frame.setVisible( 
}

So that's the calling function from Main. I have a public action event associated with my button. All of the values passed in to the constructor are necessary to render my table with the required …

eggmatters 21 Junior Poster in Training

I have a list like this:

name1: group1
name2: group4
name3: group1 group2
name4: group4
..........
..........


I wish to invert this list, and make it look like:

group1: name1 name3...
group2: name3
group4: name2, name4
...........
...........


Can somebody offer at least a psuedo code?
Thanks

Cool problem. Can you post the code that shows how your list is structured? If it's a hash then I would create an alternate hash and figure out how to assign the names to it.

You basically want to emulate a SELECT DISTINCT clause in Sql to get your groups. Maybe create an array that holds all of the distinct names, add a name to the list if and only if it doesn't exist. So your code may look something like:

# this will be part perl part pseudo code:
@groups;
$distinct_flag; # a flag to see if we have a distinct value in an array
while (($key, $value) = each(%list)){
# where key is name and group is value
# so here we want to run through our groups array and see if our value is in it:
foreach $group (@groups)
if ($value ne $group)
{
   $distinct_flag = "true";
}
else 
{ distinct_flag = "false"; }
} # end foreach
if {distinct_flag = "true" }
push (@groups, $value}
} #endwhile

so now that you have those lists. Use a variation on the above code to go …

eggmatters 21 Junior Poster in Training

Model an external formal grammar based on how you want your data structured and tell perl to perform operations on that grammar based on the rules you've created.

eggmatters 21 Junior Poster in Training

Hey there,
As with almost any algorithm, you want to define a base case. Also you want to have at least one testable condition, and then you need at least one exit condition. So . . . your exit condition will be :

for all N:
     what needs to be known for all N? (hint: it's in the last sentence of your question. Also, you may want to introduce another variable here, call it P maybe to stand for something like . . . maybe a phone call.

Your base case is probably the most important as it is the first element in the formation of your algorithm:

Base Case:
N = (what should N equal?)
What is guaranteed to happen when N equals that number?)

And finally, your testable condition. This will be a set of true or false statements assigned based on whether or not assumptions are proven about your statement. When or if they are not met, something needs to change in order to attempt to satisfy the problem. I know this sounds text bookish, but base case thinking helps give you a starting point to flesh out the algorithm.
In short you have a set of N and a set of P for each N represents a message and a person. Basically, P represents the cross product of N onto itself. You can make the algorithm even more robust to determine what needs to happen if each N contains K messages.

eggmatters 21 Junior Poster in Training

Hi,

Thanks for the reply.

I had one doubt. Suppose for example id string is like this:

$str=" AB  - Thromboxane plays an essential role in hemostasis, regulating platelet aggregation and vessel tone. TP - beta- isoforms that are transcriptionally regulated by distinct  Prm1 and Prm3, respectively";

The output should be like this:

AB -  Thromboxane plays an essential role in hemostasis, regulating platelet aggregation and vessel tone. TP - beta- isoforms that are transcriptionally regulated by distinct  Prm1 and Prm3, respectively.

But the output is not like the above one:

TP - beta- isoforms that are transcriptionally regulated by distinct  Prm1 and Prm3, respectively
AB - Thromboxane plays an essential role in hemostasis, regulating platelet aggregation and vessel tone

Actually the whole paragraph (sentences) belongs to AB Tag only not two separate tags as TP and AB its under only one tag i.e AB.

Finally How to get the output as below??

AB - Thromboxane plays an essential role in hemostasis, regulating platelet aggregation and vessel tone. TP - beta- isoforms that are transcriptionally regulated by distinct  Prm1 and Prm3, respectively.

How can i get the desired output?

AB , AD are the main tags so the information at the beginning of the tag i.e only AB - , AD - has to be parsed not the sentences which contains TP-beta- isoforms should not be parsed.

Regards
Archana

Hmm, the first question you will be asked is to provide the code you used to parse the string mentioned above. But also, I …

eggmatters 21 Junior Poster in Training

I am working on an assignment and I need a bit of help. I am using a double linked list to find roots of polynomials, the list has a trailer node only. I can't seem to get it to create a list. I figure I am just missing something small or not understanding a small part.

public class Polynomial
{

	private Node top;

	public Polynomial()
	{
		Node trailer = new Node("","",null, null);
		top.setNext(trailer);

	}
}
class Node{

	private double coef;
	private int degree;
	private Node next;
	private Node prev;

	public Node(double coef, int degree, Node newNext, Node newPrev)
	{
		this.coef = coef;
		this.degree = degree;
		next = newNext;
		prev = newPrev;

	}
	public void setNext(Node newNext)
	{
		next = newNext;
	}
}//there is more code in the node class, but is not being used yet

//this is the main method that creates the polynomial class(which is the linked list)
public static void main(String[] args)
{
	Polynomial poly= new Polynomial();

	poly.set(2.0, 3);

}

the problem seem to happen when I try to create the new Polynomial, " Polynomial poly= new Polynomial();". I get the error

Polynomial.java:8: cannot find symbol
symbol : constructor Node(java.lang.String,java.lang.String,<nulltype>,<nulltype>)
location: class Node
Node trailer = new Node("","",null, null);

I know I'm passing 2 strings, I'm not sure how to make this Node empty, since it stores a double and an int.

The signature of your node is still expecting 4 arguments whether or not you've specified them as null or not (what do they do …

eggmatters 21 Junior Poster in Training

One last question that has me completely stumped.....what call do I need with the "()" to have grab the correct data?

Are you asking about the argument for displayText.setText? I would suggest formatting a string, As of now, You're printing to stdout with:

System.out.println("\nBowling Sheet for " + name);
for (int i=0; i<=currentframe; i++){
System.out.print("Frame " + (i+1));
System.out.print(" Ball 1: " + frames[i].getBall1());
System.out.print(" Ball 2: " + frames[i].getBall2());
System.out.println(" Frame Score: " + frames[i].getFscore());
}
System.out.println("Extra Ball: " + extraball);

So instead, create a string called output string and append your display output to it.
Something like:

String outputScores = new String();
outputScores =  "\nBowling Sheet for " + name;
for (int i=0; i<=currentframe; i++){

   outputScores.concat("Frame " + (i+1) + "\n") // You will need to convert your int i to a string though. 
   outputScores.concat(" Ball 1: " + frames[i].getBall1() + "\n")
// and so on, 
}

then after the extra ball statement, just call displayText.setText(outputScores) . That should work.

eggmatters 21 Junior Poster in Training

I have to make a psuedocode or a flowchart to create a multiple-control break program.

The Specifications:

You are given an input file that contains the following information:

* Title
* Author
* Category
* Publisher
* Price
* BookCity
* BookState

Produce a report that totals the number of sales in each city and then in each state.


Please help me with this ASAP.....
Thanks.......................

Here's a method to learn how to do this:
Ask yourself: What is the necessary data above to satisfy your output conditions?
Write it down on paper, the necessary fields from your input file.
Write a test case of sample input data that satisfies the input file requirements.
Using the necessary data, draw a box around your input statements that satisfy what you wrote down in step one.
Draw lines connecting the boxes, label the lines with the actions required to satisfy output conditions, label recursive actions with a separate box and a circular line stating loop conditions if necessary.

Re write your sample data "flowchart" into something more generalized.

eggmatters 21 Junior Poster in Training

Ok...now you have lost me. I thought it is defined and implemented within loadData.

displayText is a private data member of your Bowling class:

#
class Bowling extends JPanel{
#
// create GUI objects
. . .
    private JTextArea displayText;

That is where it is defined.
As far as I can tell, displayText isn't implemented anywhere yet. Your loadData method calls printSheet, which by the way your code is desinged, seems like the ideal place to actually display your text. So, all you need to do is format a string to display data within print sheet (Instead of your println calls) and then just call displayText.setText(your_formatted_string).
Test it to make sure it works by stubbing out your output lines in printSheet and just call displayText.setText("Making sure it works") so that you know you're on the right track.
You're code looks good, and well formed. You should be able to tackle this with ease. Good luck!

eggmatters 21 Junior Poster in Training

I like this but technically it's supposed to happen within the public void loadData area.

Right, that's where you've defined the displayText pane. Then implement it there instead of main.

eggmatters 21 Junior Poster in Training

. If I can get the program to at least load the info into the gui text box I can finish everything else up.

Any help would be great.

Howdy, without delving too deep into your code, but looking at the question you've submitted, your output is resolved in the printSheet Method right? So you've set your output to stdOut using the system.out.Println methods. To display that text in a text field is pretty easy. Replace your println methods with a formatted string. Use concat and other formatting methods to create newlines etc.
You have created a textbox called displayText which I am assuming is where you want to display your data. So, set your formatted string as a private data member of your Bowler class, create an accessor method called getScores or something like that. Have it return a String object and simpy return your formatted string. Use the setText method for your displayText object, passing it the string. So you will want to do something like:

//in Bowler:
private String scoreText; 
. . .
//in Bowler.printSheet:
printSheet( . . .) {
//format your output string (scoreText)
}
public String getScores()
{
return scoreText;
}
//in Main:
displayText.setText(b.getScores());

Provided that your class algorithm is correct, it should work. I suggest stubbing out printSheet and just set scoreText to a constant string like: "Testing the text field here" and making sure that it will display, then start working on formatting your string. Godd luck!

eggmatters 21 Junior Poster in Training

Also, I think it should be noted that the moderators here frown upon folks writing out the answers to questions in code. Hash implementations and and just about anything else in Perl are pretty well documented online.

eggmatters 21 Junior Poster in Training

To make sure the algorithm is a valid solution to your problem. Type code based on your algorithm to see if the algorithm actually works in a real program. If it doesnt work, the algorithm is flawed and must be re-written.

Also, more formally, an algorithm must satisfy 2 sets of conditions. Inital conditions and final conditions. The set of initial condtions may be null. There must be one member of the set of final conditions. An algorithm is a well-formed set of n-procedures that satisfies the final condtions. For example, we have an algrorithm:

Count to 3. 
initial conditions: none
final conditions: number 3 is reached:
steps:
   initialize count to 0;
   increment count;
   is count equal to 3?
   if yes STOP
   if no, go to step 1

Very trivial, very easy to validate, but it helps to think about these things formally as you continue further into CS.

eggmatters 21 Junior Poster in Training

There are lots of different compilers for the same os too -- its called competition.

JBennet pretty much summed it up. The final result of a computer program is a binary list of bits read by the OS and processed by the CPU and associated devices. Operating Systems define specific ways in which that data should be read.
I think an easy to grasp example is how an OS stores Data. This would be the FileSystem. Each OS writes files with a header containing meta-data called an i-node. Files written in a different OS would have different I-nodes and therefore, impossible to read properly. A compiler is a set of files and a program is a set of files. For a compiler to correcly associate the data correctly, those files should be written in - for the propper OS.
Most OS code is written in C since it is less painful to write then assembly but low-level enough that you can do specific kernel-level operations.
Another interesting thing to note is that, compilers don't necessarily have to be tied to a specific OS The Church-Turing thesis states that any computable function (i.e. a program) can be computed by a turing machine (a theoretical computer). This means that any software, theoretically, can run on any machine. This is how emulators work. If you've played MAME games or perhaps downloaded an amiga chipset emulator. This is also why OpenGL runs system independantly. It's not that compilers have to run …

Rashakil Fol commented: rambly -1
jbennet commented: dont think this deserved a neg rep, dont think it deserves a + either but this should balance it out +21
eggmatters 21 Junior Poster in Training

try something like:

$tcount;
$acount;
$gcount;
$ccount;
foreach $letter (@DNA)
{
   if (($letter eq "t" ) || ($letter eq "T"))
   {
         $tcount++:
}
and so on
eggmatters 21 Junior Poster in Training

_base(const std::ios_base&)' is private
manager.cpp:18: error: within this context.

I don't think your problem is on the stream. It may be, but look at your error. Obviously, the entirety of it isn't applicable but you should have some insight as to what caused it at the top. Check line 18 of your code. It seems like you are trying to access a private class member. I see you have no access designation for your clients list (vector). Also, could you provide which line of code is line 18 in manager.cpp? That seems to be the problem child. It looks like the vector class is not liking the object passed to it. What happens when you call:

clients.push_back(c);

instead?

eggmatters 21 Junior Poster in Training

Firstly, your for syntax is incorrect, for clarity, enclose your loop conditions in brackets:

int count = input.nextInt();
   short[] grades = new short [count];/// array
   
   System.out.print("\nPlease enter the grades one at a time, pressing enter "
         +  "after each value.");
   for (int x = 0; x < count; x++)
   grades[x] = input.nextShort();

}

Should look more like:

for (int x = 0; x < count; x++) {

   grades[x] = input.nextShort();
}

Ok so now you have a global variable in main called "grades" which is an array of positive whole integer values. You've done the hard part. So you have a method:

public static string[]gettingAverage()
{
int temp = n1
        to
}

So you need to figure out how you can use this method to calculate the averages. You will need to give your method access to your grades[] array. Also, why is it returning an array of strings (by defining it: public static string[])? Should it return a number that represents an average perhaps?

At any rate, re-write your function "gettingAverage()" to be able to accept an argument (Let me know if you need help with that) the argument should be - take a big guess - your grades array (and its size).

You've already demonstrated that you can loop through an array and perform an operation on it's elements, so implementing that to determine an average should be no problem for you. Good luck!

eggmatters 21 Junior Poster in Training


You can find examples of both in the Swing tutorial for using JTable:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

Thanks! That tutorial was very helpful but was also the reason why I posted this in the first place. In the Sun tutorial, they add components and listeners for objects created outside of the data. There are checkboxes and radio buttons that fire events. The only event fired within the data table itself are cell editing events. I used that code as a basis for my table model very successfully and am pleased with that tutorial.
Where my question arises, if you run the jnlp, you can select checkboxes in the table data, and they fire events, but the event that is fired is no different than any other cell selection. It makes no difference if it's a checkbox, string or other object / component.
So what I did was add constraints on which selected cells (columns in this case) fired which events. I suppose I could call getColumnClass as well and if it's boolean, handle it that way. Either way, it works as intended, except the actionPerformed method isn't fired from a cell selection event, not sure how to make it do that, but it's ok, I have it working well enough at this point

eggmatters 21 Junior Poster in Training

That's quite alright, maybe some other time I will investigate it further. I merely placed constraints on what will happen when a cellSelection event occurs by using getColumn(). If it matches the columns that are checked, then it adds a value to an array. That is all I need basically. As far as phrasing the question, it was tough to know exactly what it was that I needed.