Normal Topic A hodge podge (Read 1217 times)
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
A hodge podge
Apr 15th, 2006 at 2:31am
Print Post Print Post  
As anyone who has programmed Q&A or Sesame is aware, @Error will return the most recent error. But it only indicates that there has been as error (an din Q&A it is limited to the "X" commands). Some time ago I put @ErrorType() into Sesame 2.0 - that returns the type of the error that happened as an integer. Today I added "@ErrorString(type as int) as string" that returns an error string based on the integer passed in (presumably the same integer that @ErrorType() returned).

I also finished work on a command one of the Forum member asked for: @RegexReplaceString(expression as string, str as string, replacement as string) as string. This command accepts a regular expression, a string (that may match that expression zero of more times) and a replacement string that will replace those portion of the "str" that match the expression. This returns a string with the replacements. The original "str" is left unchanged.

So, for example:
Code
Select All
var aa as string

  aa = @RegexReplaceString("m", "my name is mark", "p") // This will return a string: "py nape is park" because it was told to replace all of the "m"s with "p"s.

  aa = @RegexReplaceString("m.*k", "he is mark", "peter") // This will return: "he is peter" because it was told to replace any portion of the string that starts with a "m" and ends with a "k" with the word "peter".

  aa = @RegexReplaceString("^m.*k$", "my name is mark", "no it is not") // This will return: "no it is not", because it was told to replace the portion of the string that is at the beginning of the string ("^") and starts with "m" and has a "k" at the end of the string ("$") - thus it replaces the entire string.
 



Today, Ray made a new SBasic command for 2.0: "@PrintAFormAsHtml(filename as string) as int" that will print the current form as a HTML file (web page) to the filename specified. This allows you to print a form as HTML, and then (for example) attach it to an EMail using @SendMail and send that web page via email.

I also put in a speed optimization for @FormFieldValue and FormFieldValue when accessing Table View subform. If the optimization survives alpha testing (let's hope), it will make table subform access a lot faster and have no "flashing".
« Last Edit: Apr 16th, 2006 at 2:26pm by The Cow »  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
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: A hodge podge
Reply #1 - Apr 17th, 2006 at 6:00am
Print Post Print Post  
Thanks for the Search/Replace Regex tool Mark.  Grin

I am confused though when you say the original string is not replaced.  How would a Search/Replace be done?
Here is an example of something I did earlier tonight in another application:

I had to look in an HTML document for instances of this single string:
Code
Select All
<radiobutton label='abc'><start></start></radiobutton>

 

And replace each instance with these four lines:
Code
Select All
<radiobutton label='xyz'><start></start></radiobutton>
<radiobutton label='def'><start></start></radiobutton>
<radiobutton label='prs'><start></start></radiobutton>
<radiobutton label='tuv'><start></start></radiobutton>

 



I was able to do that with Regex like this:
Search for:
(<radiobutton label=')abc('><start></start></radiobutton>)

Replace with:
\1xyz\2\n\1def\2\n\1prs\2\n\1tuv\2\n

If the original string is not replaced in Sesame, then how could I accomplish this?  I know you will have the answer.
-----------
The FormFieldValue speed enhancements sound like a nice touch.  Should make things look more stable, flashing things raise too many questions, even when normal.
----------
The error codes that are returned are those sent by the Operating System and/or Sesame engine?  Will need to get some references lined up for the meanings.  This should really help to make meaningful messages and advice back to the user. 
----------
I am looking forward to Version 2.0 even more than before, was that possible? Roll Eyes
Thanks for listening and providing tools that we have requested. Grin Grin
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
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: A hodge podge
Reply #2 - Apr 17th, 2006 at 1:17pm
Print Post Print Post  
Quote:
If the original string is not replaced in Sesame, then how could I accomplish this?  I know you will have the answer.


Bob,

It works the same way as @Replace(). For example, say your command is
Code
Select All
A = @RegexReplaceString(B, C, D) 



The command is going to search for B in C and replace it with D and then return the Altered String to A. The original string C is unaltered and the altered value is in the returned string A. So to do what you are asking you would want to use something like the code below.

Code
Select All
C = @RegexReplaceString(B, C, D) 



-Ray
  

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



Posts: 2530
Joined: Nov 22nd, 2002
Re: A hodge podge
Reply #3 - Apr 17th, 2006 at 1:37pm
Print Post Print Post  
Quote:
Thanks for the Search/Replace Regex tool Mark.  Grin

I am confused though when you say the original string is not replaced.  How would a Search/Replace be done?


@RegexReplaceString returns a new string with the values replaced as specified:
Code
Select All
var strA as string
var strB as string

strA = "The cow jumped over the moon"
strB = @RegexReplaceString("cow", strA, "dog")

// At this point we have two strings, one in strA and one in StrB
// strA is equal to "The cow jumped over the moon"
// strB is equal to "The dog jumped over the moon"
// If you wish you can "go with" strB, by assigning it back in to strA
// or any other variable or LE; or you can keep using strA.

strA = @RegexReplaceString("moon", strB, "fence")

// Now we still have two different strings:
// strA is equal to "The dog jumped over the fence"
// strB is equal to "The dog jumped over the moon"

// If you want to simply reuse the same variable:

strA = @RegexReplaceString("jumped", strA, "leaped")

// strA is equal to "The dog leaped over the fence"

 



Quote:
The error codes that are returned are those sent by the Operating System and/or Sesame engine?  Will need to get some references lined up for the meanings.  This should really help to make meaningful messages and advice back to the user. 


They are the errors generated by the last SBasic command executed. None of them are operating system errors. They are not engine errors, either - in that SBasic almost always runs on the client.

Included with Sesame 2.0, there is an "include file" that can be included in any SBasic code you write. This includes the error messages, the error codes, and lots of other definitions and etc... It is an ordinary text file and can be copied and altered as the programmer sees fit. I don't recommend that Sesame's text error messages be passed to the user. They are there to help developers debug applications. Applications should probably have application specific error messages. If any of the SBasic runtime error messages come up, the application needs to be debugged. They are all pretty dire conditions that should never come up in normal operation.


  

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


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: A hodge podge
Reply #4 - Apr 17th, 2006 at 2:39pm
Print Post Print Post  
Quote:
If the optimization survives alpha testing (let's hope), it will make table subform access a lot faster and have no "flashing".


The no flashing may not be earth shaking or all that exciting to most, however I can tell you from real world experience this improvement would be an incredible aid in not freaking out the users. I thank you whole heartedly for attempting this improvement!

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: A hodge podge
Reply #5 - Apr 17th, 2006 at 6:05pm
Print Post Print Post  
I have to agree with BobScott on the Formfieldvalue optimization. Our office staff would really appreciate it, and we would LOVE to see more speed when working with table mode 'line items'.

All the new features you've been mentioning look fantastic, and this one especially got my attention.

Thanks and keep up the great work!

Steve
  
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: A hodge podge
Reply #6 - Apr 17th, 2006 at 8:58pm
Print Post Print Post  
If you are looping through the subform to retrieve values from each record, to get a total cost of items sold for example, there will be an easier way in 2.0. I believe it is also significantly faster. These few lines

Code
Select All
Var vList as String
Var vGrand as Double

vList = @FormGetValues("LineItems", "Total")
vGrand = @SumListValues(vList) 



do the same thing in 2.0 that the following lines do in 1.1.3

Code
Select All
Var vList as String
Var vGrand as Double
Var vLoop as Int
Var vCnt as Int

vLoop = 1
vCnt = @FormResultSetTotal("LineItems")
vGrand = 0

While vLoop <= vCnt
{
	vGrand = vGrand + @ToNumber(@FormFieldValue("LineItems", "Total", vLoop))
	vLoop = vLoop + 1
} 



-Ray
  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: A hodge podge
Reply #7 - Apr 17th, 2006 at 9:23pm
Print Post Print Post  
Quote:
Code
Select All
Var vList as String
Var vGrand as Double

vList = @FormGetValues("LineItems", "Total")
vGrand = @SumListValues(vList) 



Fantasic! 8)

That alone, looks like it will result in a great speed boost.

------------------------------------------------------------------------

BTW (Bob Hansen, Bob Scott, & Steve), the "-novisualupdate" switch will remove most of the flashing, as well as make a small speed improvement.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged