Normal Topic Is there a known problem with @askuser() (Read 986 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Is there a known problem with @askuser()
Mar 23rd, 2004 at 6:23pm
Print Post Print Post  
Is there a known problem with @askuser() or am I using this incorrectly?

I have a command button that when pressed is used to make the ship to data the same as home address data. I wanted to protect against overwriting shipping data by accident so I added the feature of checking if ship to elements are blank. If data is found  it asks if you want to replace it.


var vshipblank as string

vshipblank = shipstreet + Shipcity + shipstate + shipzip
// writeln(vshipblank)


If vshipblank <> ""
then
     if @askuser("There is existing data in the ship to fields", "do you want to replace","existing ship to data with home address")



ShipStreet = homestreet
shipcity = homecity
shipstate = homestate
shipzip = homezip

The problem is that if all the ship to elements are empty it does not execute the first task of  ShipStreet = homestreet, but it does all the rest.

If ship to elements has data and you choose to replace it all data is correctly transferred.

So it is either my code or ???
  

Team – Together Everyone Achieves More
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: Is there a known problem with @askuser()
Reply #1 - Mar 23rd, 2004 at 6:51pm
Print Post Print Post  
hello bob, Try this code instead


var vAdd as string

vAdd = shipstreet + shipcity + shipstate + shipzip

if vAdd <> "" then
{
     if @AskUser("There is existing data in the ship to fields", "do you want to replace","existing ship to data with home address")
     {
           shipstreet = homestreet
           shipcity = homecity
           shipstate = homestate
           shipzip = homezip
     }
}
else
{
     shipstreet = homestreet
     shipcity = homecity
     shipstate = homestate
     shipzip = homezip

}
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Is there a known problem with @askuser()
Reply #2 - Mar 23rd, 2004 at 7:14pm
Print Post Print Post  
Bob,

The reason why your code is behaving that way is because you don't have curly braces {} around the lines following the If @Askuser. Because of this, it doesn't know that all four lines are part of the conditional, and it's only including the first line it encounters as depending on the condition.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Is there a known problem with @askuser()
Reply #3 - Mar 23rd, 2004 at 7:45pm
Print Post Print Post  
Thanks for the help Ray and Erika Smiley

It is funny I added and removed the curly braces so many times and must have never had the right combination. I think the copy of num4.db that you guys and gals have has them in place. I was so close yet so far away  Roll Eyes

I do not understand why it worked to fill all the elements but the first one, I would have thought none would have worked or all would have worked or just the first one would have worked the way I had it.
Smiley
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Is there a known problem with @askuser()
Reply #4 - Mar 23rd, 2004 at 8:33pm
Print Post Print Post  
Quote:
I do not understand why it worked to fill all the elements but the first one, I would have thought none would have worked or all would have worked or just the first one would have worked the way I had it.
Smiley

Your original code is the equivalent of this:
Code
Select All
If vshipblank <> "" Then
{
    If @askuser("There is existing data in the ship to fields", "do you want to replace","existing ship to data with home address")
    {
		    ShipStreet = homestreet
    }
}
// The following lines will always run because they
// are not enclosed by any condition.
shipcity = homecity
shipstate = homestate
shipzip = homezip
 



Does that make it clearer?  Smiley
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Is there a known problem with @askuser()
Reply #5 - Mar 23rd, 2004 at 9:07pm
Print Post Print Post  
OK the light just went on. Got it. Cheesy

Sometimes I feel really dense. Embarrassed

I am so ready for an intensive beginners Sbasic workshop and then an extensive Sbasic workshop and then an intensive extensive Sbasic workshop.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Is there a known problem with @askuser()
Reply #6 - Mar 23rd, 2004 at 9:18pm
Print Post Print Post  
Quote:
I am so ready for an intensive beginners Sbasic workshop and then an extensive Sbasic workshop and then an intensive extensive Sbasic workshop.


It's too bad you're way out in California. Do you ever get out this way (Ohio or East Coast)?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Is there a known problem with @askuser()
Reply #7 - Mar 23rd, 2004 at 9:51pm
Print Post Print Post  
I, like many others will travel anywhere and pay happily for a Sesame Sbasic workshop. Either a Lantica sanctioned training course, Fees paid to Lantica or even a renegade knowledgeable person needing to earn a few extra bucks willing to put on a training class. (wink Wink, wink Wink, hint, hint Ray and others) (did I say that out loud?)Grin

Separate from the training class is it time to start talking Sesame Bash?

I volunteer to help if needed   Smiley
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged