Alrighty, I need big help. Stumper.
Displaying 1-8 of 8 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
blues_zodiakos

Okay, I've made a really huge function, but there's only one part at the very end that is giving me trouble. I'm going to be general here because I don't want to give away the surprise. :D

I have a string array [63]. Each member of the array has a single character up to a certain array. The int LastCharacter stores the number of the last member of the array that actually stores a character. I want to take all of those members that HAVE a character and combine them into a single string. I THOUGHT I could do this:

For(i=0; i|lessthan|(LastCharacter+1);i++)
{
BigString=BigString+StringArray[i];
}

But apparently I'm totally off on that one. Anyone have any other ideas? Is there some workaround, or am I just being stupid because I'm tired?

-edit

The error it keeps giving me is Unable to Resolve identifier BigString! I'm sure it's that line, too, by clever adding of blank lines and seeing what line number it gives me. Also, all of these the string arrays were defined globally.

Posted on 2004-02-19 15:48:25 (last edited on 2004-02-19 15:51:43)

andy

What's usually done for idioms like this is using the count variable to store the number of elements used. (this is exactly equal to the index of the next free element due to 0-basedness)

Then you can just say

for (i = 0; i < charCount; i++) {
    bigString += stringArray[i];
}


Manually HTMLizing code is painful. :(

Posted on 2004-02-19 16:06:03

mcgrue

pre tag! It's there!

Posted on 2004-02-19 22:15:26

blues_zodiakos

Okay, after much naughtiness, I finally got the code to compile. And it crashes, and crashes good. :( I can't even begin to imagine what I've done to make it do so, I'm not doing anything even remotely crazy(unless you count my spaggetti code...).

If you want to take a shot at it, here's the code.

http://home.comcast.net/~leonardo459/ZTL.vc

It's not too terribly complicated, but it is 400+ lines. :(
Should compile as is, all variables used in it are defined in it.

-edit

I'm pretty sure the problem is somewhere in the last 20 lines or so. :(

Posted on 2004-02-19 22:52:54 (last edited on 2004-02-19 22:59:20)

Overkill

Umm.. Maybe assigning each character to an array isn't the best approach.

I suggest that instead use left() for this, if it has any relevence in this situation. I assume it *is* a textbox function you are trying to do, am I correct?



Code:

for (i=0; i<63; i++)
{
PrintString(5+32,5,screen,0,left(BigString,i));
Showpage();
}




EDIT: Be aware that using for() statements isn't the greatest in the case of textboxes.

Posted on 2004-02-20 01:14:23 (last edited on 2004-02-20 01:19:03)

vecna

Additionally, I've added string tokenizing helper functions that will make word-wrapping textboxes a bit easier. I'll be putting out a new EXE this weekend.

Posted on 2004-02-20 02:12:09

blues_zodiakos

Nope, this has absolutely nothing to do with textboxes. :D The CommandPrompt function that I wrote (to not much success) provides a text input capability. What for, I'm not telling yet. :D

If I can't fix it though, I'm going to have to go about it a different way. I'm kind of shocked that it just crashes on me though with no explanation. The log says it compiled fine. :(

-edit

It's SUPPOSED to be a function that allows the user to input a string, but also supports using left and right to go back in the string, and backspace and delete, as well as home and end. I wanted the string to be up to 63 characters long (I have my reasons. :D). Also, the function had to be real-time, because there are timers that have to be checked in the meantime. If I can get this function running, the full game might be out in a week or two. :D

Posted on 2004-02-20 06:12:25 (last edited on 2004-02-20 06:19:48)

blues_zodiakos

(sorry for the double post. :D)

Alrighty, I didn't figure out the problem, but I rewrote it and it works. Apparently my coding skills REALLY suffer when I'm tired. :D After rereading my old code, I can't believe that the VC compiler actually got that far before exploding from the nonsense I was feeding it. :D

-edit

It doesn't really stop me really, but here is a strange thing - SCAN_DEL, SCAN_HOME and SCAN_END seem to only be picking up the numeric keys, not the regular buttons. I'm sure this is by design, but is there anyway to include scan codes for the regular buttons?

-edit

Now I'm really going to go insane. Incidentally, I'm using almost the EXACT same bit of code that TSB posted, except it's simply not working. I'm beginning to think this might be an error in VC, because now it is giving me an error: Corrupt String Assignment. I think maybe you can't assign data to a string with +.

-edit

Inexpicably, it suddenly worked. I had to do this.

for(i=0; i |lessthan| Lchar; i++)
{
NewCom =Newcom+ Currentchar[i];
}

Sorry, I don't know much html.

Posted on 2004-02-20 20:48:01 (last edited on 2004-02-20 23:50:42)


Displaying 1-8 of 8 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.