Script stopped working.

ODBC Connectivity, ELFs , Windows API etc.

Moderators: Phil Winkler, Graham Smith, Pete Tabord

Script stopped working.

Postby tinshed » Thu Jan 20, 2011 1:16 pm

Hi, been scratching my head over a little issue that has cropped up out of the blue. I have an application which I have spruced up with the odd field that conditionally hides using script. This was working great until a few days ago when I tried to add a button to an aspect which copied the data to a field in a related form. I'm not sure if this is the done thing, but it worked a couple of times and then stopped. Ok this was not too big a deal I though I'd asked a bit too much and would have to take a different approach, but what I found was that the scrpt that alter properties had stopped working in other parts of the database, while the recordsave and formopenrelated scripts still work. Any ideas?? Thank in advance.
tinshed
 
Posts: 5
Joined: Mon Jan 17, 2011 3:17 pm
Has thanked: 0 time
Been thanked: 0 time
 

Re: Script stopped working.

Postby Adrian Jones » Thu Jan 20, 2011 2:03 pm

Hi Eric, and welcome to the forum.

Can you explain what you mean by 'scrpt that alter properties'?

Thanks, Adrian
User avatar
Adrian Jones
 
Posts: 2000
Joined: Tue Sep 11, 2007 2:38 pm
Location: Cornwall, UK
Has thanked: 5 times
Been thanked: 4 times
 

Re: Script stopped working.

Postby tinshed » Thu Jan 20, 2011 3:35 pm

Hi Adrian, I have a form with a field that accepts a manual price to overide an automatic lookup. This field is normally hidden so to use it you have to check a tick box that makes the field appear. I also have a couple of buttons I hide in a similar way on the same aspect which have stopped working also.

The script on the tick box Valueloaded and Valuechange event is ...

if ManPcheck = yes or ManualPrice > 0 then

ManualPrice .Visible := 1 .
ManualPrice .redraw := 1 .
Text14.visible := 1 .
Text14.redraw := 1 .

else

ManualPrice .Visible := 0 .
ManualPrice .redraw := 0 .
Text14.visible := 0 .
Text14.redraw := 0 .

end

I all worked well for several weeks but now the fields & buttons do not hide and are always visible.
Any ideas??

Thanks
tinshed
 
Posts: 5
Joined: Mon Jan 17, 2011 3:17 pm
Has thanked: 0 time
Been thanked: 0 time
 

Re: Script stopped working.

Postby KjetilUrne » Thu Jan 20, 2011 5:22 pm

I would try to copy all the objects of this aspect (is it an aspect by the way?) to a new aspect.
KjetilUrne
 
Posts: 602
Joined: Mon Oct 08, 2007 8:21 am
Location: Norway
Has thanked: 4 times
Been thanked: 1 time
 

Re: Script stopped working.

Postby tinshed » Mon Jan 24, 2011 9:39 am

Hi Adrian, Luckily I found a backup copy of the aspect before the problem. I hope it doesn't bite me later. Thanks for your help.
tinshed
 
Posts: 5
Joined: Mon Jan 17, 2011 3:17 pm
Has thanked: 0 time
Been thanked: 0 time
 

Re: Script stopped working.

Postby Graham Smith » Mon Jan 24, 2011 1:57 pm

The first question to ask is "what was changed just before this stopped working". The reason this is an important question is because things don't just stop working all by themselves. There's no batteries to run out or springs to break, etc.

The most common cause of a script not working is some change to an object that the script refers to, or possibly a change to the object the script is on without "recompiling" the script (open the script and press [F2] to check it then save).
Graham Smith
DataSmith, Delaware
"For every expert there is an equal and opposite expert.", Arthur C. Clarke (1917 - 2008)
"X-Clacks-Overhead: GNU Terry Pratchett"
User avatar
Graham Smith
 
Posts: 2501
Joined: Fri Sep 07, 2007 11:31 am
Location: Delaware, USA
Has thanked: 0 time
Been thanked: 1 time
 

Re: Script stopped working.

Postby tinshed » Mon Jan 24, 2011 4:22 pm

Hi Graham, I'm working on a system for quotations that calls items from a catalogue table. The descriptions in the catalogue are not as good as they could be so the users often overwrite the description on the quote and I thought it would be a nice touch to pop a button on the form that would update the description in the main catalogue for later use. Being fairly new at script I didn't know if it was the done thing, the script was along the lines of ....

if any QI_Invtry_PartLink FullDesc not = FullDesc.value then

modify records in QI_Invtry_PartLink

FullDesc := FullDesc.value .

end

(sorry I have deleted the button and script now).

I checked the script and hit the run button and all worked well for a couple of times. But then it stopped and so did all of the script on that aspect which had been working fine for some time. I deleted the button but still no joy on the other objects.

I guess it was one of those things and I have put it down to experience and maybe asking too much. I have gone back to running a procedure on exit, not slick but functional.

Cheers
tinshed
 
Posts: 5
Joined: Mon Jan 17, 2011 3:17 pm
Has thanked: 0 time
Been thanked: 0 time
 

Re: Script stopped working.

Postby Adrian Jones » Mon Jan 24, 2011 4:33 pm

Hi Eric,

I strongly recommend that you use object scripting for controlling the appearance of objects on screen, a bit of navigation, and not for anything that you could do with a procedure.

I know the language does let you do a subset of the data manipulation, but it is much better to call a procedure instead, passing the value of selected records using the get/setglobal set of external functions.

There are two key reasons I say this:

1. There is the unfortunate risk that too much modification of a document can make it stop working, or stop being accessible altogether.
2. You can't reuse the procedure you would otherwise have written elsewhere.

Also, procedures ARE something you can almost "modify to death" (esp if they are not list records...).
User avatar
Adrian Jones
 
Posts: 2000
Joined: Tue Sep 11, 2007 2:38 pm
Location: Cornwall, UK
Has thanked: 5 times
Been thanked: 4 times
 

Re: Script stopped working.

Postby tinshed » Mon Jan 24, 2011 4:56 pm

Thank Adrian, I think its called learning the hard way. I knew as I tried it was a short cut I may regret. I just couldn't undestand why the other scripts stopped. Will take you advice and hold in good stead for the future.

Thanks.

Eric
tinshed
 
Posts: 5
Joined: Mon Jan 17, 2011 3:17 pm
Has thanked: 0 time
Been thanked: 0 time
 
 

Return to Advanced

Who is online

Users browsing this forum: No registered users and 1 guest

cron