Return-Path: <willitsg@pacbell.net>
User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022
Date: Fri, 28 Dec 2001 10:03:04 -0800
Subject: Re: [IF] & Databases
From: Greg Willits <willitsg@pacbell.net>
To: Pierre <pcbg@pierre-chenxu.com.sg>
>Hi Pierre --
Hi Greg,
>Sorry for the delay...
Oh no, Greg. Please don't say sorry. You have helped me so much, and I
should be saying
a million thanks to you instead.
> [If: [String_Extract: StartPosition=4, EndPosition=5, 'ID']=="SG" ]
Should be:
[If: (String_Extract:
StartPosition=4,
EndPosition=5,
> (form_param:'ID',encodenone)) =='SG']
Got it.
>Changes are:
- tags within other tags get () instead of []
- you forgot to define what 'ID' is
- always use single quotes for Lasso literals like 'SG'
You can do this in a more simple way. Lasso allows just about anything to be
a variable. So, it is possible to do this:
[If: (String_Extract:
StartPosition=4,
EndPosition=5,
(form_param:'ID',encodenone)) =='SG']
[var_set:'dbName'='XYZ_Sing']
[else:if: (String_Extract:
StartPosition=4,
EndPosition=5,
(form_param:'ID',encodenone)) =='AU']
[var_set:'dbName'='XYZ_Aussy']
[else:if: (String_Extract:
StartPosition=4,
EndPosition=5,
(form_param:'ID',encodenone)) =='US']
[var_set:'dbName'='XYZ_US']
[/if]
[Inline: -search,
-database=(var:'dbName',encodenone), <----- notice this
-layout='Commission',
-operator='eq', 'UserID'=(form_param:'UserID',encodenone),
-operator='eq', 'PIN'=(form_param:'PIN',encodenone),
-operator='eq', 'ID'=(form_param:'ID',encodenone)]
[If: (found_count)=1]
..... display data table here.....
[Else: ...Display messages here]
> [/Inline]
>This is easier to maintain.
The above works perfectly now. Actually, initially it didn't work for nearly
three
hours of trials, and I just won't give up, knowing that it should work.
Eventually,
I found out that the IIS in my Laptop (which is used for my Lasso
development work all this while)
has suddenly disappeared by itself. This is a very weird scenario, and has
never happened before.
I then reinstall evrything needed on my desktop and tried again, and it works!!!
And yes, this is much easier to maintain.
BTW, I found that without the () for the String_Extract also works, such as:
[If: String_Extract:
StartPosition=4,
EndPosition=5,
(form_param:'ID',encodenone) =='SG']
>Also, I would think it is not necessary to have three databases. Are the
calculations you mentioned performed by FileMaker or by Lasso?
By FMP.
>Either way it
is easy to use [if] to make decisions like the example above. If the
calculations are in FMP, then FMP can also test string characters and can
have IF or CASE statements to make different calculations.
Yes. I am using the IF, CASE, CALC functions in FMP.
>If the
calculations are in Lasso (this would be faster, and compatible with other
databases such as MySQL which do not perform calculations), then IF
statements can be used to select a certain formula.
This requires more Lasso work, but is much easier to maintain after it is
>completed the first time.
I see. I'll gradually switch to using Lasso to do the calculations.
>I believe one of your first messages to me was only to my direct email
address which is how we got started. So, it is OK with me to go back to
>LassoTalk.
I see. The return path in this reply is also directed to your private email,
but I changed it to go via LassoTalk.
>Hope I'm not too late to help.
No. You've been very helpful, and I really appreciate it very much.
Hope you don't mind me asking a few more questions.
1. Under what different circumstances/conditions should a single equal sign '='
or double equal sign '==' be used?
2. When should a 'encodenone' or 'encoderaw' be used?
3. I recall reading from somewhere that the Inline codes for need not
be preceded with '-' prefix. Is that true?
4. I have a lasso file (called BnsStmt.lasso) with 10 lines of codes, of
which 2 similar ones
are as shown below.
Each of the 10 codes is different only by the Level Number (denoted by L1,
L2, ... L10).
<a href="BnsStmt_[var:'Ctry']_Dtl_L1.lasso?RcrdID=[RecordID_Value]">L1</a>
<a href="BnsStmt_[var:'Ctry']_Dtl_L2.lasso?RcrdID=[RecordID_value]">L2</a>
>From the codes you'll see that the display buttons on the browser are just the
letters L1, L2, L3 up to L10. When L1 button is clicked, it will activate
the lasso file
named BnsStmt_[var:'Ctry']_Dtl_L1.lasso, and when L2 is clicked
BnsStmt_[var:'Ctry']_Dtl_L2.lasso
will be activated, and so on.
[var:'Ctry'] is set to return as 'Sing', 'Aussy', or 'US' depending on what the
'String_Extract' (in the earlier example) has found.
You can see that there are 30 possible links to create - 3 possible
countries multiply by 10 Levels
(from L1 to L10) per country. Each link is supposed to display the Detail
Bonus Statement for
a particular Level for one of the 3 countries, depending on where the
salesperson belong to.
In order to have ease of maintenance, I wish to cut down to either 3 lasso
files (one file for one
country, each to display the L1 to L10 Levels data)
Example:
Sing File Aussy File US File
--------- --------- -------
L1 data L1 data L1 data
L2 data L2 data L2 data
. . .
. . .
. . .
L10 data L10 data L10 data
OR if not possible, then to reduce to 10 lasso files
(each file will contain data for one Level, but separately for each of the 3
countries).
L1 File L2 File .... L10 File
------- ------- --------
Sing data Sing data Sing data
Aussy data Aussy data Aussy data
US data US data US data
When a salesperson first logged-in, his ID input will automatically display
the data for the specific
country where he belongs.
So, the next thing he wishes to view is the details in the various Levels.
Each person can view
each of all the 10 Levels of detail bonus statement.
Let me use the example of a salesperson from 'Sing'
After he enters his ID, the BnsStmt.lasso file will display the appropriate
data from 'XYZ_Sing'
database. The L1 to L10 text buttons will also display.
If he clicks the L1 button, he will activate the line of code:
<a href="BnsStmt_[var:'Ctry']_Dtl_L1.lasso?RcrdID=[RecordID_Value]">L1</a>
If I were to accomplish the 3-file choice, then the following 'Sing' file
will be referenced to:
Sing File
---------
L1 data
L2 data
.
.
.
L10 data
So, I have to have the codes in place like:
[If: (??? == L1)]
[var_set:'Lev'='L1']
[else:if: (??? == L2)]
[var_set:'Lev'='L2']
[else:if: (??? == L3)]
[var_set:'Lev'='L3']
and so on...
[/If]
[Inline: -search,
-database='XYZ_Sing',
-layout='(var:'Lev') Bonus'
Rcrd=(RecordID_Value),
[If: (found_count) = 1]
...Display appropriate data here...
[else]
... Message here...
[/If]
I supposed the logical condition to use will be to extract the level number
(that is: L1 or L2 or L3, etc..)
from the line of code <a
href="BnsStmt_[var:'Ctry']_Dtl_L1.lasso?RcrdID=[RecordID_Value]">L1</a>
Question1:
====== How do I extract the 'L1' letters from the above line of code to use in the
Inline Code?
The two letters 'L1' in the above code is considered as in what position if
the String_Extract tag is used?
I tried using the String_Extract tag on "BnsStmt_[var:'Ctry']_Dtl_L1.lasso"
as follows:
[if:String_Extract:
StartPosition=18,
EndPosition=19,
(form_param:'BnsStmt_Sing_Dtl_L1.lasso')=='Sing']
However, the above didn't work. I must have done something incorrectly with
the coding.
Question2:
========I have named the layouts for each of the Level's bonus in the FMP databse
file as L1Bonus, L2 Bonus and so on.
So, in the Inline code -layout tag, how should I substitute the variable? I
believe I can't
use -layout='(var:'Lev') Bonus' as shown above.
I had initially also thought of using just one file with all the different
conditions set to display the appropriate data
from the specific layout from the FMP database. However, I believe it may be
too complicated to achieve it.
Each action will then have to depend on two sets of conditions - the country
and the Level.
So, need to extract from the previous lasso format file action, the country
code ('Sing' or 'Aussy' or 'US') and the Level (L1, L2.. L10) to use as the
condition.
No doubt, you are in the best position to advice me.
Thanks very much again, Greg.
Best Regards: Pierre
-- Greg Willits
-- willitsg@pacbell.net
----------------------------------------------------------------------
[FrameWork:] A guide to intermediate Lasso and comprehensive user
authentication and management. http:////www.turnfast.com/ldml/
----------------------------------------------------------------------
http:////www.verteq.com/ http:////www.turnfast.com/
----------------------------------------------------------------------
From: Pierre <pcbg@pierre-chenxu.com.sg>
Date: Mon, 24 Dec 2001 01:06:18 +0800
To: willitsg@pacbell.net
Thanks very much, Greg.
>This is because of inlines. The search is actually performed by the inline,
and the inline has not been told what to do in the case of errors. You can
think of inlines as an independent page within a page.
I see.
>The requiredfield was submitted with the form, so Lasso knows what to do
when it sees this error. Telling that form what to do with a failed search
is meaningless to Lasso, becuase that form is not submitting a search action
(it is submitting a -nothing action).
I see.
>Unfortunately, it is not as simple as adding a -NoResultsError line to the
inline (I sure wish it was).
Instead you must use a structure like this with your inline:
[inline: -search,
-database='YOUR_DB_NAME',
-layout='YOUR_LAYOUT_NAME',
-recordID=(form_param:'rcrdID')]
[if: (found_count) != 0]
..... in here put the HTML code that arranges the table
..... and Lasso code how you want it, like:
[field:'firstname']<br>
[field:'lastname']<br>
[else]
..... your message to the user ....
[/if]
[/inline]
The above example code did help me get it work perfectly now!
>As you can imagine, testing for every possible error, and getting the right
message to the user for the right conditions gets quite involved. In
Framework, you'll find a simple error management system that works well for
many cases. (In Framework 2.0 (due in late Jan/Feb probably) I have
developed a very sophisticated and flexible error management system),
You may want to go ahead and study Framework, as it is a ready-to-go system
to do much of what you are working on right now. (the link is below).
I got the Framework V1 downloaded and browsed through the notes yesterday
and today,
and found it very useful. I'll go through in more detail over the next week
or so.
I am looking forward to your V2 in Jan/Feb 2002.
Greg, I noticed that the return path to your email to me is your private
email
address. Do you mind if I post another reply to you via the LassoTalk?
Your very detailed explanation and solution to my problem may be beneficial
to
the other readers.
Well, I actually have constructed one master database for use by 3
countries.
I simply duplicate it into 3 and named them each with a different suffix.
For example: XYZ_Sing, XYZ_Aussy and XYZ_US
Sing = Singapore
Aussy= Australia
US = U.S.A.
The reason I do this is because while the structure is exactly the same,
some field values and commission payout differ among the 3 countries.
This way, I need only maintain the master file, and update or amend this
master and then duplicate into three, each time an amendment/update is
needed.
I am thinking of using only One Log-in site for salespeople from the 3
countries.
Each country's salespeople has a unique ID, which looks like the following:
BD<SG1000089>SG
BD<AU1000123>AU
BD<AU1000234>US
JB<US1000123>US
BD<SG1000210>US
The first 2 letters denote their position.
The other 2 prefix letters within < > refers to which country's program they
are in.
The last 2 suffix letters denote which country the salesperson resides in.
So, BD<SG1000089>SG is in the Singapore program, and he resides also in
Singapore.
BD<AU1000123>AU is in the Australia program, and he resides also in
Australia.
BD<AU1000234>US is in the Australia program, but he resides in USA.
JB<US1000123>US is in the USA program, and he resides also in USA. Although
he has
the exact 7 digit number (1000123) like BD<AU1000123>AU has, the unique
differentiation
is by the 2 letter prefix inside < >. One belongs to the US program, and the
other to
the Australia program.
BD<SG1000210>US is in the Singapore program, but he resides in USA.
Although I'm going to have one Access site (for ease of maintenance)
that can be logged in by any salespeople from any of the three countries,
I thought at first that I would still need to have three different Response
lasso files to display the search results by extracting from one of the
three dbase files separately, depending on the salesperson's Unique ID
submitted,
by recognising via the 2 letter prefix inside < >.
However, after some thoughts, I believe I should be able to make do with
only one
Response lasso file(instead of 3 separate ones) by using the 'IF' tag, and I
did
try out the following code as below, but it didn't work although I did have
the
3 duplicate dbase files for the 3 countries opened and configured via the
Lasso/Security site:
[If: [String_Extract: StartPosition=4, EndPosition=5, 'ID']=="SG" ]
[Inline: -search,
-database='XYZ_Sing',
-layout='Commission',
operator='eq', 'UserID'=(form_param:'UserID',encodenone),
operator='eq', 'PIN'=(form_param:'PIN',encodenone),
operator='eq', 'DistID'=(form_param:'ID',encodenone)]
[If: (found_count)=1]
..... display data table here.....
[Else: ...Display messages here]
[/Inline]
[Else: If: [String_Extract: StartPosition=4, EndPosition=5, 'ID']=='AU' ]
[Inline: -search,
-database='XYZ_Aussy',
-layout='Commission',
operator='eq', 'UserID'=(form_param:'UserID',encodenone),
operator='eq', 'PIN'=(form_param:'PIN',encodenone),
operator='eq', 'ID'=(form_param:'ID',encodenone)]
[If: (found_count)=1]
..... display data table here.....
[Else: ...Display messages here]
[/Inline]
[Else: If: [String_Extract: StartPosition=4, EndPosition=5, 'ID']=='US' ]
[Inline: -search,
-database='GXYZ_US',
-layout='Commission',
operator='eq', 'UserID'=(form_param:'UserID',encodenone),
operator='eq', 'PIN'=(form_param:'PIN',encodenone),
operator='eq', 'ID'=(form_param:'ID',encodenone)]
[If: (found_count)=1]
..... display data table here.....
[Else: ...Display messages here]
[/Inline]
[/If]
What have I done wrong? Or does this not work at all?
If so, what's the correct code to achieve what I intended? That is,
using only one Lasso Response file.
Thanks a million, Greg!
Best Regards & wishing you a Blessed Christmas & a prosperous and Healthy
New Year!
Pierre
-----------------------------------------------------------------------
To Unsubscribe: <mailto:LassoStudioDW-off@blueworld.com>
List Archives :
<http:////listsearch.blueworld.com/LassoStudioDWSearch.lasso>
Blue World Support Central : <http:////support.blueworld.com/>
Support Inquiries: <http:////support.blueworld.com/supportinquiry.lasso>
Note: Lasso Studio for Dreamweaver Talk is not an official technical
support forum.