xBase question
-
In a PRG file, a character array is declared as:
char(1) myvar[11]
and is initialized like:
myvar[1] = Chr(32)
myvar[2] = Chr(45)
...
myvar[10] = Chr(124)My question is, since
myvar[11]
was never assigned a value, what value would I get? I don't have access to a compiler/interpreter, only the source code. Thanks. - DC"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
In a PRG file, a character array is declared as:
char(1) myvar[11]
and is initialized like:
myvar[1] = Chr(32)
myvar[2] = Chr(45)
...
myvar[10] = Chr(124)My question is, since
myvar[11]
was never assigned a value, what value would I get? I don't have access to a compiler/interpreter, only the source code. Thanks. - DC"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
False. All variables in xBase are False by default. At least in FoxPro, that it.
If it's not broken, fix it until it is
-
False. All variables in xBase are False by default. At least in FoxPro, that it.
If it's not broken, fix it until it is
Kevin Marois wrote:
All variables in xBase are False by default.
Regardless of type?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Kevin Marois wrote:
All variables in xBase are False by default.
Regardless of type?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
xBase langauges are loosley typed, so it will get its type when assigned to.
If it's not broken, fix it until it is
-
xBase langauges are loosley typed, so it will get its type when assigned to.
If it's not broken, fix it until it is
Kevin Marois wrote:
...so it will get its type when assigned to.
But if there was no explicit assignment?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Kevin Marois wrote:
...so it will get its type when assigned to.
But if there was no explicit assignment?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
Each element in the array that is not assigned to will be False It's important to remember that xBase languages are loosely typed, so this will compile and run
char(1) myvar[11]
myvar[1] = Chr(32)
myvar[2] = Chr(45)
myvar[3] = "Hello"
myvar[3] = DATETIME()
myvar[10] = Chr(124)See this[^] Note that it says:
VFP is a weakly typed language, that is, the compiler allows operations such as assignment and comparison among variables of different types. For example, VFP allows the value of a variable to be cast to another type. The ability to use variables of different types in the same expression promotes flexibility as well as efficiency.
and
Note: Strong typing in Visual FoxPro 7/8/9 SP2 is not enforced at compile or run time, but is used primarily at design time.
This is true for Visual FoxPro, and for FoxBase and dBase, all of which are xBase languages. Do you know what language this code was written in?
If it's not broken, fix it until it is
-
Each element in the array that is not assigned to will be False It's important to remember that xBase languages are loosely typed, so this will compile and run
char(1) myvar[11]
myvar[1] = Chr(32)
myvar[2] = Chr(45)
myvar[3] = "Hello"
myvar[3] = DATETIME()
myvar[10] = Chr(124)See this[^] Note that it says:
VFP is a weakly typed language, that is, the compiler allows operations such as assignment and comparison among variables of different types. For example, VFP allows the value of a variable to be cast to another type. The ability to use variables of different types in the same expression promotes flexibility as well as efficiency.
and
Note: Strong typing in Visual FoxPro 7/8/9 SP2 is not enforced at compile or run time, but is used primarily at design time.
This is true for Visual FoxPro, and for FoxBase and dBase, all of which are xBase languages. Do you know what language this code was written in?
If it's not broken, fix it until it is
Kevin Marois wrote:
Do you know what language this code was written in?
Not exactly. I heard it was xBase III, but I've seen signs of xBase V. The files have PRG extensions.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Kevin Marois wrote:
Do you know what language this code was written in?
Not exactly. I heard it was xBase III, but I've seen signs of xBase V. The files have PRG extensions.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
Ya, most xBase languages are pretty similar in their syntax. If it compiles in one, it should in another with minimal work.
If it's not broken, fix it until it is
-
Ya, most xBase languages are pretty similar in their syntax. If it compiles in one, it should in another with minimal work.
If it's not broken, fix it until it is
Kevin Marois wrote:
If it compiles in one, it should in another with minimal work.
The problem is I'm converting a portion of it to C.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Kevin Marois wrote:
If it compiles in one, it should in another with minimal work.
The problem is I'm converting a portion of it to C.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
Lucky you :) The thing to remember is that you really don't know what's in a variable until runtime. In FoxPro you can do
Customer = "Smith"
Customer = CreateObject("Excel.Application")
Customer = .T.Now a later version of FoxPro added the 'AS' keyword:
LOCAL CustomerName AS String
but this is for intellisense only and doesn't constrain the variable to a type, so you can still do
LOCAL CustomerName AS String
CustomerName = 10+5It's not uncommon in older apps to see a variable declared as Public in the startup program, then see its value changed all over the place. This is hell on earth. Here's a FoxPro forum [^]you can use. I'v been a member there for many years, and most people there are very knnowledegable.
If it's not broken, fix it until it is