V18 and Write Pro Functions that insert HTML

I have been working with 4D write pro the last days. Mostly i am impressed how relatively easy it will be to handle and maintain large sets of documents that needs to be consistent and hard typed. I had to struggle the first days but then it all became clear to me how to handle Write Pro programing.

The one thing i have not found is a good approach how to handle is the issue of dynamic tables. I have an idea to insert an expression that returns a table inside the document. A table that can format outside of the expression. Much like the Process 4D tags. I have found a ways to inject HTML into a WP document but not really as a result of an expression. Am i missing something here?

As it is now i can see two solutions:

  • Use a “bookmark” or some other marker that a parser could fin and the execute WP code accoirdingly. #MyTable1 would trigger the opening code to replace that with method that actually creates a table in WP coding. Keeping the table “dynamic” in this solution would be a complete hardcoding exercise.
  • Some kind of function code that injects html coding with the risk of destroying the internal structure of the docoment.

Anyone. What is the best way to right now handle “dynamic” tables in a WP document?

Hello Johan,

Welcome to 4D Write Pro :slight_smile:

4D Write Pro is not an HTML editor, so everything you will do this way will seem a bit strange. But we understand your need.

There is a feature we’re working on (well, to be honest, we “plan” to work on) that may solve your problem. We would like to have your opinion about it.

Today, “expressions” (since V18 we use “formulas”) car return either raw text or pictures. And that’s it.
What if, in a future version, expressions could also return a full 4D Write Pro document ?
The expression (a 4D method) could create a new document (WP New), insert as many tables ( ) and rows ( ) in it then return it as an object ($0:=$doc)

If this is your need (and I think it is), then you can expect this feature during the life of V18, within one of the “Feaure Release” version.

Regards,
Roland Lannuzel

1 Like

Yes that approach would solve my problem and is more or less what i am looking for. Another way would be to have some kind of access to the “process 4d tags” engine. What we are trying to solve is a problem where we want to isolate data from the formatting/presentation of data. It is very similar to the approach of the process tags workflow. The important thing, as a developer, is that I want the user to be in control of the design layout but be able to deliver nice looking tables into the document. It all comes down to the handling of stylesheets and bookmarks.

what i did not think about is the possibility to send the entire document object to a ST INSERT EXPRESSION and let that function return a empty string and let the function call modify the document. Setting up a custom bookmark for the call so the function can recalculate and replace the full insertion with a recalculated version. Thinking about this there would be a great feature to be able to lock parts or bookmarks. I am really trying not to be that feature request guy, but you asked for it :grinning:.

Hello Johan,

As every result of expressions, the returned text / document will not be modifiable in any way (content nor formating).

Beside that, “locking” parts of the documents is another feature. And we’re also working on it :slight_smile:

Regards,

Roland Lannuzel