I was checking out the forums to see what problems others have (maybe help where I can), and I think I tripped into something that reminded me of a problem I have had (or maybe currently have) and do not know it.
over in Control Get Text in SDK? about getting text from a control written in SDK to be used in a DDT program, I noticed that Fred Harris mentions:
key points jumped out at me..."What IF????"
*** WARNING *** The below is my BAD attempt at describing what I am wondering, so please no "Holy-Wars" over my incorrect terminology or mis-phrasing

That said Dim vs declaring (mixed terminology) lets say for simplicity sake, if I have a global declared as string, and one of my functions use that variable, and I have not put anything into the variable yet, does this use a invalid location (that Windows or compiler or whatever) may or may not forgive me and not cause a problem (until it causes a problem)?
Hopefully not TOO confusing if you get what I am trying to ask, but I know I confused myself trying to describe how to ask
over in Control Get Text in SDK? about getting text from a control written in SDK to be used in a DDT program, I noticed that Fred Harris mentions:
If you dimension a dynamic string variable [b/]and nothing is assigned to it[/b] then no memory to put anything has been allocated. That is why Byval Strptr(var) crashes. The api will start moving characters to an invalid location. That is why most api programmers use asciiz variables heavily in their code. In the situation above with your code, it makes more sence to dimension an asciiz variable long enough to hold the string, then just put that in the function call. Since basic's default parameter passing mechanism is a pass by reference, the address of the asciiz string will be passed to the Api - and that is what it wants - an address where it can start copying characters to.
*** WARNING *** The below is my BAD attempt at describing what I am wondering, so please no "Holy-Wars" over my incorrect terminology or mis-phrasing


- In my past I tried to stay away from pointers, asciiz, and anything I did not understand as much as I could (yep I am a VB refugee)
- What I did not realize was passing a variable was by default "BYREF" and not the "BYVAL" idea (aka a "Hello World", I did not know I was passing a pointer and not the words "Hello World")
- I used globals for variables that had to be passed among many functions (and yes I do know now that many functions could be changing the variable at the same moment and cause a problem)
- In the below the use of DIM I know can be easily misconstrued with declaring a variable
That said Dim vs declaring (mixed terminology) lets say for simplicity sake, if I have a global declared as string, and one of my functions use that variable, and I have not put anything into the variable yet, does this use a invalid location (that Windows or compiler or whatever) may or may not forgive me and not cause a problem (until it causes a problem)?
Hopefully not TOO confusing if you get what I am trying to ask, but I know I confused myself trying to describe how to ask

Comment