Page 2 of 2

Re: Half Strict Compilation mode

Posted: Thu Aug 04, 2011 3:17 am
by BarrySumpter
I'm pretty sure field is a keyword for the compiler.

Here isn't tFldName a local/temporary variable?
put "CustomerName" into tFldname
Or does the compiler know that tFldnameis an object and I don't need to type cast?
Can you have a local variable name with spaces?


Again, my practice is Not to use spaces in field names ever.
And not Need to use "" around names.
the space is an extra key stroke.
The " is two key strokes.
Totaling to 5 keystrokes at least extra per name.
Again, we're measuring the difference in micro-seconds of execution speed.


And here fRlfName is a control object?
put "Milo Fenderbender" into field tFldname
Where spaces in control names are allowed.

It was just a thought.
I don't know enough about the language and all its incredible variations.
But I can see in my head it could be ticked on to insert ""
with the "" highlighted for replacement.
and if a delete key is NOT pressed then the entry would begin inside the "|".

Re: Half Strict Compilation mode

Posted: Thu Aug 04, 2011 4:33 am
by mwieder
Ah. I start to see where you're going with this...
No,

Code: Select all

put "Milo Fenderbender" into field tFldName
in this example puts the string "Milo Fenderbender" into field "CustomerName" since we've already put "CustomerName" into the variable tFldName. The "put" isn't assigning a name to the field, it's storing a value into the field.

I never use spaces in object names. You can do it, but I think it's Bad Practice. And I don't think you can get away with space in variable names, although I haven't ever tried it. There are many syntactical obstacles to assigning quotes automatically because the language is so rich and supports so many variations.

Re: Half Strict Compilation mode

Posted: Thu Aug 04, 2011 4:59 am
by BarrySumpter
Yep gotcha, I read that as two examples of your point and not one point with two script lines. My bad.
That situation solved with my "" selected idea.

Code: Select all

I never use spaces in object names. You can do it, but I think it's Bad Practice.
Agreed. Well for me anyway. If others wanna then no prob.
And I don't think you can get away with space in variable names, although I haven't ever tried it.
Just tried

Code: Select all

Local "my xxx Var"
Wouldn't compile. I though that might be where we were headed.

Code: Select all

There are many syntactical obstacles to assigning quotes automatically because the language is so rich and supports so many variations.
Yeah fair enough.
Hoping my "" selected idea will tilt the balance enough to have a go.
Even though I will probably never use it. LOL

Re: Half Strict Compilation mode

Posted: Thu Aug 04, 2011 5:14 am
by mwieder
Here's what I usually do. This saves a lot of typing quotes and also cuts down on typo errors, which are especially prone to occur in quoted strings:

constant kFldName= "CustomerName"
constant kFldAmount= "InvoiceAmount"

put "hello, bucko" into field kFldName
put tInvoiceTotal into field kFldAmount
...

Re: Half Strict Compilation mode

Posted: Thu Aug 04, 2011 5:20 am
by BarrySumpter
Hey! Hey! Hey!
Very cool. As yet another idea I would never have tried.

If that saves the milisecond execution time?

If not then why not just use:

Code: Select all

put "hello, bucko" into field lblCustomerName
put tInvoiceTotal into field txtInvoiceAmount
i.e. without the constant dimentioning.

Re: Half Strict Compilation mode

Posted: Thu Aug 04, 2011 11:25 pm
by mwieder
Barry-

It's not so much that it saves execution time, but more that it a) saves error-prone typing and b) allows you change the name of a control in one place without having to search through your code for all the places you used it. I didn't put a lot of example stuff in the previous post, but I'd normally do this if I'm access a control more than a couple of times. If I have a script that needs a given field name a dozen times or so (and I do) it's much more convenient to have it in a constant declaration than to have to specify a quoted field name a dozen times and maybe end up with a typo or three.

Re: Half Strict Compilation mode

Posted: Thu Aug 04, 2011 11:51 pm
by BarrySumpter
Fair enough.

I'd use find/replace.

Re: Half Strict Compilation mode

Posted: Fri Aug 05, 2011 12:06 am
by jacque
mwieder wrote: I never use spaces in object names.
Me either. At least, not until Bill Marriott mentioned the convenience of using a number at the end of names as a counter or identifier in certain situations. That way you don't have to parse the end of the name looking for a number, you can just grab the last word of the name. I still use one-word field names mostly, but one time I found this technique is useful.