Jump to content

Running out of space when defining a calculation!


This topic is 6676 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a problem where I am decoding and translating a specifically formatted text string into english

Basically the original string is composed of "tokens" .... each token contains information for an airline flight segment and follows specific rules.

Breaking a single token down into english is not a problem.... but each string can consist of many tokens. I have a calculatin where I break the string into tokens and then translate each... but after 11 I run out of space in the define calculation box (FM says 3000 characcters is the maximum allowed for a calculation)

The way I wrote it is to break the string (the "_" character is the token separator), and translate token1, then translate token 2 etc etc. The calculation on each token is identical.... so my question is ... Is there a way of setting this calc so that I dont have to rewrite it each time... which would get me round the 3000 character limitation

I have attached a sample file with a string and calculated translation field as I have it now, but it only translates the first 12 tokens

Stringtest.fp7.zip

Link to comment
Share on other sites

Copy and Paste the calculation.

Or,

Get Developer v7 or Advance v8 and make a CF "Custom Function". Also, in v8, you can copy copy a field from one layout to another.

Lee

After looking at the file, isn't it more of a case of getting lost than anything else?

You can create this in a text editor and then paste it in, it may be easier to read and follow.

Lee

Edited by Guest
Link to comment
Share on other sites

I guess I maybe nee d to explain it better:)

Basically the string breaks into a list of values using a substitute

Let ( [F= Substitute ( Stringtest::String ; ["_" ; ¶ ] ; [ "V(" ; ""] ; [ " " ; "#" ] ; [ "]-" ; " " ] ; [ "-[" ; " " ] ; ["V???" ; "???" ] ; [")-[" ; " "] ; [ ")" ; ""] ; [ "

... so for example a shorter string of

V(/CA)-[AC#L

becomes a value list

/CA AC#L E00991111 E11992222 E55667788 NUSD20

/CA AC#L LHR-GLA-MAN

LHR AC#L BFS-EDI-GLA-MAN-LBA-MME-ABZ-INV

Any single value can be translated using the calc below where TOKEN = the specific value being translated

I break each token into a list of components using a second substitution... each has three mandatory components... first , second and last lines and up to 7 optional components which is why the calc checks what is on each of the lines from 3-9.

Thus if TOKEN = /CA AC#L E00991111 E11992222 E55667788 NUSD20

Let ( [ A= Substitute ( TOKEN ; " " ; ¶ ) ; B = ValueCount (A) ] ;

¶ & " From: " & Substitute ( LeftValues (A ;1 ) ; "-" ; " or " ) &

" To: " & Substitute ( RightValues (A ;1 ) ; "-" ; " or " ) &

" Airline: " & Left ( MiddleValues (A ;2 ; 1 ) ; 2 ) & " Class: " & Case ( Length (MiddleValues (A ;2 ; 1 )) = 4 ; "Same as fare" & ¶ ;Right ( MiddleValues (A ;2 ; 1 ) ; 2 ) ) &

Case (B >3 and Left (MiddleValues(A; 3;1); 1 )= "N" ; Substitute (MiddleValues(A; 3;1) ; ["N" ; " Buy - "]; ["3 ; Substitute (MiddleValues(A; 3;1) ; ["I" ; " Permitted Flights "]; ["E" ; " Restricted Flights "] ; [ Right ( MiddleValues(A; 3;1) ; 5 ) ; "-" & Right ( MiddleValues(A; 3;1) ; 5 )] ; [ ¶ ; ""] ) ;" Flight Restrictions: None" ) &

Case (B >4 and Left (MiddleValues(A; 4;1); 1 )= "N" ; Substitute (MiddleValues(A; 4;1) ; ["N" ; " Buy - "]; ["4 ;Substitute (MiddleValues(A; 4;1) ; ["I" ; ", "]; ["E" ; ", "] ; [ Right ( MiddleValues(A; 4;1) ; 5 ) ; "-" & Right ( MiddleValues(A; 4;1) ; 5 )] ; [ ¶ ; ""]) ; "" ) &

Case (B >5 and Left (MiddleValues(A; 5;1); 1 )= "N" ; ¶ & Substitute (MiddleValues(A; 5;1) ; ["N" ; " Buy - "]; ["5 ; Substitute (MiddleValues(A; 5;1) ; ["I" ; ", "]; ["E" ; ", "] ; [ Right ( MiddleValues(A; 5;1) ; 5 ) ; "-" & Right ( MiddleValues(A; 5;1) ; 5 )] ; [ ¶ ; ""]) ) &

Case (B >6 and Left (MiddleValues(A; 6;1); 1 )= "N" ; ¶ & Substitute (MiddleValues(A; 6;1) ; ["N" ; " Buy - "]; ["6 ; Substitute (MiddleValues(A; 6;1) ; ["I" ; ", "]; ["E" ; ", "] ; [ Right ( MiddleValues(A; 6;1) ; 5 ) ; "-" & Right ( MiddleValues(A; 6;1) ; 5 )] ; [ ¶ ; ""]) )&

Case (B >7 and Left (MiddleValues(A; 7;1); 1 )= "N" ; ¶ & Substitute (MiddleValues(A; 7;1) ; ["N" ; " Buy - "]; ["7 ; Substitute (MiddleValues(A; 7;1) ; ["I" ; ", "]; ["E" ; ", "] ; [ Right ( MiddleValues(A; 7;1) ; 5 ) ; "-" & Right ( MiddleValues(A; 7;1) ; 5 )] ; [ ¶ ; ""]) )&

Case (B >8 and Left (MiddleValues(A; 8;1); 1 )= "N" ; ¶ & Substitute (MiddleValues(A; 8;1) ; ["N" ; " Buy - "]; ["8 ; Substitute (MiddleValues(A; 8;1) ; ["I" ; ", "]; ["E" ; ", "] ; [ Right ( MiddleValues(A; 8;1) ; 5 ) ; "-" & Right ( MiddleValues(A; 8;1) ; 5 )] ; [ ¶ ; ""]) ) &

Case ( B>9 and (Left (MiddleValues(A; 9;1); 1 )= "N") ; Substitute (MiddleValues(A; 9;1) ; ["N" ; " Buy - "]; ["

produces

To: /CA

Airline: AC Class: L

Restricted Flights 0099-1111, 1199-2222, 5566-7788

Buy - USD20 Sell - USD30

I repeated the calc on each value in the list and translate each token separately. The problem comes when there are more than 11 tokens... I run out of space in the define calculation box to extend the equation.

Obviously the bulk of the space used is by repeating the same calc over and over again as i translate each tokenand I was trying to find a way to avoid this...

Have I explained it any better this time? :

Edited by Guest
Link to comment
Share on other sites

I am sorry - I meant plain English, not a Filemaker calulation (which I am having a hard time reading, not to mention understanding). Please explain to a layman how to decipher the string, using nothing but paper and pencil.

---EDIT---

Also, what's the maximum of items in a string, and the maximum of flight restriction in an item?

Edited by Guest
Link to comment
Share on other sites

Ok... I will try in english

the string refers to flights segments , as I said each string is composed of tokens using the underscore character ("_") as a separator

The example below is written as the format for a single token with the variables enclosed in {}

V({TLC})-[{X}]-V({TLC})

Where {TLC} = three letter codesof airports separated by "-" eg NYC-LAX-MIA

{X} is made up of a generic format

AL {C}{

Where AL = Airline code followed by a space (mandatory).

Optional elements are

{C} = airline class (single letter

{

{

Thus a simple string might be

V(NYC)-[DL }-V(MIA)

which would translate as being from NYC to MIA on airline DL with no flight restrictions

whereas a longer example might be

V(LON-FRA-VIE-PAR)-[QF V

which would translate as from LON or FRA or VIE or PAR to HKG on airline QF in V class, restricted flights are from 1-999 and 4000-4999 with a buy price of USD 25 and a sell price of USD 50

Any one token has three mandatory elements From, To and airline.

Optional elements are class

flight restrictions (up to six sets)

additional buy/sell price

Ther is no theoretical limit on the total number of tokens per string, it depends on how complicated the airlne rules are and how good the person reading the rules and entering data is... I have seen strings of up to 250 tokens

Thanks for trying to uderstand.... if you need any more clarification please let me know

Edited by Guest
Link to comment
Share on other sites

OK, that makes it much clearer.

Now the only question is what is your purpose here. If the only requirement is a pretty document for human consumption, then I would suggest you try another tool. Any text editor with GREP search (such as the free Textwrangler) should be able to do this with much less hassle than Filemaker. I myself can't assist you in this, but perhaps Lee might come up with a pattern.

If, OTOH, you want to turn the string into a DATABASE, then I would start with breaking it into RECORDS and FIELDS. Each token would become a record with the following fields:

Token

cOrigins (text calculation with multi-line values)

cDestinations (text calculation with multi-line values)

cAirline

cClass

cRestrictions (text calculation with multi-line values)

cPermissions (text calculation with multi-line values)

cBuyPrice

cSellPrice

The calculations resulting in multi-line values could also be repeating fields.

Of course, once you have the database, you can also produce a report - so that would give you your readable document after all. But if that's your only purpose, it's hardly worth the effort.

Link to comment
Share on other sites

Hi Chalkster,

Your problem is an unknown number of tokens. This means you need to 1) hard-code in your calc which you realize is not acceptable, 2) use

custom function for recursion 3) Use GREP or some other method, or 4) create records. Creating records will provide unlimited tokens with a

simpler calculation. Here's the general idea on turning each token line into a record which can then accept one calculation evaluation. I'm a bit

busy and didn't even mess with your calc - except switching it to apply to one token. It's rough and ugly but I hope it gives you the idea here. If

you wish to break it further into fields, that can be done also but, as Michael said, much depends upon how badly you want/need it. You

obviously want it badly enough to put this much effort into it. The attached sample file is very easy, as you will see.

Note: I used a Creator global to create each record - a simple number series. Depending upon your need, you would either need to delete the

Creator values (from each record) in Tokens after each process (if you leave the records in Tokens) or use a unique value in Strings::Creator so

it doesn't overwrite your existing tokens. I also used a StringsWorking field from which to parse, leaving your original Strings intact. Once

perfected, you may not need two fields here. In Tokens, you don't really need everything in a field. A simple calculation to display the Token

line would suffice (as I've done).

I didn't correct the calc in Tokens to fix the spacing in the first record. I've no doubt you'll take it from here. You've put so much work into it, I

didn't want you to have to start over with another approach when this intermediate solution might just do the trick instead. :wink2:

LaRetta

StringtestREV.zip

Link to comment
Share on other sites

This topic is 6676 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.