Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Array Question

Author
Message
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 12th Mar 2009 23:22 Edited at: 12th Mar 2009 23:23
I am finally starting to learn about arrays (btw, Sixty Square's tutorial is a big help!) I am trying to create an array that will hold each individual letter of the statement a person types. The following code works technically, but is there a way to simplify it?
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 13th Mar 2009 21:05
Aw, come on! Okay, so it's not the most exciting topic in the world, but one of the eighteen people who have seen this must be able to help, unless they are worse then me(which in pretty hard)

Do we all have to put stupid jokes here?
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 14th Mar 2009 08:35
Technically that code will work, but have you tried running it?

Unfortunately it will not do what you stated you want it to do.

You don't need to use an extra variable([a]) in the for-loop, because it has an intrinsic one that increments automatically; the one you used to declare it: [x].

There is also a command to retrieve the length, in elements, of an array, so calling entry$() again to set the upper bound of your for-loop will work, but since it creates needless overhead, it is unnecessary.

Another useful piece of information is that entry$(1) will allow the effects of backspace to be seen.

So if you care, copy this code and run it to see what happens. You will need to type something in order for it to display anything.


So now that its simplified, you need to use a different command to just retrieve a single character from the entry$ string: MID$() should work perfectly.

Replace

with

and you should be golden.

Cheers.
cguy
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: In my Computer!
Posted: 14th Mar 2009 19:09 Edited at: 14th Mar 2009 20:03
Changing left$ to mid$ is just what I needed.

I'm pretty suprsied at myself. If you knew just how much time I spend with text coding...I was hoping my mistake wouldn't be something I would start hitting myself over. THANKS!

EDIT: When I actually tried it: Paramenter mismatch in expression 'entry$' at line 13.

Do we all have to put stupid jokes here?

Login to post a reply

Server time is: 2024-11-25 10:40:06
Your offset time is: 2024-11-25 10:40:06