Are there are any good solutions for comment alignment? - visual-studio-code

I like aligning the code like this
test.memberName = "dough"; // Name of the Member field.
test.age = 34; // Name of the Member field.
To this:
test.memberName = "dough"; // Name of the Member field.
test.age = 34; // Name of the Member field.
To tap my Tab key with Space. This is kind of sucks. Are there any plugins or tools for this pretty simple task?
I'm working in JetBrains IDEs and VSCode.

Related

Dynamic variable NAME creation in Flutter

I need to dynamically create a List variable depending on the situation.
I have a List of strings. These were created dynamically.
List Categories = [name: 'String 1', name: 'String 2', name: 'String 3']
I need to create a List variable dynamically that can hold EACH string. Don't ask me why, but trust me.
I need something like this:
for(int i = 0 ; i < Categories.length ; i ++)
{
// logic to create a variable of List type and even name it according to the value it is holding:
List String1Var = Categories.[i].name
// or even better :
List $Categories.[i].name = ....
}
so String1Var needs to be named as String1Var - i.e. the name itself has to be dynamic, and the contents too.
Is this possible in flutter?? Or have Google still yet to advance their language so it works for people like me?
Is that the right syntax? How do I dynamically create a variable name?
What you want can be done with the help of Map.
Instead of creating separate variables we are generating dynamic keys and storing the values in it, As Dart has no concept for dynamic variables.
Code:
final Map myCategoryDynamic = {};
for(int i = 0 ; i < Categories.length ; i ++)
{
// logic to create a variable of List type and even name it according to the value it is holding:
myCategoryDynamic['String'+i.toString()+'Var'] = Categories.[i].name;
}
So when we need to check the values - we can check by - myCategoryDynamic[String1Var] myCategoryDynamic[String2Var] and so on...

Using special characters as CASE keys in typoscript

I'm trying to send a mail via the powermail extension to different receivers, depending on the value a user has selected in a form dropdown. This practice of dynamic receivers is described in the powermail documentation. Basically:
receivers1.email = CASE
receivers1.email {
key.data = GP:tx_powermail_pi1|field|receiver
1 = TEXT
1.value = receivera#domain.org
default = TEXT
default.value = receiverb#domain.org
}
Now I'm facing the following problem: my values for "receiver" are not numeric (as in the example), but text values from a dropdown. Some of them contain spaces, some of them contain umlauts (öäüß). If I try to add …
Not wörking = TEXT
Not wörking.value = anotheremail#nowhere.org
Typo3 will complain and not update anything. (Bad property!
You must enter a property with characters a-z, A-Z and 0-9, no spaces!Nothing was updated!)
I tried simply 'escaping' the forbidden characters with a backslash, not working. Had an idea of converting the key.data via stdWrap rawUrlEncode, but did not work either. Google came up with this solution, but I don't understand what's going on and could not use it successfully.
How can I get around this? Thanks a lot for any kind of hint!
I pretty like your rawUrlEncode solution. Can you provide us your solution of it here? According to this online converter the result should be something like:
key.data = GP:tx_powermail_pi1|field|receiver
key.stdWrap.rawUrlEncode = 1
Not%20w%C3%B6rking = TEXT
Not%20w%C3%B6rking.value = anotheremail#nowhere.org
Maybe for each CASE some signs like "%" are not allowed. In that case you maybe refer to the "replacement" function. https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/Functions/Replacement/Index.html#replacement
key.data = GP:tx_powermail_pi1|field|receiver
key.stdWrap.replacement {
10 {
search.char = 32
replace = _
}
// Add umlauts and other signs!
}
Not_wörking = TEXT
Not_wörking.value = anotheremail#nowhere.org

Copy range with conditional formatting

I have a range with Conditional Formatting in an existing Excel file. I used EPPlus to copy that range to a new sheet, then I found the conditional formatting was missing.
Is there any way to copy range with conditional formatting using EPPlus?
I found a solution for this. I did not test it on all formattingRuleTypes. (Only needed 2 of them for the moment)
In my application i have 1 template row for each sheet.
var formatList = fromSheet.ConditionalFormatting.ToList();
foreach (var cf in formatList)
{
// sourceRow is the row containing the formatting
if (cf.Address.Start.Row == sourceRow )
{
IExcelConditionalFormattingRule rule = null;
switch (cf.Type)
{
case OfficeOpenXml.ConditionalFormatting.eExcelConditionalFormattingRuleType.GreaterThan:
rule = dest.ConditionalFormatting.AddGreaterThan();
break;
case OfficeOpenXml.ConditionalFormatting.eExcelConditionalFormattingRuleType.GreaterThanOrEqual:
rule = dest.ConditionalFormatting.AddGreaterThanOrEqual();
break;
case OfficeOpenXml.ConditionalFormatting.eExcelConditionalFormattingRuleType.LessThan:
rule = dest.ConditionalFormatting.AddLessThan();
break;
case OfficeOpenXml.ConditionalFormatting.eExcelConditionalFormattingRuleType.LessThanOrEqual:
rule = dest.ConditionalFormatting.AddLessThanOrEqual();
break;
default:
break;
}
rule.Style.Fill = cf.Style.Fill;
rule.Style.Border = cf.Style.Border;
rule.Style.Font = cf.Style.Font;
rule.Style.NumberFormat = cf.Style.NumberFormat;
// I have no clue why the Formula property is not included in the IExcelConditionalFormattingRule interface. So I needed to cast this.
((ExcelConditionalFormattingRule)rule).Formula = ((ExcelConditionalFormattingRule)cf).Formula;
((ExcelConditionalFormattingRule)rule).Formula2 = ((ExcelConditionalFormattingRule)cf).Formula2;
// Calculate the new address for the formatting. This will be different in your case
var adr = new ExcelAddress( dest.Start.Row , cf.Address.Start.Column -1 , dest.Start.Row, cf.Address.Start.Column -1 + cf.Address.Columns -1 );
rule.Address = adr;
I have no clue why the Formula property is not included in the IExcelConditionalFormattingRule interface. So I needed to cast this.
To add to the answer of Luc Wuyts (I can't comment yet due to limited reputation):
// I have no clue why the Formula property is not included in the IExcelConditionalFormattingRule interface. So I needed to cast this.
((ExcelConditionalFormattingRule)rule).Formula = ((ExcelConditionalFormattingRule)cf).Formula;
((ExcelConditionalFormattingRule)rule).Formula2 = ((ExcelConditionalFormattingRule)cf).Formula2;
Some conditional formatting do not have the Formula-options. This cast will work, but applying the Formula properties to conditional formatting options which do not require it will have unforeseen results. Eg. the ConditionalFormatting.AddContainsBlanks() does not require Formula properties, and adding them might mess up the conditional formatting. A better approach is to check the type, and add the formula's only when required.
I had a similar problem, the only way I found to inspect, change or delete a conditional format of a cell or range is looking at the openxml specs. The conditional format is stored in the worksheet, with the range under the attribute sqref. So you can edit that range or add a new.
For example:
DIM p As New ExcelPackage(New FileInfo(ExlReportPath), True)
Dim ws As ExcelWorksheet = p.Workbook.Worksheets(ExlSheetName)
'--Find Node "worksheet" (1 in my case) , Find all Child Nodes "conditionalFormatting" (5 to 11 in my test)
Print.Debug(ws.WorksheetXml.ChildNodes(1).ChildNodes(5).Name)
'--You get: conditionalFormatting
'--Now you can inspect the range:
Print.Debug(ws.WorksheetXml.ChildNodes(1).ChildNodes(5).Attributes("sqref").Value)
'--Will give you the cell address that this formatting applies to example: "D11:D15"
'--you can change delete or add new range if you want, below I add F11:F15
ws.WorksheetXml.ChildNodes(1).ChildNodes(5).Attributes("sqref").Value="D11:D15 F11:F15"
'--You can inspect the rule itself in the InnerXml also...
If you need more details of the markup, google Wouter van Vugt, "Open XML The markup explained". I found it useful and the full document was online (free).
If you find an easier way please post it.
Regards

Typoscript: Display register value as text

I'm using the extension seo_dynamic_tag, which is a fantastic plugin for TYPO3 SEO purposes.
It uses registers to store the generated meta description and keywords. Later on in the script, the page metadata is filled in from these registers:
page {
meta {
description {
field >
data = register:description
}
keywords {
field >
data = register:keywordss
}
}
1000 < temp.seo
}
So far it works like charm.
But in addition I'd like to display a TEXT object on the page with the meta description on the bottom. The text should read the meta description and some other stuff. That's where I need your help.
I tried to do the "magic" like this:
temp.description = COA
temp.description {
10 = TEXT
10.value = Meta description: {register:description}
stdWrap.insertData = 1
}
lib.footer < temp.description
This simply does not work. If I want to display something else, for example {page:title} or {date:y-m-d}, data insertion works. For register:xxx it doesn't.
I already spent lots of hours to google out my desired solution, but no success :(
Do you have any idea what I'm missing here?
I'm using TYPO3 4.5.3 (I know I should update ;)).
Many thanks in advance for your help! :)
Your stdWrap.insertData = 1 is applied to your COA-object, and not to your TEXT-object. You can instead set 10.insertData = 1 or just write the following:
10 = TEXT
10.data = register:description

Typo3 - Custom email newsletters with direct_mail

Im building a newsletter and the start is like this:
DEAR ###USER_gender### ###USER_first_name### ###USER_last_name###
which outpouts
DEAR ###USER_gender### JOHN DOE
and I was hoping it would replace the gender mark with "Miss" and "Sir", depending on the value. How could I do this?
Extra fields have to be added to the field list (see docu). But I'm not sure whether this automatically works with non-string fields. Maybe using a hook is your solution or using another extension which adds a new field to tt_address.
Another solution is to nest marker:
###GENDER_###USER_gender######
and then warp you content in a new template object:
10 = TEMPLATE
10 {
template < yourAlreadyProcessedContent
marks {
GENDER_m = TEXT
GENDER_m.value = Sir
}
}
It's a bit unusual, but sometimes it's very useful.
(Personally I use it to replace version numbers in tt_content records.)
Edit:
Example for Dbugger:
Download the Introduction Package and install it. After that add to the Welcome page a new template record with the following steup:
temp.mainTemplate = TEMPLATE
temp.mainTemplate {
template = TEXT
template.value = (
Foo
###CONTENT###
###CONTENT###
Bar
)
subparts {
CONTENT < styles.content.get
}
}
page = PAGE
page {
typeNum = 0
10 = TEMPLATE
10 {
template < temp.mainTemplate
marks {
TEST = TEXT
TEST.value = ok
}
}
Now include CSS Styled Contnet and enable the following options:
clear constants, clear setup, rootlevel
The output should look like that:
Foo
Congratulations ...
Bar
If you add ###TEST### to the the tt_content record on the welcome page it will be replaced with ok.
This should work with direct mail, too.
Edit:
I'm sorry, this only works which normal extension which are use in the rendering process.
a little bit late, but here's the best solution for the salutation in direct_mail & tt_address .. works perfect for me. The personalized marker is just ###USER_salutation###,
https://blog.webentwickler.at/individuelle-marker-in-direct-mail/