View Full Version : INI FILES and fmcompute
stehl
24-Nov-2009, 08:45 PM
Alright.
In a previous post , I was told that I can hide the fmcompute in an .ini file. After reading the how-to I am confused because it says it does not handle any multi-form data, which my whole fmcompute does. Also it says it can only have one per formail. But I have two fmcompe1's on two different pages, so How would I make this work.
Suggestions appreciated.
russellr
03-Dec-2009, 09:39 PM
Hi,
Sorry for the delay, I thought I'd already answered this one (maybe in another thread?).
An INI file gets loaded on every page of a multi-page form. So, depending on what you're specifying in it, this is not useful.
(We'll be superseding INI files in a future version of FormMail, to avoid this problem.)
For example, if you specified "recipients" in an INI file, then FormMail would email you after every page submission. In general, not what you want. :)
Similarly for "fmcompute1", "fmcompute2", and so - they will get executed after every page submission.
Now, because of the logic you can implement, this isn't a major hurdle.
What you need is to provide an "if" statement around the logic that identifies when to execute.
For example,
total = price_1 + price_2;
would become:
if (page_number == 3)
{
total = price_1 + price_2;
}
to ensure that this calculation only happens after page 3.
Then, on the pages of your multi-page form, you include a hidden field that identifies the page number. On page 1:
<input type="hidden" name="page_number" value="1" />
And on page 3:
<input type="hidden" name="page_number" value="3" />
stehl
11-Dec-2009, 09:49 PM
So could I set up the if statments and just copy the code from the fmcompute, minus the <input type ...............
Basically start from
import function FMFatalError,FMFatalUserError;
import function FMUserError;
import string product1a;
export string next_form,price,price22,cont,upgrade;
export float fPrice1(2,'.',','), fsavings(2,'.',','), ship(2,'.',',');
cont = 'not ready';
price = 'not ready';
price22 = 'not';
fsavings = 0;
ship = 0;
upgrade = 'not set';
and go from there. or how does that work?
russellr
11-Dec-2009, 10:39 PM
Hi,
Yes.
Grab the code from your first page's "fmcompute" and put it in the INI file like this:
[special_fields]
fmcompute1 = "
import function FMFatalError,FMFatalUserError;
import function FMUserError;
import string product1a;
/* other imports and exports for page1 */
/* logic for page1 */
"
Now, simply do this:
[special_fields]
fmcompute1 = "
import function FMFatalError,FMFatalUserError;
import function FMUserError;
import string product1a;
import string page_number;
if (page_number == '1')
{
/* other imports and exports for page1 */
/* logic for page1 */
}
"
Powered by vBulletin® Version 4.1.4 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.