Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 467 468 [469] 470 471 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 909564 times)

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7020 on: February 22, 2015, 01:57:02 pm »

That is exactly what happened. Maybe should have posted that in the beginners thread.

I felt secure because boost advertises itself as being "mostly headers" and I only skimmed across the list of binaries to be linked. I missed "libboost_serialization.so".
Logged
Taste my Paci-Fist

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #7021 on: February 24, 2015, 07:59:12 am »

Friend's intro comp sci final project list.

They all seem both fun and intimidating to implement o.o
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7022 on: February 24, 2015, 09:16:39 am »

Most aren't at all intimidating and pretty much give you step-by-step instructions in the associated reference stuff.

I should give implementing diffie-hellman key exchange a go.
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #7023 on: February 24, 2015, 10:55:39 am »

Oh, I didn't look at the references section at all. haha
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #7024 on: February 24, 2015, 12:46:03 pm »

Friend's intro comp sci final project list.

They all seem both fun and intimidating to implement o.o
Looks like an interesting course.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

Zamininc

  • Escaped Lunatic
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7025 on: February 24, 2015, 10:03:58 pm »

Anyone else focusing their study on Ruby (and more specifically, the Ruby on Rails framework)?

Coming off of an intermediate knowledge of Python and some formal training in C++.
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #7026 on: February 26, 2015, 02:19:21 pm »

Could someone help me out with some VB?

Code: [Select]
    Private Sub btnReport_Click(sender As Object, e As EventArgs) Handles btnReport.Click

        lblReport.Text = "Finalists: "

        For Each item As String In listFinalists.Items
            lblReport.Text = "Finalists: " & listFinalists.Items.ToString    'this doesn't work
        Next

    End Sub
^^The offending stub.

I just want to move all the items from the listbox to the label beneath the "Finalists: " string, so it looks something like this:
Quote
Finalists:
Chief John Anderton
Billy Mays
Butthole Surfer
etc.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7027 on: February 26, 2015, 02:37:54 pm »

I'm not a VB guy except for a little VB script, but if you have that
Code: [Select]
For Each item As String In listFinalists.Items
Isn't "item As String" your string and "listFinalists.Items" the collection?

It wouldn't make sense to "ToString" the listFinalists.Items, when just "item" is your variable. Try :-
Code: [Select]
lblReport.Text = "Finalists: " & item
It's similar to for (int item =0; item < max_item; item ++) in c++
« Last Edit: February 26, 2015, 02:52:07 pm by Reelya »
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #7028 on: February 26, 2015, 02:41:31 pm »

That will only grab the first item on the list.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7029 on: February 26, 2015, 02:45:03 pm »

There's your problem, you don't understand what's going on. "item" is the loop variable that's being used to extract the data. the name "item" is generic.

This is an example from MSDN of corrent usage:

Code: [Select]
For Each item As String In lst
    Debug.Write(item & " ")
Next

So, "item" is indeed the loop variable that's being set to the string, and is what you need to use inside the loop
« Last Edit: February 26, 2015, 02:57:07 pm by Reelya »
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7030 on: February 26, 2015, 02:48:30 pm »

Really nowdays in C++ you would just write:
Code: [Select]
for (auto &i : items) {and iterate through them directly unless you had a valid reason for index shenanigans.
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7031 on: February 26, 2015, 02:51:14 pm »

I whacked up the standard c for loop for educational purposes. Using the latest fancy gizmo that only works in one language would not have helped to illustrate the concept, but I can have a reasonable assumption that someone's come across the standard for loop in some language or editor.

but if you want to iterate over a specific range and that doesn't exactly coincide with any data structure you're still going to need to specify start and stop conditions. What if index 0 is reserved for a null condition and you don't want to actually process that index?
« Last Edit: February 26, 2015, 02:55:55 pm by Reelya »
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #7032 on: February 26, 2015, 03:00:28 pm »

There's your problem, you don't understand what's going on.
>:I

Spoiler (click to show/hide)

It only outputs the first item on the list, Reelya.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7033 on: February 26, 2015, 03:04:08 pm »

Code: [Select]
        lblReport.Text = "Finalists: "

        For Each item As String In listFinalists.Items
            lblReport.Text = "Finalists: " & item   
        Next

is overwriting the entire lblReport.Text each time. There's no way it will ever hold more than 1 item that way. It should be something like:

Code: [Select]
        lblReport.Text = "Finalists: "

        For Each item As String In listFinalists.Items
            lblReport.Text = lblReport.Text & ", " & item 
        Next
« Last Edit: February 26, 2015, 03:06:21 pm by Reelya »
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #7034 on: February 26, 2015, 03:06:45 pm »

It looks like I overwrote the lblreport.text with the string "finalists" and one item each time through the loop.
FTFY

try appending to the lblreport.text by doing :

lblreport.text = lblreport.text & " " & item.
This works! Thanks for the help Reelya.

Logged
Pages: 1 ... 467 468 [469] 470 471 ... 796