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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tell if set deleted is ON/OFF 3

Status
Not open for further replies.

NasibKalsi

Programmer
Jan 8, 2004
417
CA
Hello All:

Is there any function which can return the current value of SET DELETED ??.

My Best
 
Google does not find a way to see this value for me.
I would
Code:
Display Status To File "filename.ext"
and parse the resultant file to find the deleted - on or off

There may be a better way
wjwjr

This old world keeps spinning round - It's a wonder tall trees ain't layin' down
 
Thanks Mike.
I have used this command(set) but could not relate to this function, searched everything else.

My Best

Nasib Kalsi

 
Sorry Baltman. I did not read your post, your answer was so short and backgroud was white.

My Best
 
NasibKalsi,

*-- Save and reset deleted filter status
lc_deleted = SET("DELETED")
SET DELETED ON

*---Code here

*-- Restore deleted filter status
SET DELETED &lc_deleted.


IBS
 
Baltman, yes.

Thanks everyone for your valuabele code.

Fitedgar: That is exactly what I needed it for. Thanks

My Best

Nasib Kalsi
 
You should avoind using macro subst if possible:

LOCAL lcDeleted

m.lcDeleted = Set("DELETED")

Set Deleted On

*!* Do something

If m.lcDeleted = "OFF" then
Set Deleted Off
Endif
 
Hi Calloatti:

I have used it from time to time, especislly to save lines of repeted code. However, I never tried to find out if it is a good idea or not. I use them in for loops, while loops, to assign values to the increnting vars such as a1, a2, a3..., or the like.

I will appeciate if you have some comments to make.

Regards

Nasib Kalsi
 
both incrementing var names like a1,a2,a3 and fields like phone1,phone2,phone3 are a sign of bad design. For vars use an array, for tables normalize them and store phone numbers seperate from the main record.

Regarding makrosubstitution, it's not bad in cases, but slow because each line containing a makrosubstitution will be compiled. Using it in a loop means N times compilation.

There are different solutions:
a) instead of makro substitution (line compilation in fact) compile the whole loop, that is done once or the whole loop. This can be done by execscript().

The disadvantage is, execscript is like creating a new prg file, compiling it to a frx and then call it, therefore within the script you have not access to local vars, you'd have to pass them to a parameter line within the script.

b) Use evaluate()

Especially for a1,2,3 you can use for n=1 to 3 / evaluate("a"+transform(n)), but as said an array is much easier: dim a(3), then you have a(1),a(2) and a(3) or a(n).

Bye, Olaf.
 
Hi Olaf:

I agree with you. No doubt about it. I felt it may be slightly slower than a regular expression, but turned out to be 3 or more times slower. Also found that transform() is slower than alltrim(str()). I have tried to compile an example.

Code:
*
* Compare the fox 9.0 SP1 command execution time.
*
set talk off
set echo off
#define __MAXLOOP 1000000

* Cacculate Overhead
i_Start0 = seconds()
for jj = 1 to __MAXLOOP
endfor
i_End0 = seconds()
i_LoopOverhead = i_End0 - i_Start0
? "0. Loop Overhead:",i_LoopOverHead

* 1. Start with amphersand(&) substitution
* ----------------------------------------
i_Start1 = seconds()
for jj = 1 to __MAXLOOP
	jc = alltrim(str(mod(jj,10),4))
	j&jc = jj && This will create Variables of the form j1, j2, j3 ...
endfor
i_End1 = seconds()
? "1. Time Taken By Amphersand Substition:",(i_End1 - i_Start1)

i_Start2 = seconds()
* Start with transform substitution
* ---------------------------------
for jj = 1 to __MAXLOOP
	jc = transform(mod(jj,10))
	j&jc = jj && This will create Variables of the form j1, j2, j3 ...
endfor
i_End2 = seconds()
? "2. Time Taken By TRANSFORM :",(i_End2-i_Start2)

* 3. Start with arrary substitution
* -------------------------------------
i_Start3 = seconds()
dime ja[10]
for jj = 1 to __MAXLOOP
	ji = mod(jj,10) + 1
	ja[ji] = jj 
endfor
i_End3 = seconds()

? "3. Time Taken By Array Substition:",(i_End3 - i_Start3)
? "-----------------------------------"


Thanks for your input.

Regards

Nasib

 
Hi Nasib,

you did half understand, I meant to use eval() instead of &, not to use transform over alltrim(str()). Since you don't want to read j&jc but store values to it, it's even a bit different. Make your second loop:
Code:
for jj = 1 to __MAXLOOP
    jc = transform(mod(jj,10))
    store jj to ("j"+jc)
endfor
i_End2 = seconds()
? "2. Time Taken By Name expression :",(i_End2-i_Start2)

You'll see this is between makro substitution and array usage.

Bye, Olaf.
 
Hi Olaf:

I am trying to illustrate the difference in execution over macro(1.) and array(3.). While I was at it, I want to see the difference between transform() and alltrim(str()). So 1. and 2. are the same(which I was doing), 3. is your solution.

Yes, I did miss it. This should be 4.

store jj to ("j"+jc) && a good substitute to macro


Regards

Nasib
 
Okay, Nasib

Alltrim(Str()) is faster, because both are simpler functions than Transform, even when calling Transform in it's simplest form with only one parameter it needs to see what type it is and transform it correspondingly, while Str() only accepts number type variables and Alltrim only accepts strings.

By the way, what I meant with eval is, if you read a var, dummy = evaluate("j"+jc) is faster than dummy = j&jc.

And that is, because evaluate is a simpler function than a compile. evaluate is only capable to evaluate expressions, it does not work for example to evaluate("select * from "+ cTable), but you can evaluate("functioncall(para1,para2)"), so it can also work in many cases, and it makes sense to use makrosubstitution only when name expressions like ("j"+jc) or evaluate(...) don't work.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top