Skip to main content
13-Aquamarine
February 25, 2026
Solved

Function improvement

  • February 25, 2026
  • 1 reply
  • 104 views

The attached file has two functions.  The top function work but will not allow double quotes in the second column of a text file.  The second function works to do that, and it works well enough.  Was wondering if I could improve it with a TRY... ON ERROR addition?

 

 

Best answer by Werner_E

I don't see why the first function (where you only provide a picture) should not work the same way as the second one.

It looks to me that the "else if" statement in the second never is executed because an empty string (two quotes and nothing in between - I guess that's what you refer to as "double quote"?) does already trigger the if branch.

You would have to provide both functions as working Prime code (not pictures) and demo data for T and especially P which does not work with the first function but works OK with the second one.

From the file you provided it looks to me that both function create the very same file!

In case of an empty string ("") the functions create something which may look in some text editors like a space in quotes (" ") but actually in between the quotes there is a character with ASCII/ANSI code #0 (on contrary to a space which is code #32).

To create a true empty string (two double quotes and nothing in between) in the file you would have to use something like this

grafik.png

 

BTW, try...on error... just traps errors - do you experience any error when using the first version of your function?

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
February 25, 2026

I don't see why the first function (where you only provide a picture) should not work the same way as the second one.

It looks to me that the "else if" statement in the second never is executed because an empty string (two quotes and nothing in between - I guess that's what you refer to as "double quote"?) does already trigger the if branch.

You would have to provide both functions as working Prime code (not pictures) and demo data for T and especially P which does not work with the first function but works OK with the second one.

From the file you provided it looks to me that both function create the very same file!

In case of an empty string ("") the functions create something which may look in some text editors like a space in quotes (" ") but actually in between the quotes there is a character with ASCII/ANSI code #0 (on contrary to a space which is code #32).

To create a true empty string (two double quotes and nothing in between) in the file you would have to use something like this

grafik.png

 

BTW, try...on error... just traps errors - do you experience any error when using the first version of your function?

13-Aquamarine
February 25, 2026

Sorry.... Long day yesterday.  Attached are the real functions, not screen shots.

 

Looks like what you supplied will work better for my purposes.  

25-Diamond I
February 25, 2026

The demo data is missing (matrices T and especially P).

You write that the first functions does not what you want but the second does.

So I would need some data where the two function create different results!!

Because I still don't see why the second function should ever produce a different result than the first.

For the second function you write "It works fine" in bold letters, but as I see it both functions create a zero character in between quotes in case of and empty string. So if you are happy with that in the second function, why aren't you happy with the very same result created by the first one???