Wednesday, October 22, 2008

Many useful libraries are included in the standard VBScript and JScript languages. There are libraries for regular expressions, string manipulation, math, and much more.

There are also libraries for connecting to databases. And while there is a FC8 Database Check rule, often you will want to customize its behavior. You can do that by connecting to the database with vbscript and adjusting the logic as you need. Here is an example of connecting to a Microsoft Access Database and populating the result to a suggestion box.

FC8:
Dim conn
Dim rs
Dim strSQLQuery
Dim arrayRows

Wednesday, October 22, 2008 12:04:13 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0]  | 
Tuesday, September 02, 2008

var ItemsCount = Field(“Total”).Items.Count;
var Sum = 0;
Field(“TotalAmount”).Value = Field(“TotalAmount”).Value.replace(” “,”“);
for( i = 0; i     Field(“Total”).Items.Item(i).Value = Field(“Total”).Items.Item(i).Value.replace(” “,”“);
    Sum = Sum + parseFloat(Field(“Total”).Items.Item(i).Value);
}
if (Sum != parseFloat(Field(“TotalAmount”).Value)) {
    CheckSucceeded = false;
    ErrorMessage = “Sum of values in Total column doesn’t match TotalAmount value”;  
    Field(“TotalAmount”).Suggest( Sum );
}
else {
    CheckSucceeded = true;
}

Tuesday, September 02, 2008 8:45:37 AM (Mountain Standard Time, UTC-07:00)  #    Comments [0]  | 
Monday, June 23, 2008

Rect r;
If Not kwInvoiceNumber1.IsNull Then {
r = kwInvoiceNumber1.Rect;
r.Inflate(10*dt,10*dt);
restrictsearcharea(r);
}
Else If Not kwInvoiceNumber2.IsNull Then {
r = kwInvoiceNumber2.Rect;
r.Inflate(10*dt,10*dt);
restrictsearcharea(r);
}
Else DontFind;

Monday, June 23, 2008 7:21:52 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0]  | 
Friday, June 13, 2008

Zero Padding a Field to 10 characters- VB Script

dim cnt
dim iter
dim tempString
cnt = Len(me.Field("StoreNumber").Value)
tempString = me.Field("StoreNumber").Value
For iter = 0 to 10-cnt
tempString = "0" + tempString
Next

Adding Dashes to a Social Security Number - VB Script

Dim TempSSN
TempSSN = Mid( Me.Field("SSN").Value, 1, 3 )
TempSSN = TempSSN & "-"
TempSSN = TempSSN & Mid( Me.Field("SSN").Value, 4, 2 )
TempSSN = TempSSN & "-"
TempSSN = TempSSN & Mid( Me.Field("SSN").Value, 6, 4 )
Me.Field("SSN").Value = TempSSN

Concatenating Values from a column of a table into a single field - JScript

var ItemsCount = Field("TotalColumn").Items.Count;
var Sum = 0;
var tempField = "";
for( i = 0; i < ItemsCount; i++ ){
tempField = tempField + "," + Field("TotalColumn").Items.Item(i).Value;
}
Field("CombineField").Value = tempField;

Friday, June 13, 2008 4:27:46 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0]  | 
Thursday, June 12, 2008

Finding addresses is hard if the address is unlabeled.

Use this regular expression in a character string to help find addresses. Add post-search code that favors addresses near the top of the page ( FuzzyQuality: Top, {0,0,200,25000 }*dt; ), and/or near some address label ( FuzzyQuality: AddressLabel.Left - Left, {0,0,200,15000 }*dt; ), and you'll be acquiring addresses like you're Donald Trump.

[0-9]{1-6}*{1-30}(
([Dd]*{0-10}[Ee])|([Dd][Rr])
|([Ss]*{0-7}[Tt])
|([Aa]*{0-7}[Ee])|([Aa][Vv])
|([Cc]*{0-7}[Tt])
|([Bb]*{0-10}[Dd])
|([Ll]*{0-3}[Ee]))*{0-30}

Thursday, June 12, 2008 4:32:36 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0]  | 

Pick a theme: