PDA

View Full Version : Programming problem : need help adding string variables together



jcw@w-inc.net
01-05-2004, 12:02 PM
i am trying to add three string variables together to create a filename on the fly in the code. my code looks like this

&prefix bit2
&fileNumber 1
&suffix .sbp
&fileName &prefix &filenumber &suffix

the problem is that i expect the &fileName to have a value of

bit21.sbp

the value that is being returned is

bit2 1 .sbp

with spaces in the name between the variables which i am adding.

can anyone help me?

chris

ron_cleaver
01-05-2004, 12:53 PM
Chris,

This is just a guess, but I'd try this:

&fileName &prefix&filenumber&suffix

jcw@w-inc.net
01-07-2004, 12:34 AM
no ron,

i have tried that one. it treats the grouped variables as one big variable.

any more ideas?

chris

Brady Watson
01-07-2004, 02:02 AM
Chris,

I haven't had the need to do this sort of thing yet, but what I am guessing is that it is treating the 1 as a number and not as text. Goofy things like this happen when you try ot concatonate a character string and an integer.

For the heck of it, try using the word 'one' instead of the integer '1' and see how it works. I know that this would be a pain if you were using 500 different files...If you're using a few, it's no big deal.

Let me know how you make out.

-Brady

chamcook
01-08-2004, 12:45 PM
Chris
I had a problem like this when writing contours for the NC generator in Vector. In that program if I inadvertantly hit the spacebar at the end of a line before hitting enter to go to the next line an unwanted space would show up in the code.
(Like after your "bit2". Im not sure if the SB editor would act in the same way.

bill.young
01-08-2004, 09:27 PM
Hey Chris,

This may not be exactly what you want to do, but if the "bit2" and ".sbp" parts don't need to change then this should work for you in the Windows software...


&filenumber = 1
&filename = "bit2" & &filenumber & ".sbp"

mrdovey
01-11-2004, 03:47 PM
Chris...

If you aren't able to solve this one within the normal SBP context, e-mail me and I'll write an external string concatenator (CAT.EXE) for you to use in your SBP program.

Morris

bill.young
01-11-2004, 05:24 PM
Hey Chris,

After playing around in the Windows software a litle more I think this is the syntax that will do what you want...

&prefix = bit2
&filenumber = 1
&suffix = .sbp
&filename = &prefix & &filenumber & &suffix

Hope this helps,
Bill