Normal Topic Better way to stop than "STOP"? (Read 946 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Better way to stop than "STOP"?
Dec 20th, 2005 at 8:15pm
Print Post Print Post  
Thanks, Ray, for the info on @Save.

Now, onto my next question:

I've read that the "STOP" command is not recommended, but I'm not sure if there's another way to do what I want. 

I've made "SAVE" and "SAVE - EXIT" buttons for my form (still to come: "SAVE - CONTINUE").  In both cases I want to check to be sure that elements CODE and COMPANY are not blank.  If that's the case then I want to allow saving.  However, if either is blank I want to disallow saving, alert the user, and put him where he belongs to make the correction.  Here's what I've got so far:

Code
Select All
/* Saves the record and then Exits */

If @IsBlank(Code)
	{
		NotifyForm(1)
		@MsgBox("Customer Code has not been assigned.","Please click ASSIGN CODE.","")
		  STOP
	}

If @IsBlank(Company)
	{
		NotifyForm(1)
		@MsgBox("Customer Name cannot be blank.","","")
		ThrowFocus(Company)
		STOP
	}

Else FormCommit("")
@Exit 



The "SAVE" button is exactly the same except for @Exit at the end.

Is there a better way to do this?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Better way to stop than "STOP"?
Reply #1 - Dec 20th, 2005 at 8:25pm
Print Post Print Post  
YES there is always a better way than to use Stop. Using Stop is as bad as well driving 100 miles an hour right into a brick wall. or Locking up your brakes in an over-loaded Semi while going down a several mile steep grade. Do not use Stop.

Something like
Code
Select All
If @IsBlank(Code)
{
	NotifyForm(1)
	@MsgBox("Customer Code has not been assigned.","Please click ASSIGN CODE.","")
}
Else
{
	If @IsBlank(Company)
	{
		NotifyForm(1)
		@MsgBox("Customer Name cannot be blank.","","")
		ThrowFocus(Company)
	}
	Else
	{
		FormCommit("")
		@Exit
	}
} 



There are other ways as well. In no case should you use Stop.

-Ray

P.S. DO NOT USE STOP!
P.P.S. I MEAN IT!!!
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Better way to stop than "STOP"?
Reply #2 - Dec 20th, 2005 at 8:43pm
Print Post Print Post  
Ah, that's nice and clean, thank you.

I really need to take the Advanced Programming class.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Better way to stop than "STOP"?
Reply #3 - Dec 20th, 2005 at 9:12pm
Print Post Print Post  
Ach, it's not working.  I get no errors when I test the programming, but the record is not saved and the form does not exit. 

And, strangely, when I put the same conditionals in the programming of my "SAVE" button (which just uses FormCommit, no exit) it saves the record and advances to the next blank record.  Do these conditionals affect how FormCommit works?

CORRECTION:  Save-Exit is working.  The newest button, Save-Continue (the one using @Save) is not saving and continuing.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Better way to stop than "STOP"?
Reply #4 - Dec 20th, 2005 at 9:18pm
Print Post Print Post  
Is NotifyForm() being set back to 0 anyplace? You may wanna try.

Code
Select All
If @IsBlank(Code)
{
 NotifyForm(1)
 @MsgBox("Customer Code has not been assigned.","Please click ASSIGN CODE.","")
}
Else
{
 If @IsBlank(Company)
 {
  NotifyForm(1)
  @MsgBox("Customer Name cannot be blank.","","")
  ThrowFocus(Company)
 }
 Else
 {
  NotifyForm(0)
  FormCommit("")
  @Exit
 }
} 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Better way to stop than "STOP"?
Reply #5 - Dec 20th, 2005 at 9:25pm
Print Post Print Post  
Thanks, that fixed "Save-Continue".  But plain old Save (do not advance) is still advancing.  Here's the code:

Code
Select All
// Saves the record and then stays in current mode, current record

If @IsBlank(Code)
	{
	 NotifyForm(1)
	 @MsgBox("Customer Code has not been assigned.","Please click ASSIGN CODE.","")
	}
Else
	{
		 If @IsBlank(Company)
		 {
		  NotifyForm(1)
		  @MsgBox("Customer Name cannot be blank.","","")
		  ThrowFocus(Company)
		 }
	Else
		 {
			NotifyForm(0)
			FormCommit("")
		 }
	} 



Perhaps I need to do a Mode test?  But it shouldn't jump to the next in any mode.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Better way to stop than "STOP"?
Reply #6 - Dec 20th, 2005 at 9:30pm
Print Post Print Post  
To further weirdify the problem, the above code only advances to the next blank record on the first push, that is after adding data for 1 brand new record.  After that, when adding another record, it stays put like it's supposed to.

New record #1 jumps to new record #2.  New record #2 stays on #2.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Better way to stop than "STOP"?
Reply #7 - Dec 20th, 2005 at 9:47pm
Print Post Print Post  
Hello Scott,

This has been discussed in the following thread.

http://www.lantica.com/Forum2/cgi-bin/yabb/YaBB.pl?board=gen_disc;action=display...

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged