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!

Ignores a period 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am tryng to set up some variable's based on the txtInput.value the first part works fine, but for some reason the second for statement never gets true. but I can see a period in the debug window. any help is really appreciated. heres the code:

I = 1
For I = 40 to 1 step -1
If Substr(ThisForm.txtInput.Value,I-1,1) = "\"
cPath = Substr(ThisForm.txtInput.Value,1,I-1)
Exit
Endif
Endfor
*
A = 1
For A = 40 to 1 step -1
If Substr(ThisForm.txtInput.Value,I-1,1) = "."
cOutput = Substr(ThisForm.txtInput.Value,1,I-4)
Exit
Endif
Endfor
*

Thanks again -Mike
 
Thanks David, I'll try that. I am pretty new at VFP. I don't know what FPW is. I don't want to bug you, but.. I print some log file in my runs invoking dos with run commands. Is ther a better way to do it? they are just SDF files that can be copied right to the printer.

I'm new here too, is ther a limit to the number of dumb questions I can ask?

Thanks for your help.

-Mike
 
Mike,
FPW - FoxPro for Windows - the 16-bit forerunner to VFP.

Dave was alluding to a number of functions in VFP 6.0 (that in previous versions were in the FoxTools.DLL library), JUSTPATH(), JUSTEXT(), JUSTFNAME(), JUSTSTEM(), etc.

The reason the second FOR loop doesn't work right, is that you are now using "A" as the variable, but you are still using "I" in the inner code:

For A = 40 to 1 step -1
If Substr(ThisForm.txtInput.Value,A-1,1) = "."
cOutput = Substr(ThisForm.txtInput.Value,1,A-4)
Exit
Endif
Endfor

Notes: The I = 1 and A = 1 before the FOR loops are unnecessary - the loop in both cases will immediatly set it to 40. In general it's not a good idea to use the single character variables "A" -> "J", these were originally used as default aliases for the first 10 workareas (still supported), and there are syntactic situations where you may not get what you're expecting.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top