Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) "Running" Programming through Mass Update (Read 2795 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
"Running" Programming through Mass Update
May 3rd, 2005 at 1:59am
Print Post Print Post  
Hi -

I would like to know whether anyone has automated the execution of programming using Mass Update Specs.  I would like to use it for a variety of situations and my first attempt is leaving me very confused and, so far, without success.

Here is what I want - and if someone has already done this, walking me through the steps (preferably with sample code - and where to put it) would be very helpful

I want to click on a Command Button that will:

1)  Load and execute a retrieve spec.

2)  Load and execute a sort spec

3) Have the mass update run (without input from the user as to whether "interaction" is desired).
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: "Running" Programming through Mass Update
Reply #1 - May 3rd, 2005 at 1:56pm
Print Post Print Post  
Spencer,

I thought we had #1 and #2 solved in the other thread.

Anyways here is some code that will do what you are asking. I sent you the application that has this in it so you can see how it works.

Instead of calling a Mass Update I just looped through the records in code, no extra step for the users and no macros.

Code
Select All
Var vSuccess as Int
Var vCnt as Int
Var vLoop as Int
Var vTimes as Int

vLoop = 0
vTimes = 0

If @Mode() <> 0 Then
{
	vSuccess = @SelectTreeItem("Search Update Menu!Navigation!Save Record")
	vSuccess = @SelectTreeItem("Search Update Menu!Search (F7)")
	vSuccess = @LoadSortSpec("KeyD")
	vSuccess = @LoadRetrieveSpec("TestSpec")
	vSuccess = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")

	If vSuccess = 1 Then
	{
		While ((vCnt = 0) And (vTimes < 10))
		{
			vTimes = vTimes + 1
			Loiter(1000)
			vCnt = @FormResultSetTotal("Main Form")
		}
		Writeln(vCnt + " Total Records")

		While (vLoop < vCnt)
		{
			vLoop = vLoop + 1
			FormResultSetCurrentPosition("Main Form", vLoop)
			writeln("Record Number " + vLoop + " Has a Key Value of " + Key)
		}
		Writeln("Done Looping")
		FormResultSetCurrentPosition("Main Form", 1)
	}
} 



Any questions?
-Ray
  

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



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: "Running" Programming through Mass Update
Reply #2 - May 8th, 2005 at 5:31pm
Print Post Print Post  
Ray -

I am sorry that I didn't respond sooner, however, I was unfortunately taken away from this by higher priority issues.

First, I want to thank you for all the effort you have put into this.  I especially appreciate the sample application you sent me.

The reason I posted this question on a separate thread is two-fold.  First, the other thread was getting quite "involved" and secondly, I am looking for a generic approach to using mass update together with a macro (vs looping) to execute programming.  (I thought the fact that the other thread applied specifically to use of printspec that, perhaps, the generic issue was being overlooked by some ... and I was hoping for additional feedback).

Since mass update is held out to be such a powerful feature (as it is) I thought surely that either there would be a simple built in command such as "Run MassUpdate (NameOfUpdateSpec)" OR at least that someone already came up with a "standard" programming procedure (such as was recently created for phone dialing).  Certainly, I submit this as a suggestion for the programmers to consider.  It would be nice, too, if the update could be run (using a switch) with or without attached retrieve/sort specs.

As for your thinking that we had #1 and #2 (loading the retrieve and sort specs) resolved, I thought we had too.  Yet, when I tried the new code you provided, the retrieve spec worked properly; however, the sort spec did not. The records were not printed in the order I need them.

I will continue to play with this to see if I can get it right and, certainly, if you can think of a reason the sort spec did not work, I would appreciate knowing about it.

With regard to the code you provided here, the "writeln" portion causes another window to pop up.  While I can see an advantage to this, since it not only tells me the progress of the process but can tell me the name of the record for which each envelope is being printed. But, I'm not sure that I like seeing the pop-up window.  Other than the information it provides, is there any other reason the writeln should be used? I had tried it prefixed with // before the writeln statements and the programming executed just fine (other than the sort spec issue previously mentioned) without the window.

While running the program, each record flashed on the screen ... once again, something I'm not sure I like.  If memory serves me right, when you run a macro you can have it be not visible and the records would not be seen.   Do you know, offhand, whether I am right about this?

Also, I had asked one (or two) other question(s) on my code in the other thread that not addressed.  I will add another post, there, to repeat the question(s) I would like answered.

Thanks!







  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: "Running" Programming through Mass Update
Reply #3 - May 8th, 2005 at 7:21pm
Print Post Print Post  
Quote:
Since mass update is held out to be such a powerful feature (as it is) I thought surely that either there would be a simple built in command such as "Run MassUpdate (NameOfUpdateSpec)" OR at least that someone already came up with a "standard" programming procedure

You can use this code to execute a mass update from programming or a command button.

Code
Select All
var Success as int

Success = @LoadMassUpdateSpec("MyMassUpdateSpec")
if Success = 1
	{
	@Macro("Data\Run Mass Update.mac")	//Use @Macro instead of @SelectTreeItem. The macro eliminates the mass update confirmation pop-up box.
	} 


The macro simply contains a mouse-click (or two) that selects the "Mass Update" line in the command tree while in update mode. You could also use @SelectTreeItem to select "Mass Update", but I chose not to use that because it required me to respond to a confirmation pop-up box. The macro eliminates the pop-up confirmation box from appearing.

This code can also be activated from a command button located on a custom main menu (i.e. another form). That takes a little more work, but if you need to know how to do that, let me know.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: "Running" Programming through Mass Update
Reply #4 - May 8th, 2005 at 7:26pm
Print Post Print Post  
Ray et al -

Well after spending about 2 hours on this sort spec problem, I learned a lesson that I doubt I shall ever forget.

First, I followed the steps manually and it worked every time.

Then, I executed the code and continued to have the problem with the records not being properly sorted.

I must have done this dozens of times and each time I checked the spelling of the sort code in the programming to be sure that it matched the actual sort spec.  It did; the spelling was precise.

FINALLY, LO AND BEHOLD, I discovered the problem.  What I did not check was CASE .... and, when I did, I discovered that using the name of a spec is CASE SENSITIVE.

So my programming called for Alphabetical By Last Name whereas the actual sort spec was named Alphabetical  by Last Name.

Case sensitivity may be covered in the User and/or Programming guides but, if so, I simply missed it.

In any event, HOORAY, this particular hurdle has been resolved.  As I said before, it is a lesson well-learned and I doubt I will forget it in the future.  I DO hope that it will save someone else from going through this tortuous exercise.  lol

  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: "Running" Programming through Mass Update
Reply #5 - May 8th, 2005 at 7:37pm
Print Post Print Post  
Carl -

Talk about coincidence.  I just posted a "finding" and question related to this very issue on the other thread.

I discovered a few nights ago that when recording a macro the user intervention notice did not appear .. so I assumed that when it was run, it would not be interrupted to ask for input by the user.  My question was whether my assumption was correct and, of course, you have now answered that.  Thank you!

As of now, I think I have my programming working using loops as Ray had suggested.  Once that is "flat" I am very eager to try the macro approach to see if the screen is "cleaner."  As I mentioned in the other thread the loop/writeln approach gives me a pop-up window that I'm not sure I want ... and even leaving out the writeln statements (which eliminates the pop-up window) I still see the records flashing .... which I don't like .... and which I believe could be eliminated when using a macro.

So, anyhow, thank you much for your response.  It may be a while before I can get to the macro aspect, but I will certainly try it and let you know how I make out.

As to using a "Main Menu" I am nowheres near ready to try something like that as yet, but will certainly ask for and appreciate help when I do get to that point.

Thanks, again.

(Ever considered moving to Tampa, so we could start a user group here?   lol)
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: "Running" Programming through Mass Update
Reply #6 - May 8th, 2005 at 7:45pm
Print Post Print Post  
Quote:
...I discovered that using the name of a spec is CASE SENSITIVE.


Indeed it is, or should I say was...

Found and fixed.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: "Running" Programming through Mass Update
Reply #7 - May 8th, 2005 at 7:50pm
Print Post Print Post  
Mark -

When you say Quote:
Found and fixed
does that mean that you have changed it so that it is no longer case sensitive .... or at least that it won't be in a future update to Sesame?

If so, I'm delighted that, perhaps, I have made a contribution that will be helpful to others.

I have gotten so much help, here, that I would love to think I could at least return a little of it.  lol

Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: "Running" Programming through Mass Update
Reply #8 - May 8th, 2005 at 8:11pm
Print Post Print Post  
It will be case insensitive in the next release. None of the "user" operations in Sesame are supposed to be case sensitive other than the passwords. So if you find any other spots where "A" <> "a", let us know. Thanks.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: "Running" Programming through Mass Update
Reply #9 - May 8th, 2005 at 8:29pm
Print Post Print Post  
Mark -

Glad to hear this; thanks.

Now, for you, Ray, et al:

Having resolved the case sensitivity issue, the programming I am using now works UP TILL the point of actually printing the envelopes.

It sorts, retrieves and loops through all of the selected record set but then it does NOT print!

I am wondering whether it has to do with the placement of the "Else Stop" code (although I tried it in another location in relation to the ending brackets, with no better result).  This is supposed to execute only when the user answers "no" to the askuser question.  (When no is answered it does stop, as I want it to).

But when yes is answered, as I said, it does go through the entire process except for the printing.

Code
Select All
var Z as int
var SaveRecord as Int
var SearchMode as Int
var LoadSort as Int
var LoadRetrieve as Int
Var DoRetrieve as Int
Var vCnt as Int
Var vLoop as Int
Var vTimes as Int

vLoop = 0
vTimes = 0

if not @update then
{
z = @asynchshell("C:\Program Files\Sesame\Data\Sounds\Cannot Use Here.wav")

STOP

}


else



If @Mode() <> 0 Then
{
      SaveRecord = @SelectTreeItem("Search Update Menu!Navigation!Save Record")
      SearchMode = @SelectTreeItem("Search Update Menu!Search (F7)")
        LoadSort = @LoadSortSpec("Alphabetical by Last Name")
      LoadRetrieve = @LoadRetrieveSpec("Paid Subscribers")
      DoRetrieve = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")


      If DoRetrieve = 1 Then

{          If  @Askuser("You are about to print", @ResultSetTotal() + " envelopes","Do you want to do this?")

 Then


      {
            While ((vCnt = 0) And (vTimes < 10))
            {
                  vTimes = vTimes + 1
                  Loiter(1000)
                  vCnt = @FormResultSetTotal("Middle Villagers")
            }
            Writeln(vCnt + " Total Records")

            While (vLoop < vCnt)
            {
                  vLoop = vLoop + 1
                  FormResultSetCurrentPosition("Middle Villagers", vLoop)
                  writeln("Record Number " + vLoop + " prints an envelope for " + Mail Name)
            }
            Writeln("Done Looping")
            FormResultSetCurrentPosition("Main Form", 1)
      }      

  Else  STOP
}      



AlternateDefaultPrinter("Envelopes")
PrintPagePaper(20)
Newpage(950,412)
PrintString("Herbert Teicher", 30, 25, 0, "Arial", 14, 0)
PrintString("26 McDonald Street", 30, @PageExtentY(), 0, "Arial", 14, 0)
PrintString("Staten Island, NY  10314-5055", 30, @PageExtentY(), 0, "Arial", 14, 0)

PrintString(Mail Name, 450, 200, 0, "BArial", 16, 0)
PrintString(Street Address + " " + Apt, 450, @PageExtentY(), 0, "BArial", 16, 0)
PrintString(City + ", " + State + "  " + Zip, 450, @PageExtentY(), 0, "BArial", 16, 0)

PrintString("Thanks for supporting The Middle Villager Newsletter", 30, 355, 0, "IArial", 12, 0)

FinishPage()
}
 



This is the last step I need to address in order for my command button to be fully functional.

HELP!!!!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: "Running" Programming through Mass Update
Reply #10 - May 9th, 2005 at 1:52pm
Print Post Print Post  
Okay Spencer,

I cleaned up your code for you made it more readable and understandable for Sesame. Note this is the end result. This will print an envelope for each person in the retrieve spec. I have tested this here and it works fine.

If you are not getting anything to print out check your AlternateDefaultPrinter() code and make sure it is right.

Also the Macro would just fire off a Mass Update which is also going to flash through every record, same as the code. So a macro is not going to be any cleaner than the code that you have.

The WriteLn's were put in there so that you personally could visually see what was happening and also where to put the envelope code. It was my way of helping to explain what the code was doing, and it makes no difference if they are in the program or not.

Don't use STOP. It is a command that is only in Sesame for Q&A compatibility and should be avoided. It also makes code hard to debug.

I believe it is already on the list for future enhancements to Sesame to be able to fire a Mass Update Spec from inside Programming without using a macro or @SelectTreeItem()

Code
Select All
var Z as int
var SaveRecord as Int
var SearchMode as Int
var LoadSort as Int
var LoadRetrieve as Int
Var DoRetrieve as Int
Var vCnt as Int
Var vLoop as Int
Var vTimes as Int

vLoop = 0
vTimes = 0

if not @update then
{
	z = @asynchshell("C:\Program Files\Sesame\Data\Sounds\Cannot Use Here.wav")
}
else If @Mode() <> 0 Then
{
	SaveRecord = @SelectTreeItem("Search Update Menu!Navigation!Save Record")
	SearchMode = @SelectTreeItem("Search Update Menu!Search (F7)")
	LoadSort = @LoadSortSpec("Alphabetical by Last Name")
	LoadRetrieve = @LoadRetrieveSpec("Paid Subscribers")
	DoRetrieve = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")

	If DoRetrieve = 1 Then
	{
		If @Askuser("You are about to print", @ResultSetTotal() + " envelopes","Do you want to do this?") Then
		{
			While ((vCnt = 0) And (vTimes < 10))
			{
				vTimes = vTimes + 1
				Loiter(1000)
				vCnt = @FormResultSetTotal("Main Form")
			}
			Writeln(vCnt + " Total Records")

			AlternateDefaultPrinter("Envelopes")
			PrintPagePaper(30)
			While (vLoop < vCnt)
			{
				vLoop = vLoop + 1

				FormResultSetCurrentPosition("Main Form", vLoop)
	 			     	writeln("Record Number " + vLoop + " prints an envelope for " + Mail Name)

				Newpage(950,412)
				PrintString("Herbert Teicher", 30, 25, 0, "Arial", 14, 0)
				PrintString("26 McDonald Street", 30, @PageExtentY(), 0, "Arial", 14, 0)
				PrintString("Staten Island, NY  10314-5055", 30, @PageExtentY(), 0, "Arial", 14, 0)

				PrintString(Mail Name, 450, 200, 0, "BArial", 16, 0)
				PrintString(Add1 , 450, @PageExtentY(), 0, "BArial", 16, 0)
				PrintString(City + ", " + State + "  " + Zip, 450, @PageExtentY(), 0, "BArial", 16, 0)

				PrintString("Thanks for supporting The Middle Villager Newsletter", 30, 355, 0, "IArial", 12, 0)
				FinishPage()
			}
			Writeln("Done Looping")
			FormResultSetCurrentPosition("Main Form", 1)
			RestoreDefaultPrinter()
		}
	}
}
 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
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: "Running" Programming through Mass Update
Reply #11 - May 9th, 2005 at 9:14pm
Print Post Print Post  
Ray, re the future function,

Thanks for considering this as a future function.

Please keep in mind the option to allow us to choose whether or not we want to use manual Intervention in the update process.  Please allow a switch to enable/disable the intervention prompt.   

This should also allow us to include a RetrieveSpec, a SortSpec and and UpdateSpec, right?  We could make a "dummy" spec for any of the three categories, or the defaults could be All Records, Ascending, NullMassUpdate?

Suggestion for four (4) parameters in the function:
RetrieveSpec(null=All records, option=RetrieveSpecName)
SortSpec(null=Ascending, options=Desc, or SortSpecName)
UpdateSpec(null=NullMassUpdate, option=UpdateSpecName)
Intervention(null=none, option = manual or none)
  



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


Canadian Government =
Elected Dictatorship

Posts: 88
Location: Peoples Republic of Kanada
Joined: Apr 20th, 2005
Re: "Running" Programming through Mass Update
Reply #12 - May 10th, 2005 at 12:46pm
Print Post Print Post  
Thanks for the idea, a print envelope button would be very useful!

Wonder what kind of trouble I can get into here  Shocked Shocked
  
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: "Running" Programming through Mass Update
Reply #13 - May 13th, 2005 at 6:44pm
Print Post Print Post  
Ray -

First, my apologies for not responding sooner; however, other priorities demanded my attention.

HIP HIP HOORAY AND A GREAT BIG THANK YOU - I HAVE WHAT I WANT!!!!

The programming appears to work flawlessly.  Although I haven't actually printed the set of envelopes (I did test one), it (writeln) reports the correct number and selection of specific records as having been processed, and the correct number of pending documents is listed in my print queue.  

I am so very pleased to have this completed since I can use it (along with variations) in several situations.

I am not real familiar with using sbasic, so I have a couple of questions for you after trying to figure out the programming as best I can.

One thing that I am totally confused about is the reason for stating:

Code
Select All
While ((vCnt = 0 And (vTimes <10)) 



Since both vCnt and vTimes are initially set to "0"  why are you using vTimes <10 (instead of vTime = 0)? I just can't figure out what the <10 does.

Also, how would I know to include a "Loiter" statement?  

Is the pause needed in all loop progamming execution?  (If so, couldn't it be built into Sesame itself?)  

And once having determined that Loiter is needed, is 1000 something of a "standard?"


Your feedback on these questions wll give me a better understanding of using sbasic. Thanks!

As for the coding support to print multiple envelopes, once again, a HEARTFELT THANK YOU!!!!  It was a critical element of my application and I am delighted to now have it in place.

- Spencer
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: "Running" Programming through Mass Update
Reply #14 - May 13th, 2005 at 7:20pm
Print Post Print Post  
If you look in the while loop vLoop is being increased by 1 each time so the less than ten means the loop will run 10 times, unless vCnt is set to not equal 0.

The reason for the loiter is to pause the sbasic. The reason for the pause is so that Sesame will have time to retrieve the records. Depending on the application(DB) file you are in and how many records you have this may take longer than another person. So what I did was loop until the record count was returned. Once the record count is something other than zero then we know we have records.

You might not need the loiter statement, it all depends on how fast your application gets and sorts the records. If you writeln the value of @FormResultSetTotal and it is not Zero, then you do not need to loiter.

No the pause is not needed in all loops just this one as we are waiting for a condition to be true. In most cases you do not need to pause at all but if you find a spot where you need to pause, feel free to loiter.

1000 means 1 second. It could be set to more or less.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print