Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Fields from base_file with BLANKs - in brackets?


Hi,

in my underlying Excel_file there are fields with blanks in the field_name. Currently, for instance, there is "Betriebsstunden Dezember 2014" and "Betriebsstunden Januar 2015".

For various reasons, I load it all at first and use the Fieldname() function to find out the field_names. The names of these two fields appear in the Debugger in brackets as I would expect, as "[Betriebsstunden Dezember 2014]" and so on.

Now, however, I have the challenge that every month from now, one column will be added:

=> In March, there will be a third column "Betriebsstunden Februar 2015" and so forth.

I have copied the original file to test a loop parsing all fields to the right of the "current" one and find out if their names begin with "Betriebsstunden".

The issue is, in the Debugger, when I test this loop (and I have one column "Betriebsstunden Februar 2015", it appears without brackets and so, if I want it to become "BS_Feb_15", I have to cut off the last 2 numbers from the year.

<=> If that were to appear with brackets, that would be wrong, I would need to cut the first 2 of the last 3 in that case.

=> Can anyone help me there? Why does the field appear without brackets in the loop?

The essential bit of code is this:

>>  IF Subfield(Fieldname($(i), 'Staplerkosten_pre'), ' ', 1) = 'Betriebsstunden' THEN
         LET v_VarValue2 = 'BS_'& LEFT(SubField(Fieldname($(i), 'Staplerkosten_pre'), ' ', 2), 3) & '_' & RIGHT(SubField(Fieldname  ($(i), 'Staplerkosten_pre'), ' ', 3), 2);

<<

(of course this IF_THEN_loop is closed properly. The code works, I am just not sure if I should use the last 2 or 3 numbers from the fieldname)

Thanks a lot!

Best regards,

DataNibbler

2 Replies
datanibbler
Champion
Champion
Author

Hmm ... maybe I can use the Purgechar() option. That would make this question irrelevant.

Let's see if Purgechar() doesn't throw an error if the character to purge is not found ...

datanibbler
Champion
Champion
Author

Yep, that seems to work.