Jump to content

Better way to handle exceptions (if/then)


Sam W
 Share

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

Recommended Posts

Another part of my database is capturing the styles of each string of text. But each string can have several atributes: "bold, italic, underline, etc"

For now I have captured each into its own field in the table that holds each string as a record.

I have anticipated that if I get a multiple style, such as {bold, italic} that I can pull an "exception" from another table that would pair up with its font into the calculated formatted output.

If record 1 has "Courier" and "bold", "italic" I would want the font used to be "Courierbolditalic".

But I'm having trouble wrapping my head around how that would happen.

I had thought that I would combine the style fields and a Pattern Count function, but then I think I'm still building a complex if/then function for how many styles there are.

In my exceptions table, I have the correct font name for bold Courier, etc. and I expect to pull from that after matching on the original font in the text parts table.

I just need to pull the actual correct font, based on the styles each record comes across.

If {bold, italic} then "exceptions::font_boldital" but that doesn't sound right.

Does this make sense?

I cannot use FMPro's text formatting functions as I need text output as a string, eg: html

Link to comment
Share on other sites

What about use the GetAsCSS(text)function ?

For example, if fied1 contains:"something" and is formatted as bold+italic, that function will give you:

GetAsCSS(field1)

something

There is even another function:

GetAsSVG(field1)

and the result is:

something

Link to comment
Share on other sites

Thank you for considering this. This is intriguing, but the reason I wasn't using any of the formatting commands was because I have text strings.

However, I could regenerate with some formatting, but then I would have to run exceptions on each format change and I have to remap it to an actual font file.

I stil think that if I got Courier font-style"bold"; font-style "italic" I still have to run if/then to Courierbolditalic.

The remapping process is a key thing I'm stuck on, thanx, sam

Link to comment
Share on other sites

This is intriguing, but the reason I wasn't using any of the formatting commands was because I have text strings.

Those aren't formatting functions !

They only describe your's text strings formation.

I stil think that if I got Courier font-style"bold"; font-style "italic" I still have to run if/then to Courierbolditalic.

No if/then here, only text calculations !

Link to comment
Share on other sites

Yes, you are correct.

Aside from not knowing how formatted text gets imported into FM (I tried copying a formatted Word text block), I still have the problem of having the flags of {bold, italic, underline, etc} that will affect which font is called.

I guess I'll write a complex if/then to accommodate all the variations that can occur so they can pull the right font, but I was hoping to avoid that.

I'm sure I'm not explaining this coherently. Let me attempt again.

If style1 = bold, then pull in "CourierBold", if style 1=bold & style2 =italic, then pull in "CourierBoldItalic".

I appreciate your reading my query, thanx, sam

Link to comment
Share on other sites

Yes, you're right. I have made a much more slimmed down example of the core part. It's to make a text file that is a script so it's important that I open and close each text string correctly. Underline is not illustrated here as it's not as easy.

I guess the core thing is how do I take those style flags and pull in the correct font file without killing myself on the if/then statements. There are more styles than these three, such as "all caps" which is why I made an "exception" table.

I'm sure there is a better way to pull in the style tags, too, but that's what I came up with to pull in a list from Applescript.

I'm hoping someone can show me a better way, even with pulling in the style tags into a more friendly way for each record.

thanx, sam

componentslim.fp7.zip

Link to comment
Share on other sites

Yes, thank you for asking. The text component table is the recipient of an Applescript copy strings of text along with its attributes as you've seen.

I've got to create a script using a proprietary language that will recreate the printed page into a pdf. This is much preferable as I can create thousands of versions within seconds as opposed to any other database solution.

You're probably aware, but the actual name of the font file is typically used in print because it is not ambiguous. "CourierBoldItalic" as opposed to just styling the Bold button to Courier in Word for example.

But typically, you'll not be pure. My Quark docs will have the actual font selected, but there are some text strings that have the regular font selected, but also the Bold button.

I have to marry that into this script so that the actual font name is used.

It's not easy as a human usually does that because it takes a human to determine that Helvetica Neue Medium Condensed can be bolded or not. (it can't, but an app will happily let you try).

So the formatted string should have the font and other formatting things applied to it on a record basis.

I'd be happy to rethink the strategy, but the properly formatted script is the result. I'm grateful for the time you've spent contemplating my problem.

thanx, sam

Link to comment
Share on other sites

Thank you. I had not seen this file. I spent some time studying it trying to remap what I'm doing to it to see if it could work.

At first look, the Case function might be a step in the right direction. However, I want to study it some more so I don't make wrong assumptions and muck it up like I did sbg2's in the other thread.

thanx, sam

Link to comment
Share on other sites

This topic is 5755 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
 Share

×
×
  • Create New...

Important Information

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