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 / Help with the spaces$ command

Author
Message
Jac
20
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 17th Oct 2004 21:13
hi,

I'm learning about parsing strings at the moment but don't seem to be able to understand how the space$ command works.



Shouldn't the code in the snippet print 6. All I seem to get is 0 printed on sreen.

Have i miss understood the syntax of am I doing something wrong.

Thanks

JC

These are not the droids you are looking for.
Richard Davey
Retired Moderator
22
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 17th Oct 2004 21:23
You haven't set X to anything, try adding x=6 at the top of your code. Also, you're just printing out X (which, as it hasn't been set to anything, will have a value of zero).

space returns a string consisting of X spaces. Printing it out won't really show much Try this:



"I am not young enough to know everything."
- Oscar Wilde
Jac
20
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 17th Oct 2004 21:38
Thanks Richard

I completely mis understood what the command did. I was trying to find a way to locate and count the spaces in a sting that I already have. I first tryed this



but that's not working either.

Anyone got any pointers on how to locate spaces in a string?

JC

These are not the droids you are looking for.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Oct 2004 21:47
Maybe you aren't setting the stringSix$ variable this time, because you code works just fine:



*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Jac
20
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 17th Oct 2004 21:53
Thanks IanM

I ws sitting here thinking `but that code is right` then I went back to my actual code and spotted I'd missed an = from in front of the " ".

Doh. Spot the new guy!

Thanks again,

JC

These are not the droids you are looking for.

Login to post a reply

Server time is: 2024-09-23 02:25:34
Your offset time is: 2024-09-23 02:25:34