We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › custom function ignored sometimes
Page Index Toggle Pages: 1
custom function ignored sometimes (Read 334 times)
custom function ignored sometimes
Aug 30th, 2006, 5:56pm
 
hi all

i have an app which adds dead links to a database. their is a function called write() which writes the current status of the app to screen but it only works at certain points in the code and i can't figure out why. most noticeably when i first click on the "engrave" button it doesn't come up with "validating link..." it just completes everything and then prints the final status to screen ("can't open db" or "site engraved") . any help greatly appreciated, here's the offending code:

Code:


import SpringGUI.*;
SpringGUI gui;
FileWriter file;
String site;

void setup() {
size(352,123);
background(0);
gui = new SpringGUI(this);
gui.addTextField("myTextField", "Please enter deceased link here and click ENGRAVE.", 10, 10, 330, 22);
fill(150);
PFont font;
font = loadFont("RotisSer.vlw.gz");
textFont(font, 30);
textAlign(CENTER);
text("ENGRAVE", 176, 70);
fill(200);
text("ENGRAVE", 176, 71);

}

void draw() {
;
}


void mousePressed() {
if (overRect(100,40,152,40)) {
site = gui.getText("myTextField");
write("Validating link...");//doesn't work?!

if (validLink(site)) {
site = checkableLink(site);
if (deadLink(site)) {
if (site.equals(lastSite) != true) {
//PHP:
boolean worked = postNewItem(parameter,trimFront(site), "http://renechristen.net/wrapped/memorial/posted_2.php");
if(worked){
println("SUCCESS");
write("The Site has been engraved.");
lastSite = site;
println(lastSite);
println(site);
}else{
println("FAILURE");
write("Can't open database, please try again.");
}
has_posted = true;
}else { //if recently added:
write("Site already engraved.");
//end php

}
}
}
}
}


//detects hover over "engrave" button:
boolean overRect(int x, int y, int width, int height)
{
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
} else {
return false;
}
}

//writes status info to screen
void write(String input) {
fill(0);
stroke(0);
rect(0,80,400,70);
fill(200);
PFont font;
font = loadFont("RotisSer.vlw.gz");
textFont(font, 15);
textAlign(CENTER);
text(input, 176, 108);

}

//stop spring gui complaining:
void handleEvent(String[] parameters) {
// When return is pressed...
if ( parameters[1].equals("myTextField") && parameters[2].equals("returnPressed") ) {
//
}
}

Page Index Toggle Pages: 1