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!

Alternate way to SELECT a table

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I have a problem in my single form app. The app opens over 30 tables and reports statistics on them.

The results are to be stored in a table I have named STORAGE. This is created early in the app.

Two sets of results are put into this table with the REPL command at two differnt points in the program.

To ensure I have the right table open I LOCATE a project name in the storage table and message to the user.

On my development PC it works flawlessly but after an installation via Inno compiler the program misses the second storage opening somehow.

Can I use any other opening commands to make certain the table is SELECTED when needed?

The values I want to place in STORAGE table are in storage4

Part of my code is

Code:
Set Default To (mysystempath)
If !Used('storage')
	Use storage In 0
Endif
Select storage
Go Top
Locate For Project = myproject
If Found()
    If 'SHU'$compname()
	nAnswer = Messagebox('Found correct project table for TMG tables values')
     Endif
Endif

	Set Default To (mysystempath)
	If !Used('storage4')
		Use storage4 In 0
	Endif
	Select storage4
	nhits = 0
	Go Top
	Scan
		nfield = storage4.NPER
		nhits = storage4.NTAGS
		
		Select storage
		Do Case
		Case nfield = 0
			Replace  storage.N_et00 With nhits

etc etc

Thanks

GenDev
 
Olaf and Dan,

Thank you for your suggestions. In my defence I would like to remind that the code I have works correctly on my development PC - that is why I am completely puzzles as to why it doesn't work on a user's PC.

I am trying to follow all the suggestions that have been made in this thread and thus far have not solved my problem. But today is another day and I will keep trying.

Some points.

There will only ever be one project being accessed throughout the code. This is selected in the first two tabs of my form (project location and selection of actual project)and is contained in the variable 'myproject' which is stored in the STORAGE table in field PROJECT early on in the code.

'SHU' refers to my computer name (SHUTTLE) and I have temporarily removed the test so that I can see the messages on a user PC.

I have no experience of the crosstab wizard which is why I stick to very basic code.

The operation that is giving the problem is 'miniscule' in computing terms. Just getting previously computed data from one table into another. Speed is not a problem - the previous calculations take the most time.

Thanks

GenDev
 
Gendev: Would you be able to express what have you tried, exactly. This may get you better answers.

Also try BROWSEing both tables before the scan starts, readonly, to make sure you have appropriate data loaded in the fields, may be they are 0s.


Dan: I never tried to look at the scan/endscan but very anxious to look into it and may start using it.
 
Gendev, your problem must be in the data, not in your code. Either myproject is not found or the data in storage4.nper and ntags is not as you expect. As you say myproject is selected from the projects existing, the problem has to be in the other data, as Nasib now suggests. All you describe still points to being at EOF, meaning not found a record while replacing. Maybe its as simple as a user skipping the step to choose a project. It wouldn't be the first case in the history of computer applications an end user is not doing as instructed or an application not checking all eventualities and prerequisites.

Bye, Olaf.



 
Thanks for all the attempts to help.


How's this for a right pain.

I put the new executable on a thumbdrive along with the sample project files in a separate folder.

1 On my Netbook (win7) - my app runs perfectly - STORAGE identified in the dialogues - good csv written and viewable

2 On my Notebook (win8)- my app runs - TEMP_zz identified in dialogues and visible in csv. TEMP_zz is one of the tables in the project.

I'm still mystified and trying lots of minor prg changes to no avail. I like the browse idea as a test but obviously as per the above results it will show the wrong table as per the dialogues on my Notebook.

GenDev

PS The only user who is trying it is my client and I am watching via Teamviewer.
 
The problem most probably is in a place you don't look at and you don't show us.
So far we heard of storage4 and storage, now you introduce temp_zz.

Do you get any errors? Do you really not find some tables? So far you didn't report any errors. Did you perhaps include DBFs into your EXE? If you did, you always find them, but will get errors writing to them.

I actually would like to know what the detail problem really is?
You say in a good you get csv output. So where is your code writing csv?

Bye, Olaf.
 
>You say in a good you get csv output
You say in a good run you get csv output...

Bye, Olaf.
 
Olaf,

There is a very large amount of prg code doing the processing of the 19 tables in the genealogy app.

I didn't want to bother you with all of it.Temp_zz is the alias() of one of those 19 tables which I am finding the physical size and the number of records of.

I am trying to investigate why STORAGE isn't open when the dialogue shows on the WIN 8 PC but is open on the WIN 7 PC.

Thanks

GenDev
 
It surely is not helpful to see all code, but the code failing.
Now you talk of the dialogue. Which dialogue?

I think we can only rest this case in not being able to help you find the error.

I can only give you the advice to not install data into program files, because its a readonly system folder for executables. Either install the whole application into a folder like C:\gendev\yourapp\ or at least add the data into a writable folder. On Win Vista/7/8/8.1/10 this could be C:\Users\Public or C:\ProgramData and installshield will have special folders you can set in the installer project.

For detail look into
Bye, Olaf.
 
GENDEV said:
I am trying to investigate why STORAGE isn't open when the dialogue shows on the WIN 8 PC but is open on the WIN 7 PC.

I have asked before but never got an answer: WHAT ERROR MESSAGE ARE YOU GETTING?

I strongly suspect you are misdiagnosing this condition. I also suspect you aren't listening to what we're telling you.
 
Dan,

I haven't been getting any error messages - it was just that the opening of storage was not occurring.

However the good news is that after minor changes to my code - based on information gained in the messages in this thread- my latest executable has run on my 2 PCs and now runs on my client's PC.

Both he and I are very relieved and the app will now be sent to a wider selection of users to confirm its stability.

Thanks to everyone who contributed to this thread - I found it very difficult to report on the problems I was having.

Regards

GenDev
 
GENDEV said:
I haven't been getting any error messages - it was just that the opening of storage was not occurring.

Rubbish.

Sorry, but this absolutely cannot be the case.

If a table cannot be opened, you will receive an error message.
If you SELECT an alias that does not exist, you will receive an error message.

Again: YOU WILL RECEIVE AN ERROR MESSAGE.

There is no way you will not receive an error message.

I fear you have misdiagnosed this thing from the beginning and still don't understand what was going on.

But, hey, if you've got it working now rock on!
 
Note that there is ONE instance I have observed where USE will result in an empty Alias(), but it only manifests in many many repeated openings of same-named tables.

(This actually manifested in Stonefield Database Toolkit, and apparently I was the only one who ever saw/trapped it.)

The solution?
Code:
Use (lcPath + lcTable)
If Empty(Alias())
   Use (lcPath + lcTable)
Endif

It took 300+ iterations through same-named data sets to hit it but it was reproducible.

You do not want to know the wording of the comment I put on that IF block.
 
Dan said:
If a table cannot be opened, you will receive an error message.
If you SELECT an alias that does not exist, you will receive an error message.

Again: YOU WILL RECEIVE AN ERROR MESSAGE.

There is no way you will not receive an error message.

Well, if you really want to be ultra-precise about this, there is a case where the table cannot be opened buy you don't seen an error message. It will happen if you are error-trapping your USE statement (with TRY / ENDTRY, ON ERROR, or an Error method), and if your error-handler does not issue a message.

But I accept that is extremely unlikely in the present case, and does not detract from your main point, Dan. You are certainly right when you say that GenDev has misdiagnosed the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Dan: Can you still produce the error after introducing small wait state ( = inkey(.001)) ?


 
Unfortunately I no longer have access to that application or their largest customer's data set.

It was a bear to pin down because of course the error doesn't appear when you USE the table, only later when you SELECT it by alias. It has no alias. It's the only time since dBase III I've ever seen a table open with NO alias at all. In the view window, there was a blank row for that table. It didn't even get the alphabet soup alias VFP sometimes uses as a tie breaker when the default alias is already taken.

I don't think I'd use a timeout (however small) when processing thousands of files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top