@ThinkDigital - I don't mind at all. I do what I do for the same reason you posted what you did. You were here; I was elsewhere. Thanks for taking up my slack!
@WindowsKiller - That actually compiled? I would not have thought it possible.
if quote_open = 0
then quote_open = x
else quote_close = x
@Inspire - I think that there are some things that need to be clarified a little more. The first thing is that, in the editor, when you are programming, you need the quotes to tell DBPro...this is a text string. For example, this does not do anything:
but this does:
assuming that Text is a string variable.
Next, the
local keyword is very important in functions. Functions are better if they are self-contained and modular. That way, you have flexibility in using them. Local variables are stored on the stack, and can only be seen in the function. If you have a global named i, and a local named i - the function only "sees" the local i, they are different variables, although they have the same name. Local guarantees I am using the one that is in the function. That is very important as it is quite likely that someone will already have a variable named i, and I don't want to trash its value, I want to use "my" i.
This is alot coming at you at once. Pointers are not really BASIC, they are C. Pointers are addresses, not the variables but the address of the variable. They are dwords because they are 32 bits. Integers are signed, and are inappropriate for use as pointers. This is how you get the variable's
value:
The * is called the
indirection operator. It is not multiplication in this case, its pointer indirection. It means simply, "the thing pointed to by ptr". Indirection looks at the left side of the equation (called the l-value), and since databyte is a byte, it takes the address (ptr), and takes a byte from there, and assigns that to databyte. Why do it this way? Because, if you ask DBPro to assign one string to another, it will ignore the first quote character. That is normal, because use you need it to ignore them when you try to do this:
To make a string with quotes in it, you need to hide them a little, as a result of their use. Like I said above, they are a reserved character in any string based system. (In C/C++, too.)
+ Code Snippetglobal str1 as string = "This is a string."
global str2 as string
print str1
str2 = chr$(34) + str1 + chr$(34)
print str2
You cannot, for example do this:
+ Code Snippetglobal str1 as string = "This is a string."
global str2 as string
print str1
str2 = " + str1 + "
print str2
Or any form of that.
In my example, which btw is to take a C-style string and make a DBPro string from it, I use the variable
i because I am using a control structure (while/endwhile) without a terminating condition. I want to limit the string to 32768 characters because BASIC usually limits strings to that length. The function has no idea how long the string is; i just limits that to 32768.
ptr gets incremented because I want to get the
next byte.
buildstr is a string, and it is the string being built, and also it is the return from the function call. I initialize it to nothing, which is called a NULL string. It is simply an empty string, represented by
"". Technically, a single byte of value 0 is what a NULL string is.
It is not surprising that this is not easy for you, if you have not been able to locate the explanation for chr$(). Look here:
Under Help, select "Help Contents", then "Commands". All of the string functions are listed under the item "2. TEXT COMMANDS" Also, you can IM me by clicking the little Yahoo! IM button under this post, or e-mail if you prefer that way. Or just keep this thread open, you option.
Cheers, I hope this helps.