• Welcome to Valhalla Legends Archive.
 
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Dyndrilliac

#16
.NET Platform / Re: C++/CLI: priority stack problems
November 14, 2006, 02:49 AM
I've been reading through the C++/CLI specification (partly out of curiosity, partly out of necessity), and it makes it sound as though indirection in the way K described is a real pain in the ass. I made the following alterations: void Swap(Node^ val1, Node^ val2) {
Node^ temp = val1;
val1->value = val2->value;
val2->value = temp->value;
}
This yields the following output:
Quote6

1
22
333
333
333
333

0
Press any key to continue . . .
For some reason it changed all of the items with priorities into copies of the bottom-most item without a priority.

As far as a different route of implementation is concerned, I would rather make my current method work. I will need to know how to implement sorting in C++/CLI anyway, and this way I can change the sorting mechanism at my leisure.

Edit: The following change was made: void Swap(Node^ val1, Node^ val2) {
Object^ temp = val1->value;
val1->value = val2->value;
val2->value = temp;
}
The change yielded the following output:
Quote6

Higher priority data.
333
3
22
1
1

0
Press any key to continue . . .
It's getting closer.
#17
.NET Platform / C++/CLI: priority stack problems
November 14, 2006, 01:31 AM
I'm implementing my own priority stack as part of a project, and ran into a problem. For some reason, I can't seem to sort the stack properly. I believe the problem lies in my Swap routine. Here's the relevant code: Node^ GetNode(long i) {
if (!ValidIndex(i)) {
throw gcnew Exception("Index out of range.");
} else {
Node^ temp = this->first;

while (i) {
temp = temp->next;
i--;
}

return (temp);
}
}

Byte GetNodePriority(long i) {
if (!ValidIndex(i)) {
throw gcnew Exception("Index out of range.");
} else {
Node^ temp = this->first;

while (i) {
temp = temp->next;
i--;
}

return (temp->priority);
}
}

bool ValidIndex(long i) {
return (this->size >= i);
}

void Swap(Node^ val1, Node^ val2) {
Node^ temp = val1;
val1 = val2;
val2 = temp;
}

void Sort() {
// BubbleSort Algorithm!
long i = this->size;

for (int x = 0; x < i; x++) {
for (int y = x + 1; y < i; y++) {
if (GetNodePriority(y) < GetNodePriority(x)) {
Swap(this->GetNode(y), this->GetNode(x));
}
}
}
}

int main() {

Stack^ s = gcnew Stack;

s->Push("Highest priority data.", 0x00);
s->Push("Higher priority data.", 0x32);
s->Push("High priority data.", 0x64);

s->Push(1);
s->Push(2);
s->Push(3);

s[0] = 1;
s[1] = 22;
s[2] = 333;

Console::WriteLine("{0}",s->Size);
Console::WriteLine();

long x = s->Size;

for (long i = 0; i < (x); i++) // Because the internal count of the stack changes
Console::WriteLine("{0}", s->Pop()); // as Pop's are peformed, it is necessary
// to keep a constant external upperbounds
Console::WriteLine();
Console::WriteLine("{0}",s->Size);

return (0);
}
Here's the program output:
Quote6

1
22
333
High priority data.
Higher priority data.
Highest priority data.

0
Press any key to continue . . .
Sort() is called upon completion of a successful Push() operation, and at the beginning of the Pop() routine. The output should be in reverse order, but nothing I do to the sorting algorithm itself makes any difference, therefore the problem must be that the nodes aren't being moved. Anyone have any suggestions?
#18
.NET Platform / [C++/CLI] Compiler Error C2352
September 01, 2006, 05:24 PM
MSDN defines C2352 as this: "A static member function called a nonstatic member function. Or, a nonstatic member function was called from outside the class as a static function."

Unfortunately, it doesn't mention how one would go about calling a non-static member method from outside the class as a non-static function. I got the error on this code:frmMain::AddDebug(szTextBuffer, Drawing::Color::Red);Can anyone clarify why the compiler thinks I am trying to call a static method, and what to do about it? Both class member-methods are non-static and public.
#19
Oh! Thanks for the info, now things make a lot more sense. I'm really starting to enjoy C++.net. The interoperability is really nice, as is garbage collection.
#20
.NET Platform / [C++.NET] Variable length arrays?
August 31, 2006, 01:59 PM
I've been trying to figure out how the correct syntax for creating a variable length array should go, and having very bad results. Here's what I've got:array<Byte>^ MyBuffer[(const UInt32)i_len+4] = {0};I also tried:
  • Array ^MyBuffer = System::Array::CreateInstance(System::Byte::typeid, i_len+4);
  • Array *MyBuffer = System::Array::CreateInstance(System::Byte::typeid, i_len+4);
  • const UInt32 Len = (i_len+4);
    array<Byte>^ MyBuffer[Len] = {0};
All to no avail. Also MSDN spits up bunches of results in their Search utility with old syntax making it pretty worthless -.- I'm using .NET Framework 2.0 btw.
#21
Edit: I feel kind of stupid. Nevermind. I realize now I had a "::" operator where a "->" operator should have been.

I'm converting the above code to C++.NET, and I'm having a bit of trouble with the Insert_CSTR method. I'm using the following namespaces:using namespace System;
using namespace System::Data;
using namespace System::IO;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
Here's my code:Void __inline Insert_CSTR(String^ cstring) {
array<Byte>^ByteArray = Encoding::ASCII->GetBytes(cstring);
for (UInt16 i = 0; i < ByteArray->GetLength(); i++) {
Insert_BYTE(ByteArray[i]);
}
Insert_BYTE(0);
}
Here's the error:f:\backup\public\source code\c++.net\personal projects\dyslexicchat v2\clsPacketBuffer.h(59) : error C2039: 'GetBytes' : is not a member of 'System::Text::Encoding::ASCII'
        f:\backup\public\source code\c++.net\personal projects\dyslexicchat v2\clsPacketBuffer.h(59) : see declaration of 'System::Text::Encoding::ASCII'
f:\backup\public\source code\c++.net\personal projects\dyslexicchat v2\clsPacketBuffer.h(59) : error C3861: 'GetBytes': identifier not found
I'm wondering where the GetBytes() method that the code shows is located; I'm using the .NET Framework v2.0.
#22
Quote from: FrOzeN on May 01, 2006, 11:22 PM
Just a thought, but if this were to happen. Would google not just locate there network in a different country in which this law wouldn't apply?
The big communication companies still control what content gets to your computer from the internet. Don't think they won't just lock out or artifically degrade the quality of hosting companies who aren't playing by the rules.
#23
I personally don't know what my life would be like without Google. I find myself all the time wishing I had a computer on hand so I could Google something I just read, heard, or saw. I've become so dependent on the ability to see something being talked about and being able to Google it, that I can't see myself making due without it.
#24
NOTE: I briefly searched the forums in an attempt to make sure this same topic had not already been posted about, so if I missed it somehow, please just delete it and move on - my apologies.

Soon, the United States Congress will vote on whether to support Network Neutrality or not. Network Neutrality is a law that requires ISP's, and Webhosting companies to give every site the same amount of bandwidth for the same reasonable price. This means that the website that you have hosted for 10$ a month has access to the same amount of bandwidth as the site that Big Corporation Co. has paid the same 10$ a month for from the same hosting company.

Big telecommunications companies like Comcast, MCI, and AT&T, are trying to get Network Neutrality revoked so that they can provide bandwidth to companies based on how much they pay for it. For example, Wal-Mart's website will pay for a staggering amount of bandwidth, while non-profit web-sites like Wikipedia will only be able to afford what they already pay, meaning Wikipedia runs at the same speed as a Freewebs site while Wal-Mart's site could withstand a DDoS attack beyond what any of you could fathom.

This in effect means that only the huge multi-billion dollar corporations could afford to extend their business to the Web, killing all the current free services we take for granted - Google, Wikipedia, these forums, PlanetSourceCode, Gamefaqs/IGN/Gamespy/Gamespot, Newegg, etc.

I know you are saying to yourself right now, "That could never happen." Well, it's coming down to the wire, and it's imposssible to tell how Congress will vote. Many of our incredibly corrupt members of congress lay in the deep pockets of the corporations that support the movement, and only an overwhleming show of opposition will make a difference. For this reason, MoveOn.org is sponsoring a petition to support Network Neutrality. You all need to sign the petition. We currently have over 250,000 signatures.

Sign here!
#25
Ah, I see. So depending on which action I want to take, setting the file pointer at either the beginning or the end of the file will take care of that - thank you.
#26
I've been perusing the PHP documentation over at www.php.net and have run into some some problems with certain functions being rather ambiguous in their exact use.

The most prominent example is fwrite(). I can't figure out if fwrite() overwrites the entire file with the data you give it, or if it simply appends. If fwrite() overwrites the files contents, how would I write multiple lines to a single file? Does the standard newline escape sequence work ('\n')? If the function simply appends, how would I clear the file out?

I realize the first reply I will get will most likely be, "Why don't you test it out, and see for yourself?". I am not at home, and killing some time writing some pseudo code and do not at the moment have the time to be experimenting. I would rather know sooner than later, so that I can get more work done than I would otherwise be able to do.

I appreciate any and all on-topic replies.
#27
Computer Support Issues / Help Setting up a LAN
March 30, 2006, 09:46 PM
I just recently bought a Dynex DX-ESW5 5 Port Standard Ethernet Switch, to setup a small LAN at my home. However, I am having issues with all of my devices save one not being able to connect. My main Desktop PC can connect to the net, but my Laptop (Also, my Laptop does not appear on my LAN in My Network Places) and PS2 cannot. I have hooked up everything properly as far as I can tell, and I configured my PS2 and LAptop to have static IP addresses while my main PC is set to resolve it's IP automatically using DHCP (I'm using Comcast Cable for my ISP, if that's of any relevance). I have ran the Windows Network Setup Wizard on both my Laptop and Desktop, to no avail.

My Ethernet Switch does not come with a built-in firewall, so I shouldn't need to forward my ports or create a DMZ.

Any suggestions or help with this issue is appreciated.

Edit: I'm using Windows XP Pro (32-bit) on both PC's.
#28
Quotec:\program files\microsoft visual studio 8\vc\include\stdlib.h(395) : error C2061: syntax error : identifier '_CountofType'
{
template <typename _CountofType, size_t _SizeOfArray>
char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
#define _countof(_Array) sizeof(*__countof_helper(_Array))
}
#29
Thanks much, K! It works now. I kinda was just assuming, that since my old VC++6 project file was configured to link with user32.lib, when this new IDE imported and converted the project file to the new format that it would carry the linker options over as well. Not to mention, whenever I started a new project in VC++6, it by default linked with some of the most constant libraries.
#30
I installed the Platform SDK, but now I'm having more problems. It calims that I have unresolved externals when I attempt to use FindWindow() and SendMessage(). Here's the error:
QuoteWA_SongTitle.obj : error LNK2019: unresolved external symbol __imp__SendMessageA@16 referenced in function "char const * __cdecl WA_GetSongTitle(void)" (?WA_GetSongTitle@@YAPBDXZ)
WA_SongTitle.obj : error LNK2019: unresolved external symbol __imp__FindWindowA@8 referenced in function "int __cdecl WA_IsRunning(void)" (?WA_IsRunning@@YAHXZ)
I don't get what's wrong. I went into "Tools->Options", and then I went to "Projects and Solutions->VC++ Directories". Then, I added the LIb, INCLUDE, and BIN directories for the Platform SDK. I didn't know which directory I needed to add for "Source" and "Reference" directories.