Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any comment on using & ?

Status
Not open for further replies.

andreateh

Programmer
Jul 19, 2003
83
SG
in A form i have 3 textbox, text1,text2,text3. And my code as below :
Code:
for i =1 to 3
   cObject = "text"+str(i,1)
   cMsg = "ERR_MSG"+STR(i,1)+"_LOC"

   With &cObject
      IF .value <= 0
           MESSAGEBOX(&cMSG,0+48,ERR_TTL_LOC)
	   .SetFocus()
	    RETURN 
      ENDIF 
   Endwith 
endfor

Is it have any others shortcut instead of using & ?
 
In some instances you can use () instead of &

Examples

lcTable = boo
USE &lcTable
* OR
USE (lcTable)


lcFile = boo.txt'
IF FILE('&lcFile')
MESSAGEBOX('1')
ELSE
MESSAGEBOX('2')
ENDIF
* OR
lcFile = 'boo.txt'
IF FILE((lcFile))
MESSAGEBOX('3')
ELSE
MESSAGEBOX('4')
ENDIF

In your particular instance - try removing the & and enclosing the cObject in () or (()).

From the buzz I have heard - this is more efficient than &




Jim Osieczonek
Delta Business Group, LLC
 
Code:
for i =1 to 3
   cObject = "text"+str(i,1)
   cMsg = "ERR_MSG"+STR(i,1)+"_LOC"

   With (cObject)
      IF .value <= 0
           MESSAGEBOX((cMSG),0+48,ERR_TTL_LOC)
       .SetFocus()
        RETURN 
      ENDIF 
   Endwith 
endfor

or

Code:
for i =1 to 3
   cObject = "text"+str(i,1)
   cMsg = "ERR_MSG"+STR(i,1)+"_LOC"

   With ((cObject))
      IF .value <= 0
       MESSAGEBOX(((cMSG)),0+48,ERR_TTL_LOC)
       .SetFocus()
        RETURN 
      ENDIF 
   Endwith 
endfor

both mehtod i have try.. but can't. I aslo heard that using & will be bit slow.
 
Try this test
Code:
oObj = CREATEOBJECT('Custom')
oObj.AddProperty('myprop',0)
cObj = 'oObj'
_t=SECONDS()
FOR i=1 TO 100000
	WITH &cObj
		.myprop = i
	ENDWITH
NEXT

?'Macrosubstitution',SECONDS()-_t

_t=SECONDS()
FOR i=1 TO 100000
	WITH EVALUATE(cObj)
		.myprop = i
	ENDWITH
NEXT

?'EVALUATE()',SECONDS()-_t

 
is another period missing? maybe you could try this:

Code:
for i =1 to 3
   cObject = "text"+str(i,1)
   cMsg = "ERR_MSG"+STR(i,1)+"_LOC"

   With [b]&cObject.[/b] 
      IF .value <= 0
           MESSAGEBOX(&cMSG,0+48,ERR_TTL_LOC)
       .SetFocus()
        RETURN 
      ENDIF 
   Endwith 
endfor


kilroy [trooper]
philippines
"and that's what we call creativity..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top