Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 86 87 [88] 89 90 91

Author Topic: Programming Help Thread (For Dummies)  (Read 100404 times)

Arx

  • Bay Watcher
  • Iron within, iron without.
    • View Profile
    • Art!
Re: Programming Help Thread (For Dummies)
« Reply #1305 on: November 26, 2014, 12:51:22 pm »

There should be a folder called 'files' somewhere in the folder the script is in. The print is a debug thing, I think.

What are you actually trying to achieve with this? I gather it's something that counts the number of matches for a term in the Google results for a given query. Is that right? I have no regex-fu, and my Python is rusty.
Logged

I am on Discord as Arx#2415.
Hail to the mind of man! / Fire in the sky
I've been waiting for you / On this day we die.

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1306 on: November 26, 2014, 12:52:33 pm »

Source.

That blog post was written six years ago. It appears that Google changed what their cached page links look like. The script needs to be modified, but my regex-fu isn't up to the task at the moment.
Logged

My Name is Immaterial

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1307 on: November 26, 2014, 02:10:21 pm »

There should be a folder called 'files' somewhere in the folder the script is in. The print is a debug thing, I think.

What are you actually trying to achieve with this? I gather it's something that counts the number of matches for a term in the Google results for a given query. Is that right? I have no regex-fu, and my Python is rusty.
There's nothing showing up in that folder when I run it.
I'm trying to archive a downed website through the Google cache.

Source.

That blog post was written six years ago. It appears that Google changed what their cached page links look like. The script needs to be modified, but my regex-fu isn't up to the task at the moment.
I'll see if I can't update the code.

My Name is Immaterial

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1308 on: November 27, 2014, 03:53:52 am »

I've given up on the Python script, and am looking into other options. Thanks for the help!

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: Programming Help Thread (For Dummies)
« Reply #1309 on: January 17, 2015, 08:28:12 pm »

PTW
Logged

highmax28

  • Bay Watcher
  • I think this is what they call a tantrum spiral...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1310 on: February 04, 2015, 08:58:22 pm »

Having problems with Javascript. So far, when run, this thing displays everything I need it to, but when I enter the info, the textbox that is displayed doesn't display the info its supposed to write. Here it is:

Code: [Select]
<html>
<head>
<!-- Program Name: flowerForm.html
Purpose: To create a form with the user's name and a choice of flower
Author: Specner Durette
Date last modified: February 3rd, 2015
-->
<script type="text/javascript">
//Variables
var flower;
var BR = "<br />";
var PA = "<p />";
var NL = "\n";

//Change the flower value when a radio button is pressed
function setType(flowerType) {
flower=flowerType;
}

function displayRequest() {
var fullName = document.FlowerForm.fullName.value;
var flower = document.FlowerForm.flowerPicked.value;

document.FlowerForm.FormRequest.value =
"Thank you for requesting information!" + NL + NL
+ "Name: " + fullName + NL
+ "Flower Inquiry About: " + flowerType
}
</script>
</head>
<body>
<h2>Flower Information Form</h2>
<form name="FlowerForm" action="">
<strong>Enter Your Full Name:</strong><br />
<input type="text" name="fullName" value="Full Name" size="40"><br />
<br />
<strong>Select the flower you wish to make an inquiry about</strong><br />
<input type="radio" name="flower" value="Roses" onclick="setType(flowerType)" />Roses<br />
<input type="radio" name="flower" value="Carnations" onclick="setType(flowerType)" />Carnations<br />
<input type="radio" name="flower" value="Daisies" onclick="setType(flowerType)" />Dasies<br />

<input type="button" name="resquestButton" value = "Display Request" onclick="displayRequest()" /><p />
<textarea name ="FormRequest" readonly="true" value = "" rows="8" cols="50"></textarea><br />
</form>
</body>
</html>

I took some advice from the rage thread, and it looks a little different code wise, but same problem happens
Logged
just shot him with a balistic arrow, i think he will get stuned from that >.>

"Guardian" and Sigfriend Of Necrothreat
Jee wilikers, I think Highmax is near invulnerable, must have been dunked in the river styx like achilles was.
Just make sure he wears a boot.

Nirur Torir

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1311 on: February 04, 2015, 10:46:31 pm »

Having problems with Javascript. So far, when run, this thing displays everything I need it to, but when I enter the info, the textbox that is displayed doesn't display the info its supposed to write. Here it is:

Code: [Select]
//Change the flower value when a radio button is pressed
function setType(flowerType) {
flower=flowerType;
}

<input type="radio" name="flower" value="Roses" onclick="setType(flowerType)" />Roses<br />
<input type="radio" name="flower" value="Carnations" onclick="setType(flowerType)" />Carnations<br />
<input type="radio" name="flower" value="Daisies" onclick="setType(flowerType)" />Dasies<br />
I'm not really a coder, and don't know javascript at all, but I don't see where you're setting flowerType. Is the flower name after setType(flowerType)" /> setting flowerType somehow? (Is that function call even needed, or is it just seen as good practice to use it there?)
Logged

highmax28

  • Bay Watcher
  • I think this is what they call a tantrum spiral...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1312 on: February 04, 2015, 11:01:34 pm »

Its all I got in here since its literally the first chapter of Javascript. I've been mostly bashing this thing. I got it to work, but now its spouting undefined. I think the BR and NL isn't working.

Code: [Select]
<html>
<head>
<!-- Program Name: flowerForm.html
Purpose: To create a form with the user's name and a choice of flower
Author: Specner Durette
Date last modified: February 3rd, 2015
-->
<script type="text/javascript">
//Variables
var flower = document.FlowerForm.flower.value;
var BR = "<br />";
var PA = "<p />";
var NL = "\n";

//Change the flower value when a radio button is pressed
function setType(flowerType) {
flower=flowerType;
}

function displayRequest() {
var fullName = document.FlowerForm.fullName.value;
var flower = document.FlowerForm.flowerRadio.value;

document.FlowerForm.FormRequest.value =
"Thank you for requesting information!" + BR + NL
+ "Name: " + fullName + BR + NL
+ "Flower Inquiry About: " + flower
}
</script>
</head>
<body>
<h2>Flower Information Form</h2>
<form name="FlowerForm" action="">
<strong>Enter Your Full Name:</strong><br />
<input type="text" name="fullName" value="Full Name" size="40"><br />
<br />
<strong>Select the flower you wish to make an inquiry about</strong><br />
<input type="radio" name="flowerRadio" value="Roses" onclick="setType(flower)" />Roses<br />
<input type="radio" name="flowerRadio" value="Carnations" onclick="setType(flower)" />Carnations<br />
<input type="radio" name="flowerRadio" value="Daisies" onclick="setType(flower)" />Daisies<br />

<input type="button" name="resquestButton" value = "Display Request" onclick="displayRequest()" /><p />
<textarea name ="FormRequest" readonly="true" value = "" rows="8" cols="50"></textarea><br />
</form>
</body>
</html>

This is what I got now after some help on the rage thread
Logged
just shot him with a balistic arrow, i think he will get stuned from that >.>

"Guardian" and Sigfriend Of Necrothreat
Jee wilikers, I think Highmax is near invulnerable, must have been dunked in the river styx like achilles was.
Just make sure he wears a boot.

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1313 on: February 05, 2015, 12:25:06 am »

Whoops, I posted the solution in your other thread, I'll requote it here, sorry.  It looks like you already figured out half of the problem.
   :P
Edit:  I fix.  I comment.  I do a dance.

Code: [Select]
<html>
<head>
<!-- Program Name: flowerForm.html
Purpose: To create a form with the user's name and a choice of flower
Author: Someguy
Date last modified: February 3rd, 2015
-->
<script type="text/javascript">
//Variables
var flower;
var BR = "<br />";
var PA = "<p />";
var NL = "\n";

//Change the flower value when a radio button is pressed
function setType(flowerType) {
flower=flowerType;
}

function displayRequest() {
var fullName = document.FlowerForm.fullName.value;
//var flower = document.FlowerForm.flowerPicked.value; //There isn't any variable called flowerPicked, and you've already got flower defined above in the globals.
//another way to do this would be something like:
//flower = document.FlowerForm.flower.value;  //Now I don't need to have a setType function at all, its taking it directly from the form.

document.FlowerForm.FormRequest.value =
"Thank you for requesting information!" + NL + NL
+ "Name: " + fullName + NL
+ "Flower Inquiry About: " + flower; //I changed this from flowerType to flower, and added a semicolon all over the place.
}
</script>
</head>
<body>
<h2>Flower Information Form</h2>
<form name="FlowerForm" action="">
<strong>Enter Your Full Name:</strong><br />
<input type="text" name="fullName" value="Full Name" size="40"><br />
<br />
<strong>Select the flower you wish to make an inquiry about</strong><br />
<input type="radio" name="flower" value="Roses" onclick="setType('Roses');" />Roses<br /> <!--flowerType isn't defined as anything, so I tossed in actual values-->
<input type="radio" name="flower" value="Carnations" onclick="setType('Carnations');" />Carnations<br />
<input type="radio" name="flower" value="Daisies" onclick="setType('Daisies');" />Dasies<br />

<input type="button" name="resquestButton" value = "Display Request" onclick="displayRequest();" /><p />
<textarea name="FormRequest" readonly="true" value = "" rows="8" cols="50"></textarea><br />
</form>
</body>
</html>

The problem was mostly you seemed to be trying to get the flower variable in two different ways that were probably colliding with each other a bit.  One way was with the setType, and that was mostly fixed by putting in actual text strings instead of an undeclared variable.  The second way was grabbing it straight from the form, which you almost had right, but were grabbing it from "flowerPicked" instead of "flower".  I commented it up where I've changed things.

Also some semi-colons were missing.  You got to be very careful not to forget them!
« Last Edit: February 05, 2015, 12:27:55 am by Levi »
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1314 on: February 05, 2015, 08:21:25 am »

We have a thread for programming help? How did I not see this all the time? PTH
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1315 on: February 05, 2015, 08:28:08 am »

Source.

That blog post was written six years ago. It appears that Google changed what their cached page links look like. The script needs to be modified, but my regex-fu isn't up to the task at the moment.

I can confirm that it's definitely not as easy to automate scraping google results as even 18 months ago. I have some google scraping code that worked before but fails now. They changed things to try and block automated scripts. You have to be more clever with the user-agent thing now, but I'm not sure exactly what needs to change.
« Last Edit: February 05, 2015, 08:32:42 am by Reelya »
Logged

Akhier the Dragon hearted

  • Bay Watcher
  • I'm a Dragon, Roar
    • View Profile
    • My YouTube Channel
Re: Programming Help Thread (For Dummies)
« Reply #1316 on: February 06, 2015, 05:59:09 pm »

   Okay, my Googling fails me. I have been fooling around in python and have my mapgen translated into it (as I am wont to do with every language I learn). With that working I now would like to make a nice little png visualization of it. Problem is all I can find is the suggestion to use the png module which should be easy enough except I can't find any examples nor tutorials so I am sort of stranded right now. Probably just missing something simple or did the wrong Google searches but any help would be appreciated.
Logged
Quote
Join us. The crazy is at a perfect temperature today.
So it seems I accidentally put my canteen in my wheelbarrow and didn't notice... and then I got really thirsty... so right before going to sleep I go to take a swig from my canteen and... end up snorting a line of low-grade meth.

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1317 on: February 06, 2015, 10:52:36 pm »

   Okay, my Googling fails me. I have been fooling around in python and have my mapgen translated into it (as I am wont to do with every language I learn). With that working I now would like to make a nice little png visualization of it. Problem is all I can find is the suggestion to use the png module which should be easy enough except I can't find any examples nor tutorials so I am sort of stranded right now. Probably just missing something simple or did the wrong Google searches but any help would be appreciated.

https://pythonhosted.org/pypng/png.html

Would this help? It seems like there would be a better way than making a 2d list with one entry per pixel.
Logged

Akhier the Dragon hearted

  • Bay Watcher
  • I'm a Dragon, Roar
    • View Profile
    • My YouTube Channel
Re: Programming Help Thread (For Dummies)
« Reply #1318 on: February 06, 2015, 11:04:48 pm »

   That is what I get pointed to but it doesn't have a code example. A tutorial is what I would like to see or at least an example or two. I am not able to make much from the base stuff you get there.

Edit: I assume I am just missing something somewhere.
« Last Edit: February 06, 2015, 11:17:56 pm by Akhier the Dragon hearted »
Logged
Quote
Join us. The crazy is at a perfect temperature today.
So it seems I accidentally put my canteen in my wheelbarrow and didn't notice... and then I got really thirsty... so right before going to sleep I go to take a swig from my canteen and... end up snorting a line of low-grade meth.

highmax28

  • Bay Watcher
  • I think this is what they call a tantrum spiral...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1319 on: February 07, 2015, 12:27:09 am »

This may be a slight derail, but the code I posted earlier was found by one of my classmates who took it and handed it in after changing my name on it. He didn't know it was me despite my name on it and he had a big eye opener when he found out I was Highmax. My lifelong dream of someone going up to me and saying "Wait... YOU'RE Highmax!?" has come true... And all it took was posting my homework online. I'm tempted to post more incomplete code on here so if he finds it again, it won't work and he doesn't get to copy-paste it
Logged
just shot him with a balistic arrow, i think he will get stuned from that >.>

"Guardian" and Sigfriend Of Necrothreat
Jee wilikers, I think Highmax is near invulnerable, must have been dunked in the river styx like achilles was.
Just make sure he wears a boot.
Pages: 1 ... 86 87 [88] 89 90 91