Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hi,

I am trying to establish some simple code using a text calculation.  The calc I have written goes like this :

"[" & #_security_name & "]¶" & 
"security_name = " & #_security_name & "¶" & 
"security_type = " & #_security_type & "¶" & 
"account = " & #_account & "¶" & 
"sar_timeframe = " & #_sar_timeframe & "¶" & 
"sar_timeframe_switch = " & "#_sar_timeframe_switch" & ¶ & 
"sar_periods = {""1m"": ""1D"", ""2m"": ""1D"", ""3m"": ""1D"", ""5m"": ""1D"", ""10m"": ""1D"", ""15m"": ""1D"", ""20m"": ""1D"", ""30m"": ""3D"", ""60m"": ""1D"", ""120m"": ""1D"", ""240m"": ""2D"", ""1D"": ""5D""}" & ¶ & 
"sar_incremental_step = " & #_sar_incremental_step & ¶ & 
"sar_max_step = " & #_sar_max_step & ¶ & 
"ma_timeframe = " & #_ma_timeframe & ¶ & 
"ma_slow = " = #_ma_slow & ¶ & 
"ma_fast = " = #_ma_fast & ¶ & 
"order_size = " & #_order_size & ¶ & 
"activate = " & #_activate_security_name

The result I am getting at present is just "0".  However if I just use the first ten lines i get :

Quote

[CWBR]

security_name = CWBR

security_type = STK

account = U#####

sar_timeframe = 1D

sar_timeframe_switch = #_sar_timeframe_switch

sar_periods = {"1m": "1D", "2m": "1D", "3m": "1D", "5m": "1D", "10m": "1D", "15m": "1D", "20m": "1D", "30m": "3D", "60m": "1D", "120m": "1D", "240m": "2D", "1D": "5D"}

sar_incremental_step = 0.02

sar_max_step = 0.2

ma_timeframe = 1D

which is exactly what I want.  Would anyone have any idea why the line 

"ma_slow = " = #_ma_slow & ¶ 

impedes the calc from functioning properly?

Sorry.  Just figured it out.  Line 10 should read

"ma_slow = " & #_ma_slow & ¶

and not

"ma_slow = " = #_ma_slow & ¶

 

My bad

 

Edited by dysong3

You can use  & ¶ & in all instances vs  & "¶" & as a single pilcrow will evaluate ( you have some with and without ) 

Or

start from line two and like 

"[" & #_security_name & "]" &  
"¶security_name = " & #_security_name &
"¶security_type = " & #_security_type &

Using the List() function could make this both easier and more readable, I think.

That is assuming it's worth doing at all. It seems like you're preparing a text file for export; if that's true, I'd suggest you look into exporting as XML and using an XSLT stylesheet to create a text file in the required format. 

i am not sure how this even evaluates with out escaping the quotes, unless you ignoring smart quotes? 

"sar_periods = {""1m"": ""1D"", ""2m"": ""1D"", ""3m"": ""1D"", ""5m"": ""1D"", ""10m"": ""1D"", ""15m"": ""1D"", ""20m"": ""1D"", ""30m"": ""3D"", ""60m"": ""1D"", ""120m"": ""1D"", ""240m"": ""2D"", ""1D"": ""5D""}" & ¶ &

another option would be:

InsertText ( to a variable ) script step as $template  (No need for quotes or & or ¶

[%A%]
security_name = %b%
security_type = %c%
account =  %d%
sar_timeframe = & %e%
sar_timeframe_switch = %f%
sar_periods = %g%
sar_incremental_step %h%
sar_max_step = %i%
ma_timeframe = %j%
ma_slow = %k%
ma_fast = %l%
order_size = %m%
activate =  %n%

Then substitute for each place holder. 

Substitute ( $template ; [ "%a% ; #_security_name ] ; [ "%b% ; #_security_name ] ; ..... ) 

9 minutes ago, Ocean West said:

i am not sure how this even evaluates with out escaping the quote

It's the legacy format of escaping quotes; "" is the same as \".

  • Author

Thank you for all this precious feedback.  Any hints on how to configure an XSLT stylesheet

There are quite a few examples posted here, mostly by Fenton and by me. To get you started, have a look at the attached demo:

XML demo.zip

Note that field names can be changed without breaking the export, but the field export order must be preserved.

 

 

Edited by comment

  • Author

Thanks once again. With your demo I was able to create a stylesheet that pretty much suits my purposes.  Just two more questions.

Ideally I'd like to have 4 global records serve as a header is the stylesheet. So that their info only appears once at the beginning of the output file.  Is there any way of doing that?

And how do you add paragraphs characters, say between the each records block of text?  

Edited by dysong3

3 hours ago, dysong3 said:

I'd like to have 4 global records serve as a header is the stylesheet.

I think you mean global fields? You would include them in the export (so that they would appear in every record) and use them outside the <xsl:for-each select="fmp:RESULTSET/fmp:ROW">...</xsl:for-each>  block.

To get the value of such field, use:

<xsl:value-of select="fmp:RESULTSET/fmp:ROW[1]/fmp:COL[x]/fmp:DATA"/>

where x is the number of the field in the field export order.

 

3 hours ago, dysong3 said:

And how do you add paragraphs characters

I have them in my stylesheet:

&#10; 

is a line feed character. If you need a carriage return, use:

&#13;

 

 

Edited by comment

  • Author

Yes of course, global fields.  Thanks once again.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.