As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

SELECT * FROM posts WHERE tid = 'PA PROGRAMMING THREAD'

15354565859100

Posts

  • CantidoCantido Registered User regular
    Am I allowed to do two queries one by one or can I squeeze both these operations into one query. PDO wasn't working so I used brute force and it both insertions and deletes work, but now I want to order them.
    $q="INSERT INTO scheduler VALUES ('$custnum', NULL, '$day', '$starttime', '$mode', '$temp', '$humid', '$duration', '$air_quality', '$fresh_air')";
    $result=mysql_query($q) or die ("query submission error:".mysql_error());
    
    $o = "SELECT * FROM scheduler ORDER BY day";
    $result=mysql_query($o) or die ("query submission error:".mysql_error());
    

    Also, I can successfully order by day via phpmyadmin because I changed the seven days of the week to integers, but the user still sees "Mon, Tue, Wed" and so on by matching the integer with an array like so.
    $days=array ('null','Mon','Tue', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun');
    //skipping rows....
    echo '<td>'. $days[$row['day']] .'</td>';
    

    3DS Friendcode 5413-1311-3767
  • bowenbowen How you doin'? Registered User regular
    Insert and Select statements need to be separate.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • IncindiumIncindium Registered User regular
    edited April 2012
    Hey @Jimmy King your profile pic is dead linked... Should just put it up on PADev.net or something.

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • Jimmy KingJimmy King Registered User regular
    Incindium wrote: »
    Hey @Jimmy King your profile pic is dead linked...

    Yeah, I'm lazy. It's been that way for a long time. I changed some stuff on my web server and never fixed it.

  • bowenbowen How you doin'? Registered User regular
    edited April 2012
    Holy shit.

    I ran across some code where it looks like someone attempted some templating generics but would've been far better if they used polymorphism. In particular it looks like someone had adapted this code to be multi-database but instead of having a base interface in which to derive from, the class has like 4-5 different types of variables.

    Something like:
    
    public enum SQLType
    {
      SQLServer,
      MySQL,
      //there's a few in here
      //only those two were implemented
    }
    
    public class DatabaseLinker
    {
      //defaults to SQL Server
      private SqlType type = SQLType.SQLServer;
    
      private MySqlConnection my_cn;
      private SqlConnection cn;
    
      private MySqlCommand my_cmd;
      private SqlCommand cmd;
      //... so on
    
      //wat????
      public SqlDataReader GetReader() {
              return dr;
      }
    
      public MySqlDataReader GetReader() {
          return my_dr;
      }
    }
    

    Oh yeah... and that's my cleaned up version of the mess they had.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • NightslyrNightslyr Registered User regular
  • bowenbowen How you doin'? Registered User regular
    edited April 2012
    Oh whoops I messed up something there on line 21. I must've missed something in a signature when I was cleaning it up too, because that shouldn't work/compile at all, I don't think, at least I don't think it does in .NET.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • CantidoCantido Registered User regular
    bowen wrote: »
    Insert and Select statements need to be separate.

    Then what I did was, rather than put the ORDER BY after my submissions and deletions, I went to the page displaying the database contents, and put my ORDER BY in front of the select. Rather than try to order the database itself, it grabs everything from the database, then orders it for the user's purposes. This did the trick.

    3DS Friendcode 5413-1311-3767
  • baronfelbaronfel Would you say I have a _plethora_?Registered User regular
    Man, .Net reflection is dizzying. I just reflected over an arbitrary number of types that have some attribute we created that specifies a MenuStrip (WinForms control) is present in that class. I then used reflection to get that MenuStrip and iterated over the MenuItems, stripping useful properties from each one to stuff into a new data model we've been mandated to move to. Oh, I also grabbed MenuItem.PerformClick() and wrapped it as an Action so that when they click WPF elements in the new UI we can fire the old Action without even knowing what it was.


    I feel dirty.

  • bowenbowen How you doin'? Registered User regular
    Well at least you aren't cleaning up this code with it's wonderful ambiguous template-style system that I'm worried about has been functioning properly.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Jimmy KingJimmy King Registered User regular
    So, if you need to refactor a model from one django app out into a new one and are trying to use South for migrations it's kind of a nightmare. I'm so glad this system is early enough in development and not live anywhere so that "Drop the db and recreate it. Sorry about the test data loss." was acceptable.

  • Mike DangerMike Danger "Diane..." a place both wonderful and strangeRegistered User regular
    edited April 2012
    Never mind, I think I figured this out.

    Mike Danger on
    Steam: Mike Danger | PSN/NNID: remadeking | 3DS: 2079-9204-4075
    oE0mva1.jpg
  • ArsonideArsonide Registered User regular
    Okay I'm going to ask this here, because it seems appropriate. I'm working on a project, and I need to modify someone else's code slightly. A little, minor change. The only problem is that he used Boost, and Boost refuses to properly install or something. I tried installing it from scratch, and I tried using BoostPro. I don't see what I can be doing wrong as I followed a guide, and BoostPro has like three checkboxes that you fill in appropriate to your IDE. I'm using VS9/2008.

    When I try to compile, Boost explodes with all sorts of errors, here's an excerpt: http://pastebin.com/qJdQ8w2X

    I really want to continue working on my project. Does anybody have any idea what is going on? I've asked in Boost's IRC channel, but it's surprisingly idle and the only answers I've gotten are "You did it wrong. Do it again." I've done it four times now, tried compiling from scratch following a guide, and BoostPro has like three checkboxes - there's no way to screw it up.

  • ecco the dolphinecco the dolphin Registered User regular
    edited April 2012
    Arsonide wrote: »
    Okay I'm going to ask this here, because it seems appropriate. I'm working on a project, and I need to modify someone else's code slightly. A little, minor change. The only problem is that he used Boost, and Boost refuses to properly install or something. I tried installing it from scratch, and I tried using BoostPro. I don't see what I can be doing wrong as I followed a guide, and BoostPro has like three checkboxes that you fill in appropriate to your IDE. I'm using VS9/2008.

    When I try to compile, Boost explodes with all sorts of errors, here's an excerpt: http://pastebin.com/qJdQ8w2X

    I really want to continue working on my project. Does anybody have any idea what is going on? I've asked in Boost's IRC channel, but it's surprisingly idle and the only answers I've gotten are "You did it wrong. Do it again." I've done it four times now, tried compiling from scratch following a guide, and BoostPro has like three checkboxes - there's no way to screw it up.

    Those lines look like they're referring to C++0x features:

    e.g.
    #if defined( BOOST_HAS_RVALUE_REFS )
    
        template<class Y>
        weak_ptr & operator=( weak_ptr<Y> && r ) // <---- Line 137 here
        {
            this_type( static_cast< weak_ptr<Y> && >( r ) ).swap( *this );
            return *this;
        }
    
    #endif
    
    

    From what I can tell, VS2008 does not support C++0x.

    It looks like something is telling boost to use C++0x features, because those lines are only compiled if BOOST_HAS_RVALUE_REFS is defined.

    I guess if you want to keep on using VS2008, you could try to find out what is causing C++0x features to be turned on?

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • ArsonideArsonide Registered User regular
    Thank you. This got me Googling for the right problem! I updated Visual Studio and downgraded Boost to 1.42 - the last version that was designed for VS2008. Seems to work now.

  • urahonkyurahonky Registered User regular
    Okay guys I have a question about drag and dropping.

    I've added a DropTargetListener to a control that we have. Using system.out.println() I know that it is working properly (if something drags over it the listener outputs correctly). Now the real issue is I need to figure out how to get the data of the dragged event. I see that the following method exists:
    public void drop(DropTargetDropEvent dtde){
    }
    

    Is the data hidden behind the dtde? Or am I going about this all wrong?

  • bowenbowen How you doin'? Registered User regular
    edited April 2012
    You'll probably want to determine the type of object (image, string, whatever) from the dtde.getCurrentDataFlavors() of the event, and then use dtde.getTransferrable() on the to get the actual object once you determine what type it is and how to manage it.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • urahonkyurahonky Registered User regular
    Okay this is weird. Whenever I drag and drop something into our editor window the drop target drop event doesn't have any data flavors.

  • urahonkyurahonky Registered User regular
    edited April 2012
    Even weirder. It works when I call the dtde immediately after the drop, but when I pass that event into another class I lose the data flavors. I don't understand why that is.

    e: Turns out we don't really use the dtde for anything other than the location. Sigh..

    urahonky on
  • bowenbowen How you doin'? Registered User regular
    What do you mean "pass that event into another class" ?

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • ToddJewellToddJewell Registered User regular
    anyone take the 70-432? I am going to take it next month probably [using the opportunity to advance myself and learn some things I don't currently know]

  • urahonkyurahonky Registered User regular
    bowen wrote: »
    What do you mean "pass that event into another class" ?

    Say you drag and drop something. This dtde event gets stored into a private variable. This variable is passed into another class. And then this is called again, but somehow the DataFlavors don't exist.

    But I figure I'm just going to follow what we did before.

  • BarrakkethBarrakketh Registered User regular
    Arsonide wrote: »
    Thank you. This got me Googling for the right problem! I updated Visual Studio and downgraded Boost to 1.42 - the last version that was designed for VS2008. Seems to work now.
    FYI, when using b2/bjam to build Boost for MSVC you need to specify the toolset and the version number (VS2008 == 9.0, so msvc-9.0).

    Rollers are red, chargers are blue....omae wa mou shindeiru
  • bowenbowen How you doin'? Registered User regular
    Just for my own knowledge is it possible to mirror a class to another name (C#)?

    Let's say I have class foo:
    public class Foo 
    {
        public void SayHello() {
            Console.WriteLine("Hello!");
        }
    }
    

    Is it possible to make a global mirror so I can do something like
    public class Bar : Foo; //(MIRRORS FOO)
    
    int main()
    {
        //call one of Foo's constructor's through Bar
        //and SayHello
        Bar myBar = new Bar();
        myBar.SayHello();
    }
    

    The class name I have to be calling is ugly as shit and I was hoping for an easy way to do this without having to have a statement in each file or something, something I can do globally.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • InfidelInfidel Heretic Registered User regular
    bowen wrote: »
    Just for my own knowledge is it possible to mirror a class to another name (C#)?

    Let's say I have class foo:
    public class Foo 
    {
        public void SayHello() {
            Console.WriteLine("Hello!");
        }
    }
    

    Is it possible to make a global mirror so I can do something like
    public class Bar : Foo; //(MIRRORS FOO)
    
    int main()
    {
        //call one of Foo's constructor's through Bar
        //and SayHello
        Bar myBar = new Bar();
        myBar.SayHello();
    }
    

    The class name I have to be calling is ugly as shit and I was hoping for an easy way to do this without having to have a statement in each file or something, something I can do globally.

    This is something that the C typedef/preprocessor is good at.

    In other words, TOUGH SHIT! :rotate:

    OrokosPA.png
  • Grey PaladinGrey Paladin Registered User regular
    A while back I asked for some resources on graphical programming. In addition to what was posted here I found a pretty nifty introductionary guide. Anyone who has any interest in the subject might want to give it a look.

    Link

    "All men dream, but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity; but the dreamers of the day are dangerous men, for they may act their dream with open eyes to make it possible." - T.E. Lawrence
  • bowenbowen How you doin'? Registered User regular
    Infidel wrote: »
    bowen wrote: »
    Just for my own knowledge is it possible to mirror a class to another name (C#)?

    Let's say I have class foo:
    public class Foo 
    {
        public void SayHello() {
            Console.WriteLine("Hello!");
        }
    }
    

    Is it possible to make a global mirror so I can do something like
    public class Bar : Foo; //(MIRRORS FOO)
    
    int main()
    {
        //call one of Foo's constructor's through Bar
        //and SayHello
        Bar myBar = new Bar();
        myBar.SayHello();
    }
    

    The class name I have to be calling is ugly as shit and I was hoping for an easy way to do this without having to have a statement in each file or something, something I can do globally.

    This is something that the C typedef/preprocessor is good at.

    In other words, TOUGH SHIT! :rotate:

    God damnit, //flip table

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • bowenbowen How you doin'? Registered User regular
    edited April 2012
    Apparently :
    using Bar = Foo;
    

    Works, but you can't do it globally, it has to be per file.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    So I really like some of the stuff Notch is doing with programmability in games with his 0x10^C stuff. Ever since playing FF12, and later Dragon Age, and seeing the complex gambit/AI systems they had, that were essentially visual scripting systems, I've been thinking about putting a much more advanced AI scripting system in my game...it's super niche, but I think niche sells in the indie space, and frankly I am more worried about writing something I'd play and have fun with, than making a ton of cash.

    My big question is if I should use an off the shelf language, that may be off putting to really new users, or if I should roll something simple and BASIC'y that is really easy for non-programmers to try and pick up. I think it would be really neat to have my game be used as a way for younger/newer scripters to learn how to write good AI code. Would be really cool to see people passing around AI scripts for different party members.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • InfidelInfidel Heretic Registered User regular
    GnomeTank wrote: »
    So I really like some of the stuff Notch is doing with programmability in games with his 0x10^C stuff. Ever since playing FF12, and later Dragon Age, and seeing the complex gambit/AI systems they had, that were essentially visual scripting systems, I've been thinking about putting a much more advanced AI scripting system in my game...it's super niche, but I think niche sells in the indie space, and frankly I am more worried about writing something I'd play and have fun with, than making a ton of cash.

    My big question is if I should use an off the shelf language, that may be off putting to really new users, or if I should roll something simple and BASIC'y that is really easy for non-programmers to try and pick up. I think it would be really neat to have my game be used as a way for younger/newer scripters to learn how to write good AI code. Would be really cool to see people passing around AI scripts for different party members.

    Off the shelf language means you are writing an API, not a scripting system. For things to be simple enough for non-developers, you want that BASIC'y limitation on what they can do to (a) keep them on task and (b) make it a lot more straight-forward.

    Something where the interactions and processes are visible is the key to usability. Even programmers have fun with a custom scripting language in games so it works for everyone.

    OrokosPA.png
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Yeah, I agree, and that's the way I was leaning. Thanks for validating my thought process. Time to bust out my compiler/parser books!

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • centraldogmacentraldogma Registered User regular
    GnomeTank wrote: »
    Yeah, I agree, and that's the way I was leaning. Thanks for validating my thought process. Time to bust out my compiler/parser books!

    That shouldn't be too hard. I recall there was some trick to creating an interpreter really quickly, like in the matter of a day.

    I have since forgotten that trick.

    When people unite together, they become stronger than the sum of their parts.
    Don't assume bad intentions over neglect and misunderstanding.
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    I've written them in the past, it's not real difficult. I'll probably use Antlr to write the parser, as it has a C# interface, and makes things really nice to do in terms of Parser BNF -> AST -> Byte Code.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • InfidelInfidel Heretic Registered User regular
    Being able to assume a lot of context is what makes scripting friendly and intuitive.

    I had a lot of fun with ZZT/Megazeux back in the day. Take a look at the code, it is short but event-message driven and uses a lot of builtins to make interfacing with your game world easy.

    I would recommend something a little more up to date though in style. :lol:

    OrokosPA.png
  • urahonkyurahonky Registered User regular
    Oh man I thought I was getting somewhere then went on lunch... And as soon as I got back I immediately regretted it because I felt like I lost it. But I'm finally back on track and hopefully will be able get these tabbed panes fully implemented! I'm pretty excited because I honestly didn't think it was possible in the current state of our program. But now I'm learning a LOT about drag and drops.

  • bowenbowen How you doin'? Registered User regular
    At least you're not refactoring whatever the fuck it is I'm refactoring. My god mix match of using statements and straight declarations and calling dispose manually.

    What the fuck kind of monster made this?

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • urahonkyurahonky Registered User regular
    bowen wrote: »
    At least you're not refactoring whatever the fuck it is I'm refactoring. My god mix match of using statements and straight declarations and calling dispose manually.

    What the fuck kind of monster made this?

    The worst kind of monster. ____________

  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    bowen wrote: »
    At least you're not refactoring whatever the fuck it is I'm refactoring. My god mix match of using statements and straight declarations and calling dispose manually.

    What the fuck kind of monster made this?

    What's wrong with calling dispose manually? :P Not everything can be wrapped in a using() clause.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • quietjayquietjay Indianapolis, INRegistered User regular
    ToddJewell wrote: »
    anyone take the 70-432? I am going to take it next month probably [using the opportunity to advance myself and learn some things I don't currently know]

    I used the Microsoft Press Self-Paced Training Kit book to study for that test. When I took the test it was all just test questions, there weren't any lab simulator questions like the SQL 2005 test had.

    By now the SQL 2012 tests are probably available, so unless you specifically need the 2008 version you may want to look at the newer exams.

    Become a Star Citizen
  • urahonkyurahonky Registered User regular
    Mother of shit Sharepoint is terrible.

This discussion has been closed.