Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it,
follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given
their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!
SELECT * FROM posts WHERE tid = 'PA PROGRAMMING THREAD'
Posts
I'm assuming it uses CRecordset ? But how?
Is as much as I've turned up with the MSDN, but how does one process the query?
I'm classy motherfuckers.
I have it set to shuffle all which includes my classical station. Just great to have a variety of music to code to.
You need to derive a custom class from CRecordset from what I remember doing... Here is something from some legacy code I pulled up...
from the .h file
class CPCustomRS : public CRecordset { public: CPCustomRS(CDatabase& DB); long m_RID; CString m_CODE; CString m_NAME; CString m_ATTENTION; CString m_ADDRESS1; CString m_ADDRESS2; CString m_CITY; CString m_REGION; CString m_POSTALCODE; CString m_COUNTRY; BYTE m_STAT_RID; CString m_NOTES; virtual CString GetDefaultSQL(); virtual void DoFieldExchange(CFieldExchange* pFX); };from .cpp file
CPCustomRS::CPCustomRS (CDatabase& DB) : CRecordset(DB) { m_RID = 0; m_CODE = _T(""); m_NAME = _T(""); m_ATTENTION = _T(""); m_ADDRESS1 = _T(""); m_ADDRESS2 = _T(""); m_CITY = _T(""); m_REGION = _T(""); m_POSTALCODE = _T(""); m_COUNTRY = _T(""); m_STAT_RID = 0; m_NOTES = _T(""); m_nFields = 12; m_nDefaultType = dynaset; } CString CPDistributorRS::GetDefaultSQL() { return _T("[dbo].[V_CUSTOM_RW]"); } void CPDistributorRS::DoFieldExchange(CFieldExchange* pFX) { pFX->SetFieldType(CFieldExchange::outputColumn); RFX_Long(pFX, _T("[RID]"), m_RID); RFX_Text(pFX, _T("[CODE]"), m_CODE); RFX_Text(pFX, _T("[NAME]"), m_NAME); RFX_Text(pFX, _T("[ATTENTION]"), m_ATTENTION); RFX_Text(pFX, _T("[ADDRESS1]"), m_ADDRESS1); RFX_Text(pFX, _T("[ADDRESS2]"), m_ADDRESS2); RFX_Text(pFX, _T("[CITY]"), m_CITY); RFX_Text(pFX, _T("[REGION]"), m_REGION); RFX_Text(pFX, _T("[POSTALCODE]"), m_POSTALCODE); RFX_Text(pFX, _T("[COUNTRY]"), m_COUNTRY); RFX_Byte(pFX, _T("[STAT_RID]"), m_STAT_RID); RFX_Text(pFX, _T("[NOTES]"), m_NOTES); }From where you'd actually use it in code.
CPCustomRS rsCustom (pMyApp->m_Database); if (rsCustom.Open (CRecordset::forwardOnly,NULL,CRecordset::readOnly|CRecordset::executeDirect)){ while (!rsCustom.IsEOF()){ if (!rsCustom.IsDeleted()){ CString temp = rsCustom.m_ADDRESS1; } rsCustom.MoveNext(); } rsCustom.Close (); }Diablo 3 Profile
There's a 90's hip hop station that I've started listening to that is pretty awesome to program to. I tried Smooth Jazz, but it was TOO relaxing. I need something to keep me going.
Thanks @Incidndium I actually got it before I checked back here. Here's what I did:
CDatabase db; LPCTSTR connectionString = _T("... My database stuff here..."); db.OpenEx(connectionString, CDatabase::openReadOnly | CDatabase::noOdbcDialog); wchar_t query[256]; swprintf(query,L"SELECT dnStr FROM personnel WHERE emp_user ='%s'",user); CRecordset rs(&db); rs.Open(CRecordset::forwardOnly,query); CDBVariant varValue; if(!rs.IsEOF()) { rs.GetFieldValue((short)0,varValue); } MultiByteToWideChar(CP_ACP,0,*varValue.m_pstringA,strlen(*varValue.m_pstringA),userDN,sizeof(userDN)); rs.Close(); db.Close();Also, yes, I live dangerously.
Ha... I'm glad I don't actively work with C++/MFC anymore.
Diablo 3 Profile
It's like throwing up, you go 10 years without doing it and suddenly you're like hey why not, and then you realize that's a terrible idea.
(All I did to find that link was google "java enum arraylist", and scan the results for answers from StackExchange. Develop your google-fu... feel the power...
Okay, that's what my problem was: you can't ArrayList an enum, instead that example shows that you can make an ArrayList of strings composed of enum values. That's fantastic, and just what I need.
If anyone can help, I can provide more details.
Oh wow. I didn't think something as useful as /r would be so new. On the other hand, maybe I'm missing some more common idiom for what I'm doing.
What's the usual Perl way to pull a single pattern match? For instance, if you have the string "abcdef", how would you get the single capture from the pattern "bc(.)e" as a return value, such that you can use it when defining a hash?
In Lua this would be:
local hash = { d = string.match("abcdef", "bc(.)e") }But the closest I've gotten in Perl 5.8.8 is two lines:
my ($d) = ("abcdef" =~ m/bc(.)e/); my $hash = { d => $d };I'm having surprisingly little luck Googling for this. Isn't this Perl's forte?
I don't think I'm understanding you right, can you explain again or give a different example?
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
edit: Oh, duh. I didn't even realize you could subscript an anonymous array context:
my $hash = { d => ("abcdef" =~ m/bc(.)e/)[0] };That works exactly as I was hoping it would.
The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
Does something like this work?
my %hash = ( "d" => ("abcdef" =~ m/bc(.)e/g)[0] )The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
What a nifty little language, though. Hard to believe that something as ugly as PHP was "inspired" by it.
Should we burst his bubble now guys, or let him marinate in it for a while before we link to the Perl obfuscation competition?
Yeah, that's how I try to look at those things. I don't care if you ever use the code I write or not as long as you're willing to pay me to keep writing it.
Socket clientReader = new Socket(//predetermined port that server is listening to); Socket clientWriter = new Socket(//predetermined port that server is listening to); //in client ObjectInputStream in = new ObjectInputStream(clientReader.getInputStream()); run(){ while(true){ String message = (String)in.readObject(); System.out.println(message); } } //server Socket serverReader = new Socket(//client write socket); Socket serverWriter = new Socket(//client read socket); //in server sendMessage(String message){ ObjectOutputStream out = new ObjectOutputStream(serverWriter.getOutputStream()); out.flush(); out.writeObject(message); } //service fetcher Socket ServiceFetchWrtier SFW = new Socket(//server reader socket); Socket ServiceFetchReader SFR = new Socket(//server write socket); //In service fetcher sendMessage(String message){ ObjectOutPutStream out = new ObjectOutputStream(SFW.getOutputStream()); out.flush(); out.writeObject(message); }Will that print out service fetcher's message to client? My question then is, how would I take the input from the client and pass it to a module the service fetcher has fetched and executing and awaiting input? Is the answer to pass along serverReader and ServerWriter sockets to a module that's being executed and use those for input and output? So a constructor would look like://Service Fetcher Constructor public ServiceFetcher(Socket serverReader, Socket serverWriter, int command){ ObjectInputStream in = new ObjectInputStream(serverReader.getInputStream()); ObjectOutputStream out = new ObjectOutputStream(serverWriter.getOutputStream()); out.flush(); if(//command == service number){ service(serverReader, serverWriter); } in.close(); out.close(); }Would something like that work?
Or do I just put them all in a package and pass the server object to the service fetcher, and then do something like:
Public ServiceFetcher(Server MAINSERVER, int command){ this.server = MAINSERVER; if(//command == service number){ service(MAINSERVER); sendMessage("Executing service: "+command); } } sendMessage(String message){ server.sendMessage(message); }Google+ Profile Origin: 13Evigilant Steam: Evigilant
I cannot resist linking to PHP: a fractal of bad design.
For extra fun, search that page for "INT_MAX".
I have a little Ruby program that takes in two files: a "degree" spec and a list of the user's courses. A degree is broken up into requirements. A requirement has a name ("200 level courses"), a quantity (4), and a list of courses which can satisfy that requirement. (CSCI210, CSCI250, CSCI280, etc) The Ruby program reads the degree spec and the list of courses and figures out what's left.
My vision is that the user comes to the app, picks their major, and then clicks a button for each course they've completed in the major, then gets a message showing them what they have left to do.
So, looking at what I have set up for myself, it seems like I'm going to need to be storing stuff in a database for later retrieval? Show the page for the user, hit the DB to get the degree spec, display the course options, do the logic, display the result.
02:07: ~/rails_projects/specs $ rails console Loading development environment (Rails 3.2.3) >> fil = File.new("list.txt", "r") => #<File:list.txt> >> fil.each_line do |l| ?> rails generate model #{l.strip} name:string quantity:integer courses:array >> end NameError: undefined local variable or method `model' for main:Object from (irb):3 from (irb):2:in `each_line' from (irb):2The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
Kind of, get rid of the two sockets and get two separate streams from one socket. Then, after a client connects, wait until there's data. Check how many bytes, read it, Append it to an array or string until you get a delimiter -- you need a delimiter of sorts to know your message is done -- and then do whatever you need to do when you reach that delimiter (call a function and pass the string maybe?). I usually use something like 0xff for the delim which isn't really an ascii character (assuming we're using ascii and not unicode).
Sending binary data becomes the fun part.