Hot Topic (More than 10 Replies) Programing question (Read 1311 times)
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Programing question
Dec 19th, 2006 at 12:18am
Print Post Print Post  
Hello,
I'm looking to add a prefix to a global value next number.
Right now I have it hard coded in programing but what I would like is to have it on what I call my information page. A page that the data entry person can change and change the prefix.

My question is what command would I use to look up this field so I don't have to rewrite this code every year? I don't think its the xlu because I don't have a key field on the purchase order form that needs to be compared to.
Does this make any sense? 

Merry Christmas to all.
flip
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Programing question
Reply #1 - Dec 19th, 2006 at 12:22am
Print Post Print Post  
Hi Flip,

I usually use another GlobalValue, named something like "Prefix" for things like this. I make a Settings Form with nothing but unbound elements that allows user to edit the various settings and save them by clicking a button.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Programing question
Reply #2 - Dec 19th, 2006 at 1:01am
Print Post Print Post  
Hello Erika
what command do I use to get it from the element fieled on the settting form to the Global value?
thanks for all your help, again.
flip
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Programing question
Reply #3 - Dec 19th, 2006 at 1:08am
Print Post Print Post  
If this is going to change yearly, can't you make the prefix a function of the current year?
So it will automatically change at the beginning of the year, and would be correct all year long. 
No need to change it every year.

A variation of the following:
Code
Select All
varIncrementalNumber = Existing Sequential Number
GlobalVariable("NextNumber",@Str(@Year(PurchaseOrderDate)) + @Str(varIncrementalNumber)) 


For the varIncrementalNumber, you could have an Invisible, ReadOnly auto incrementing element on your purchase order form.

There are a number of examples on the forum on how to do this using @XLR and adding 1 to the value.  Used in place of @Number

Also check the Sesame Programming Guide, page 59, for an example of using @GlobalValue instead of @Number.  Just modify that example to add @Year(PODate) to the front as shown above.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Programing question
Reply #4 - Dec 19th, 2006 at 1:21am
Print Post Print Post  
Hello Bob,
I was read page 59 as I got your reply, I like your idea!
This is what Im working with at the moment, one has to be a single letter and the other form needs to be a two digit number

If @IsBlank(opo) And (@IsNew)
     {
           if (@Modified)
                 {
                       vNextNum = @ToNumber(@GlobalValue("nextNumber")) +1
                       opo = "C-" + @Str(vNextNum)
                       GlobalValue("NextNumber", @Str(vNextNum))
                 }
     }      
had not thought far enough ahead to make it automaitic change....I like your thinking.
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Programing question
Reply #5 - Dec 19th, 2006 at 2:13am
Print Post Print Post  
Not quite sure when you are setting this value, but would suspect it would be on New Records.

But your programming will never work, because you @Modified will never be true it @IsNew is True, so that programming will never be executed.  I think you may want to remove the IF @Modified section, or change the conditions.

==============
Edited....My above statement is incorrect. Embarrassed

I am probably suffering from my Q&A history. 
I understood that this was a Q&A carryover, which could only occur once a record was already saved. 
According to Mark, Sesame is a little different.

He is correct.   Roll Eyes
In Sesame the comparison is made against the form content when is it first shown, vs.  comparing against a record content.

From the Sesame Programming Guide, page 189: Quote:
@Modified returns TRUE if the record has been modified in any way during the current instance of having it on-screen. @Modified compares the data as it appears in the form against the data that appeared in the form when the current record was initially shown. Initial Values being set in a new record does not set @Modified. Programming may modify a record as it's displayed. This sets the modified flag to true, the same as if the user changed an element’s value from the keyboard.

So, in Sesame it is possible to have @IsNew and @Modified both True at the same time. 

Sorry for any confusion.  Still learning something new about Sesame every day. 

Thanks to Mark for the clarification.
« Last Edit: Dec 19th, 2006 at 4:04am by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Programing question
Reply #6 - Dec 19th, 2006 at 2:18am
Print Post Print Post  
Bob_Hansen wrote on Dec 19th, 2006 at 2:13am:
Not quite sure when you are setting this value, but would suspect it would be on New Records.

But your programming will never work, because you @Modified will never be true it @IsNew is True, so that programming will never be executed.  I think you may want to remove the IF @Modified section, or change the conditions.




If the record is new and has not yet been committed, yet has been modified, @New and @Modified will both be true - at least in 1.1.5 (I don't have 1.1.4 here at home, but I suspect it is the same).
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Programing question
Reply #7 - Dec 19th, 2006 at 2:39am
Print Post Print Post  
Hello Mark,
What I posted works fine, but I understand what you mean, it is posted on an element exit. What I am looking for is to lookup a field on the setting form and us it as the prefix on the number. Seems I cant xlookup without a key field.

I have a couple other applications I could use this on as well

I appreciate everyone’s help!
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Programing question
Reply #8 - Dec 19th, 2006 at 4:09am
Print Post Print Post  
ok, why wont this work?

If odate >= 1/1/2007
     {
           If @IsBlank(call_number) And @IsNew
                 {
                       if (@Modified)
                             {
                                   vNextNum = @ToNumber(@GlobalValue("NextNumber")) +1
                                   Call_number = "07-" + @Str(vNextNum)
                                   GlobalValue("NextNumber", @Str(vNextNum))
                             }
                 }
     }
Else If @IsBlank(call_number) And @IsNew
     {
           if (@Modified)
                 {
                       vNextNum = @ToNumber(@GlobalValue("NextNumber")) +1
                       Call_number = "06-" + @Str(vNextNum)
                       GlobalValue("NextNumber", @Str(vNextNum))
                 }
     }   
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Programing question
Reply #9 - Dec 19th, 2006 at 1:37pm
Print Post Print Post  
At the least, the date comparison is failing because it needs double quotes:
Code
Select All
 If odate >= "1/1/2007"
 



If you do not double quote it, SBasic believes you are trying to divide 1 by 1 by 2007.

Try temporarily inserting a bunch of writeln statements into your program, to see what's happening.

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Programing question
Reply #10 - Dec 19th, 2006 at 5:20pm
Print Post Print Post  
Thank you Mark,
As Mayor of Incompetency,
It is in my power to promote you to Super Hero Status!
And for now, all is good in the world.

Works just like it should. I keep forgetting about the writeln, its very helpful.  I will to try and figure out the settings page thing when I get back. This should keep them busy until then.
Thank you all for your help and support.
Merry Christmas and Happy New Year to all!!
Flip
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged