Jump to content

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

Recommended Posts

Posted

Hello,

Does anybody know whether it is possible to construct a fieldname in a scriptstep? What I would like to do is to make a loop. In this loop there must be a scriptstep that pastes a result in a field. The name of this field varies all the time, for example the first time the field is 'result1', the second time 'result2' and so on. In order to do this, I would like to change the name of the field with some formula, e.g. 'result+a' in which 'a' becomes higher all the time.

Well, sorry for my lovely English, but I hope somebody understands. Any help is appreciated!

Martin

Posted

In other words the field name itself is a field - a calculation . . . . does that help?

But if we're talking about an unfixed number of results, I'm wondering if you'd be better off having your results show up in a portal - and in this way you'd get the number part for free - i.e. number of portal rows = number of results . . .

Posted

Hi Booboo,

Thanks for your reply. You understand the problem, but I'm afraid that I don't understand your answer. I would indeed like to use a field/calculation for the fieldname. But how can I do that? When I want to use scriptsteps like 'go to field' or 'set field' then I can only choose from my lists of variables, not make any calculation, right?

The fields that I want to fill like this are devided over several lay-outs, and within each layout one field per page. Therefore I think the 'portal solution' will not work with me.

Any suggestions? confused.gif

Posted

Hi Kwaska ...

Can you could provide a little more information about what's happening before you need to set the target field. For example, what determines which field will be the target? I assume that this is the result of a calculation. What exactly is returned by the calculation, and what are the rules for determining which field becomes the target of the SetField?

The Status(CurrentFieldName) function can be used in combination with the Go To Field script step and a global field, e.g., "g_targetField", to perform a SetField.. So, if your calculation returns a fieldname, it would go something like this:

Go to Record/Request/Page [ your desired record ]

Go to Layout [ your layout ]

# go to the first field on the layout

Go to Next Field

# set the global g_first_fieldname to the name of the first field. This will be used to exit the loop if your target field is not found

Set Field [ g_first_fieldname, Status(CurrentFieldName) ]

Set Field [ g_targetField, your calculation result ]

Loop

If [ Status(CurrentFieldName) = g_targetField ]

# if the current field is your target field, you don't need to specify a fieldname in the SetField step. You only need to specify the value to be put into the field.

Set Field [ your source value ]

Show Message [ Buttons:

Posted

Hi Jim,

Thanks for your reply. This is what I'm trying to do:

1. I have an MsExcel file with a couple of columns

2. In each columns are e.g. 50 values, which can look like this:

1

2

3

4

5

3

4

2

3

4

5

And so on.

3. I import this file into FM, and then calculate a frequency table. My final result looks something like this:

(5) 10%

(4) 60%

(3) 20%

(2) 10%

(1) 0%

This is what I've built sofar and it works fine. In order to do this, I've made a couple of scripts that covert the records into this frequencytable. The problem: I can use this script for only converting 1 column from excel to such a table. For each other column I use a copy of this script. So, in order to convert 72 columns, I need 72 script. For every change that I make, I have to change 72 scripts, which is not very attractive. That's why I'm looking for a 'dynamic field' solution.

Some background information: I work with FM 5.5 for OS X (mac). All the fields that I want to fill with a table are in the same lay-out. This means that when everything is converted, I end up with only one record.

Well, thanks again as I really think that your answer helps me solve the problem (it will take some time before I know).

Martin

Posted

Martin ...

OK. I still don't understand exactly what's going on in terms of the SetField process -- i.e., the specifics of the calculation that produces the field name. But, I'm glad I gave you some ideas to get you going. Let us know if you have any more questions.

Posted

Hi,

It would be good to know how you performed your import from Excel.

However, there are some rather "unknown" functions in FM that may also help you, even if I didn't clearly understood your goal.

The first is FieldName(DtatabaseName, LayoutName) that would give you a value list of all fields in a layout. When indexed, this calc could be used as any value list to determine which field is on a layout and therefore switch to another layout.

The second is LayoutNames(dtatabasename) which could also be used as a Value List.

Then, a loop GoToLayout involving a Text calculation on the LayoutNames() involving a counter, could help you switch layout quickly if the field currently isn't on the layout.

I'm not sure how to adress it but the GetField() could also be useful to retrieve the value of a field, involving this time the FieldName()...

HTH

Posted

Hi Ugo,

The import from excel is simple: use the FILE and then IMPORT RECORDS menu (my version is Dutch, so I hope these are the right names). This is however a bit simple, perhaps you mean something else?

This topic is 7779 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.