PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

my bad programming part 2

This is like the last one but now I am just working one function at a time.

So this function is for saving the configuration which I want to be a text file that contains the filenames of the WAVs in the list control. So to outline here is what I have done

1. Open the filedialog to allow the name to be set
2. Create a CStringArray to hold the names in the ListControl and loop
3. Create a CFile and loop as I write out each name

I know I could skip a step but I figure if I put everything in a array I can modify the function more later if I have the need...

comments please?


Code:

void CHartmanDlg::OnSavecfg()
{
CFile savefile;
CString fname = "theconfig";

CFileDialog fileDialog(FALSE, NULL, fname, NULL, (_T("All Files (*.*)|*.*|")), NULL);
if (fileDialog.DoModal() == IDOK){}


CStringArray thelist;
int nCount = m_lcsounds.GetItemCount();
for (int i = 0;i < nCount;i++)
{
CString xxx = m_lcsounds.GetItemText(i, 0);
thelist.Add(xxx);
}

savefile.Open(fileDialog.m_ofn.lpstrFile,CFile::modeCreate | CFile::modeNoTruncate);

for (int j = 0; i < thelist.GetSize(); i++)
{
CString str = thelist.GetAt(0);
savefile.Write (str, str.GetLength());
savefile.Write ("\n", 1);
}
savefile.Close();
}
Line 7 doesn't properly handle cancellation of the file dialog.

Line 22 should read:

CString str = thelist.GetAt(i);

You should check to see if the output file was successfully created / opened.

Otherwise it looks fine.

Dan East
UMCPmatt · 30 Jul 2002, 04:06 UTC — ok i feel better
I thought I was way off. so it is not as bad as I thought.

Other things I have been wondering.

1. Any recommendation on the best deal for a web host the has asp.net and SQL ?

2. Anyone know a c++ tutorial for making a ACtiveX control for the web. I was making a little game .. and it seems my choices would be ActiveX or java applets.. do I need to get some sort of permission for the general public to use it?

3. How do Java applets interface with a SQL database are there classes for this? (I am thinking of a high score table)

4. Any time frame on the .net for PPC? 1 month? 1 year? I figure I will use c++ and switch over to that eventually.

5. Anyone else find CD-RW useless as me since CD-Rs are so cheap you just throw away a CD rather than change anything on it and its quicker (cd-r)

6. Anyone who is a dummy like me want to recommend any MFC/DX/PPC/COM books that they found finally explains concepts in a way they can understand? Good programmers cannot recommend this since nothing confuses them. (the ppc andre lamothe book was the best book I ever read as far as explaining concepts that I could not grasp before)

7. Any other programmers out of work like me? I am 27 with 2 years programming asp/vb/sql and cannot find work for $35k for 2 months now and thier gonna take my condo from me!

8. Wouldnt a turn table scratching program for the PPC be a cool idea ? I was looking into making one eventually.. shouldnt be too hard

9. Is programming without MFC really harder than not using MFC?

10. Has anyone tried programming the e740 hardware directly with xscale assembly to test the speed? Would this even be possible?

ok.. theres some random thoughts that been going on in my head.. anyone write back!
Michael Y · 30 Jul 2002, 04:14 UTC — ok i feel better
UMCPmatt wrote:
5. Anyone else find CD-RW useless as me since CD-Rs are so cheap you just throw away a CD rather than change anything on it and its quicker (cd-r)


There's the whole environment issue... burning one CD and then using it over and over again is a LOT more environment-friendly than throwing away 500 CDs.
Armegeddon 1:89

And the Lord Smog said, let there be pollution, and there was pollution. On Day 1 the Lord Smog, told men to cut down all the rain forests, and then burn the stumps, and the men did as the Lord Smog commanded. On Day 2, the Lord Smog, told the men to build huge factories with huge smoke stacks, and the men did as the Lord Smog commanded. On Day 3, the Lord Smog, told men to cover all the land on the earth in concreet, and the men did as the Lord Smog commanded. On Day 4, the Lord Smog, told the men to pump all the toxic wastes from their factories into all the earths water, and the men did as the Lord Smog commanded. On Day 5, the Lord Smog, told the men, to burn the factories to the ground, releasing huge amounts of toxic smoke into the air, and the men did as the Lord Smog commanded. On Day 6, the Lord Smog, told men to build huge nuclear bombs, and destroy the Canadians, who were enimies of the Lord Smog, but no one heard the Lord Smogs commandment. The Lord Smog became very angry and threatened to kill all the first born of the world, if the people did not obey. But still the Lord Smog's commandment was not heard. The Lord Smog became very very angry, but then looked down upon the world and saw that all the men, women, and children were dead. On Day 7, the Lord Smog said, oh shit!



Please use CDRWs. This has been a local message from your friends at PocketMatrix.
2. Bear in mind that ActiveX controls really aren't the most portable things... you'd be better off with Java.

3. JDBC - should be heavily documented on Sun's site.

5. For testing things, CDRWs are great.


7. Any other programmers out of work like me? I am 27 with 2 years programming asp/vb/sql and cannot find work for $35k for 2 months now and thier gonna take my condo from me!


I was for a while last year (well, I was on a decent retainer, but not on a contract between last June and last November)... at which point I stopped contracting and took a permanent job.

The problem is that lately the market has been absolutely swamped with people, which means that there are just so many people applying for positions that the businesses can find "cheap" people pretty easily. Finding competant people is a little trickier. :'(

(And this is going to sound elitist, but the market has been mostly swamped with "VB/ASP" programmers because they're the languages the hobbyists tend to "learn").

9. Depends what you're wanting to do.

10. Yes, it's possible (just use the ARM assembler ... and maybe do "bad things" to embed XScale-specific op-codes), but until somebody wants to give/lend me an XScale device and free up some time in my schedule, I can't play. :'(
James S · 30 Jul 2002, 15:35 UTC — ok i feel better
Michael Walker":2abvq1fr]
Why would you throw away 500 CDs?
Old & useless data, "coasters", etc...
UMCP_matt · 30 Jul 2002, 19:23 UTC — i dont throw them away really
I hand them out to other people... most of the time it is CDs full of MP3s

About the job.. yes I know everyone out there can do ASP/VB. That is why I need to try to seperate myself from the crowd. I am just using C++ nowadays and going to take a advacned java class in a month. I also am putting up a website to put the software I have written on it and calling it a 'company'. Beyond that if anyone else has any ideas how I can stand out let me know. I am hoping that being a programmer not just as a job but as a hobby will help some.. and I am 27 and people half my age program better than me and that does not make me feel very good.
UMCP_matt:

It'll come. Don't worry. :) Just keep your head in the books and doing stuff. The biggest problem I have with "coders" I meet on a day to day basis is because they're not really interested in what they're doing. "Hobbyist"s and people like me who do this as a hobby and as a job, are almost always in a better position technically than those who just do it as a day job, learn one language, and then sit on their arse doing the same damn thing for years and years...

Problem is that most businesses don't even bother looking for that kind of initiative. Ho hum.

(Oh, and forget about age.. sure, it's allegedly easier to learn young, but I've seen *spectacular* coders in their 60s, and "wonder kids" who couldn't code for shit). 27 isn't old, or past it. I hope! :D
UMCP_matt · 01 Aug 2002, 19:45 UTC — when I finally get a interview
I try to make a point that I am not just someone who took the classes and programs for money.

Unfortunatly, my mind does not think very logically so things take me a while to catch on..

But I try to use my fustration energy to set up a web site and put the little programs I make on there.

I should get a 2nd job but then that would leave no time at all to program or read anything.

Then entry.mid lvel jobs are hard to come by and 200 people send thier resumes in for them also
UMCP_matt · 01 Aug 2002, 22:58 UTC — little problem
Code:

for (int j = 0; j < thelist.GetSize(); j++)
{
CString str = thelist.GetAt(j);
f.Write (str, str.GetLength());
}
//f.Write ("\n", 1);
f.Close();


the txt file should say

bmyname.wav

but instead it says


b m y n a m

i have a feeling it has something to do with unicode/ansi.. what am I doing wrong?
BurningSheep · 01 Aug 2002, 23:11 UTC
A unicode string is 2 bytes per character so you should probably use
Code:
f.Write (str, 2*str.GetLength());
UMCP_matt · 05 Aug 2002, 06:44 UTC — another easy question
So how do I send a carriage return? \n does not seem to work

Code:

for (int j = 0; j < thelist.GetSize(); j++)
{
CString str = thelist.GetAt(j);
f.Write (str, 2*str.GetLength());
f.Write ("\n", 2);
}
'\r' is a carriage "R"eturn
'\n' is a the "N"ewline character
UMCP_matt · 05 Aug 2002, 07:06 UTC — i dont get it
I made the change and I still get those rectangle characters when I open up notepad and view the file. :evil: :evil:

Code:

for (int j = 0; j < thelist.GetSize(); j++)
{
CString str = thelist.GetAt(j);
str = str + '\n';
f.Write (str, 2*str.GetLength());
//f.Write ('\r', 2);
}
BurningSheep · 05 Aug 2002, 12:41 UTC
Mac uses \r as end-of-line character, Unix and the likes use \n, but DOS/Windows uses both \r\n
Now if you are using a good text-editor it doesn't matter what you use, but notepad is definitely not a good text-editor.
Without wanting to start an editor war, my favourite editor ever is:

<a href="http://www.ultraedit.com">UltraEdit</a>

(it can automatically convert Unix->DOS and back if you want it to).
UMCP_matt · 05 Aug 2002, 21:26 UTC — so I am doing everything right?
so how come I am getting a rectangle character rather than seeing the text on another line though??
BurningSheep · 05 Aug 2002, 22:39 UTC
I'm not familiar with the CString object at all, but I'm not sure whether you can concatenate a CString and a character the way you are trying...

try this instead:

Code:

for (int j = 0; j < thelist.GetSize(); j++)
{
CString str = thelist.GetAt(j);
str = str + CString(_T("\r\n"));
f.Write (str, str.GetLength() * sizeof(TCHAR));
}


[edit]made it unicode-aware[/edit]
EditPad Lite or Pro is a great editor

but the Notepad in WindowsXP gets rid of those rectangular characters, it reads them correctly just like Wordpad.