问:
Unknown dots rendered into page - what causes them?
I have a demo application here and in the upper left corners of the "tweets" there are dots and I have no idea where they come from. The code is written in Ember and the template looks like this

```<code> <h2>Ember.js DEMO Tweet list</h2>

        <div class="tweets-list">
        <h2>Tweets</h2>
<button {{action 'changeAllTweets'}}>Change All Tweets</button>
<button {{action 'changeOneTweet'}}>Change One Tweet</button>
<div class="row input-wrap">
</div>
        {{#each this.model.topTweets as |model|}}
            <li class="media">
<div {{action 'bindNewModel' this}} class="row">
  <a class="pull-left" href="#"><img class="media-object" width="75" height="75" src={{model.avatar}}/></a>
  <div class="media-body">
  <h4 class="media-heading">{{model.favorites}}</h4>
  <p>{{model.text}}</p>
        </div>
</div>
<div class="row">
<div class="col-xs-4">
<a href="#">Expand</a>
        </div>
<div class="col-xs-8">
<ul class="list-inline text-right">
<li href="#">Reply</li>
<li href="#">Retweet</li>
<li href="#">Favorite</li>
<li href="#">More</li>
        </ul>
        </div>
        </div>

</li>
{{/each}}

                </div>
</code>```

P.S. The SHOW LIST button must be pressed for the list to show

答:
These are the list item markers. Add list-style:none; to the ul, and they will disappear.
Edit: I see that you are also missing the ul itself. The wrapping ul does not exist. These are just list items. Add the opening ul before the each statement and closing after it. And in case the list style none rule.
I'm on mobile and can't edit the fiddle.</p>

Body:
I have a demo application here and in the upper left corners of the "tweets" there are dots and I have no idea where they come from. The code is written in Ember and the template looks like this

Ember.js DEMO Tweet list

Tweets

<button {{action 'changeAllTweets'}}>Change All Tweets</button>
<button {{action 'changeOneTweet'}}>Change One Tweet</button>

        {{#each this.model.topTweets as |model|}}

{{model.favorites}}

{{model.text}}

Expand

Reply

Retweet

Favorite

More

{{/each}}

P.S. The SHOW LIST button must be pressed for the list to show


来源: stackexchange

问:
Create a Custom Tab
When I start a new Excel Web Add-in, by default the blank project has a MyAppName.xml file that declares the ribbon.
The declaration sets a custom group and a custom control under the native Home Excel tab.

What I want is to create a separate tab for my Addin.
In the file project itself, there are these code lines:

```<code><!-- Use OfficeTab to extend an existing Tab. Use CustomTab to create a new tab. -->
<OfficeTab id="TabHome">
</code>```

So I changed OfficeTab for CustomTab, but now I get the message in the error list:

```<code>The element 'CustomTab' in namespace 'http://schemas.microsoft.com/office/taskpaneappversionoverrides' has incomplete content. List of possible elements expected: 'Group, Label' in namespace 'http://schemas.microsoft.com/office/taskpaneappversionoverrides'.
</code>```

Do you know how I can create a custom tab? What am I doing wrong?

I'm using:
Microsoft Visual Studio Enterprise 2017
Version 15.2 (26430.12) Release
VisualStudio.15.Release/15.2.0+26430.12

Thanks.

答:
Below is an example manifest that uses CustomTab. Can you compare your's with the example and see what might be different? Are you giving the CustomTab a unique ID? Does it have Group and Label child elements?

```<code><?xml version="1.0" encoding="utf-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">

<!-- See https://github.com/OfficeDev/Office-Add-in-Commands-Samples for documentation-->

<!-- BeginBasicSettings: Add-in metadata, used for all versions of Office unless override provided -->

<!--IMPORTANT! Id must be unique for your add-in. If you copy this manifest ensure that you change this id to your own GUID. -->
<Id>e504fb41-a92a-4526-b101-542f357b7acb</Id>
<Version>1.0.0.0</Version>
<ProviderName>Contoso</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various placed of the Office UI such as the add-ins dialog -->
<DisplayName DefaultValue="Add-in Commands Sample" />
<Description DefaultValue="Sample that illustrates add-in commands basic control types and actions" />
<!--Icon for your add-in. Used on installation screens and the add-ins dialog -->
<IconUrl DefaultValue="https://contoso.com/assets/icon-32.png" />
<HighResolutionIconUrl DefaultValue="https://contoso.com/assets/hi-res-icon.png" />
<SupportUrl DefaultValue="[Insert the URL of a page that provides support information for the app]" />
<!--BeginTaskpaneMode integration. Office 2013 and any client that doesn't understand commands will use this section.
  This section will also be used if there are no VersionOverrides -->
<Hosts>
  <Host Name="Document"/>
</Hosts>
<DefaultSettings>
  <SourceLocation DefaultValue="https://commandsimple.azurewebsites.net/Taskpane.html" />
</DefaultSettings>
<!--EndTaskpaneMode integration -->

<Permissions>ReadWriteDocument</Permissions>

<!--BeginAddinCommandsMode integration-->
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
  <Hosts>
    <!--Each host can have a different set of commands. Cool huh!? -->
    <!-- Workbook=Excel Document=Word Presentation=PowerPoint -->
    <!-- Make sure the hosts you override match the hosts declared in the top section of the manifest -->
    <Host xsi:type="Document">
      <!-- Form factor. Currently only DesktopFormFactor is supported. We will add TabletFormFactor and PhoneFormFactor in the future-->
      <DesktopFormFactor>
        <!--Function file is an html page that includes the javascript where functions for ExecuteAction will be called.
        Think of the FunctionFile as the "code behind" ExecuteFunction-->
        <FunctionFile resid="Contoso.FunctionFile.Url" />

        <!--PrimaryCommandSurface==Main Office app ribbon-->
        <ExtensionPoint xsi:type="PrimaryCommandSurface">
          <!--Use OfficeTab to extend an existing Tab. Use CustomTab to create a new tab -->
          <!-- Documentation includes all the IDs currently tested to work -->
          <CustomTab id="Contoso.Tab1">
            <!--Group ID-->
            <Group id="Contoso.Tab1.Group1">
              <!--Label for your group. resid must point to a ShortString resource -->
              <Label resid="Contoso.Tab1.GroupLabel" />
              <Icon>
              <!-- Sample Todo: Each size needs its own icon resource or it will look distorted when resized -->
                <!--Icons. Required sizes: 16, 32, 80; optional: 20, 24, 40, 48, 64. You should provide as many sizes as possible for a great user experience. -->
                <!--Use PNG icons and remember that all URLs on the resources section must use HTTPS -->
                <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
              </Icon>

              <!--Control. It can be of type "Button" or "Menu" -->
              <Control xsi:type="Button" id="Contoso.FunctionButton">
                <!--Label for your button. resid must point to a ShortString resource -->
                <Label resid="Contoso.FunctionButton.Label" />
                <Supertip>
                  <!--ToolTip title. resid must point to a ShortString resource -->
                  <Title resid="Contoso.FunctionButton.Label" />
                  <!--ToolTip description. resid must point to a LongString resource -->
                  <Description resid="Contoso.FunctionButton.Tooltip" />
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="Contoso.FunctionButton.Icon16" />
                  <bt:Image size="32" resid="Contoso.FunctionButton.Icon32" />
                  <bt:Image size="80" resid="Contoso.FunctionButton.Icon80" />
                </Icon>
                <!--This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane-->
                <!--Look at the FunctionFile.html page for reference on how to implement the function -->
                <Action xsi:type="ExecuteFunction">
                  <!--Name of the function to call. This function needs to exist in the global DOM namespace of the function file-->
                  <FunctionName>writeText</FunctionName>
                </Action>
              </Control>

              <Control xsi:type="Button" id="Contoso.TaskpaneButton">
                <Label resid="Contoso.TaskpaneButton.Label" />
                <Supertip>
                  <Title resid="Contoso.TaskpaneButton.Label" />
                  <Description resid="Contoso.TaskpaneButton.Tooltip" />
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                  <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                  <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
                </Icon>
                <Action xsi:type="ShowTaskpane">
                  <TaskpaneId>Button2Id1</TaskpaneId>
                  <!--Provide a url resource id for the location that will be displayed on the task pane -->
                  <SourceLocation resid="Contoso.Taskpane1.Url" />
                </Action>
              </Control>
              <!-- Menu example -->
              <Control xsi:type="Menu" id="Contoso.Menu">
                <Label resid="Contoso.Dropdown.Label" />
                <Supertip>
                  <Title resid="Contoso.Dropdown.Label" />
                  <Description resid="Contoso.Dropdown.Tooltip" />
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                  <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                  <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
                </Icon>
                <Items>
                  <Item id="Contoso.Menu.Item1">
                    <Label resid="Contoso.Item1.Label"/>
                    <Supertip>
                      <Title resid="Contoso.Item1.Label" />
                      <Description resid="Contoso.Item1.Tooltip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                      <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                      <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <TaskpaneId>MyTaskPaneID1</TaskpaneId>
                      <SourceLocation resid="Contoso.Taskpane1.Url" />
                    </Action>
                  </Item>

                  <Item id="Contoso.Menu.Item2">
                    <Label resid="Contoso.Item2.Label"/>
                    <Supertip>
                      <Title resid="Contoso.Item2.Label" />
                      <Description resid="Contoso.Item2.Tooltip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                      <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                      <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <TaskpaneId>MyTaskPaneID2</TaskpaneId>
                      <SourceLocation resid="Contoso.Taskpane2.Url" />
                    </Action>
                  </Item>

                </Items>
              </Control>

            </Group>

            <!-- Label of your tab -->
            <!-- If validating with XSD it needs to be at the end -->
            <Label resid="Contoso.Tab1.TabLabel" />
          </CustomTab>
        </ExtensionPoint>
      </DesktopFormFactor>
    </Host>
  </Hosts>
  <Resources>
    <bt:Images>
      <bt:Image id="Contoso.TaskpaneButton.Icon16" DefaultValue="https://myCDN/Images/Button16x16.png" />
      <bt:Image id="Contoso.TaskpaneButton.Icon32" DefaultValue="https://myCDN/Images/Button32x32.png" />
      <bt:Image id="Contoso.TaskpaneButton.Icon80" DefaultValue="https://myCDN/Images/Button80x80.png" />
      <bt:Image id="Contoso.FunctionButton.Icon" DefaultValue="https://myCDN/Images/ButtonFunction.png" />
    </bt:Images>
    <bt:Urls>
      <bt:Url id="Contoso.FunctionFile.Url" DefaultValue="https://commandsimple.azurewebsites.net/FunctionFile.html" />
      <bt:Url id="Contoso.Taskpane1.Url" DefaultValue="https://commandsimple.azurewebsites.net/Taskpane.html" />
      <bt:Url id="Contoso.Taskpane2.Url" DefaultValue="https://commandsimple.azurewebsites.net/Taskpane2.html" />
    </bt:Urls>
    <bt:ShortStrings>
      <bt:String id="Contoso.FunctionButton.Label" DefaultValue="Execute Function" />
      <bt:String id="Contoso.TaskpaneButton.Label" DefaultValue="Show Taskpane" />
      <bt:String id="Contoso.Dropdown.Label" DefaultValue="Dropdown" />
      <bt:String id="Contoso.Item1.Label" DefaultValue="Show Taskpane 1" />
      <bt:String id="Contoso.Item2.Label" DefaultValue="Show Taskpane 2" />
      <bt:String id="Contoso.Tab1.GroupLabel" DefaultValue="Test Group" />
       <bt:String id="Contoso.Tab1.TabLabel" DefaultValue="Test Tab" />
    </bt:ShortStrings>
    <bt:LongStrings>
      <bt:String id="Contoso.FunctionButton.Tooltip" DefaultValue="Click to Execute Function" />
      <bt:String id="Contoso.TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane" />
      <bt:String id="Contoso.Dropdown.Tooltip" DefaultValue="Click to Show Options on this Menu" />
      <bt:String id="Contoso.Item1.Tooltip" DefaultValue="Click to Show Taskpane1" />
      <bt:String id="Contoso.Item2.Tooltip" DefaultValue="Click to Show Taskpane2" />
    </bt:LongStrings>
  </Resources>
</VersionOverrides>
</OfficeApp>
</code>```

See also this article and the samples it links to. And check out Validate and Troubleshoot your Manifest too.

ContentLicense: CC BY-SA 3.0

Title: Create a Custom Tab

Body:
When I start a new Excel Web Add-in, by default the blank project has a MyAppName.xml file that declares the ribbon.
The declaration sets a custom group and a custom control under the native Home Excel tab.

What I want is to create a separate tab for my Addin.
In the file project itself, there are these code lines:

<OfficeTab id="TabHome">

So I changed OfficeTab for CustomTab, but now I get the message in the error list:

The element 'CustomTab' in namespace 'http://schemas.microsoft.com/office/taskpaneappversionoverrides' has incomplete content. List of possible elements expected: 'Group, Label' in namespace 'http://schemas.microsoft.com/office/taskpaneappversionoverrides'.

Do you know how I can create a custom tab? What am I doing wrong?

I'm using:
Microsoft Visual Studio Enterprise 2017
Version 15.2 (26430.12) Release
VisualStudio.15.Release/15.2.0+26430.12

Thanks.

Body:
Below is an example manifest that uses CustomTab. Can you compare your's with the example and see what might be different? Are you giving the CustomTab a unique ID? Does it have Group and Label child elements?

<?xml version="1.0" encoding="utf-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">

<!-- See https://github.com/OfficeDev/Office-Add-in-Commands-Samples for documentation-->

<!-- BeginBasicSettings: Add-in metadata, used for all versions of Office unless override provided -->

<!--IMPORTANT! Id must be unique for your add-in. If you copy this manifest ensure that you change this id to your own GUID. -->
<Id>e504fb41-a92a-4526-b101-542f357b7acb</Id>
<Version>1.0.0.0</Version>
<ProviderName>Contoso</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various placed of the Office UI such as the add-ins dialog -->
<DisplayName DefaultValue="Add-in Commands Sample" />
<Description DefaultValue="Sample that illustrates add-in commands basic control types and actions" />
<!--Icon for your add-in. Used on installation screens and the add-ins dialog -->
<IconUrl DefaultValue="https://contoso.com/assets/icon-32.png" />
<HighResolutionIconUrl DefaultValue="https://contoso.com/assets/hi-res-icon.png" />
<SupportUrl DefaultValue="[Insert the URL of a page that provides support information for the app]" />
<!--BeginTaskpaneMode integration. Office 2013 and any client that doesn't understand commands will use this section.
  This section will also be used if there are no VersionOverrides -->
<Hosts>
  <Host Name="Document"/>
</Hosts>
<DefaultSettings>
  <SourceLocation DefaultValue="https://commandsimple.azurewebsites.net/Taskpane.html" />
</DefaultSettings>
<!--EndTaskpaneMode integration -->

<Permissions>ReadWriteDocument</Permissions>

<!--BeginAddinCommandsMode integration-->
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
  <Hosts>
    <!--Each host can have a different set of commands. Cool huh!? -->
    <!-- Workbook=Excel Document=Word Presentation=PowerPoint -->
    <!-- Make sure the hosts you override match the hosts declared in the top section of the manifest -->
    <Host xsi:type="Document">
      <!-- Form factor. Currently only DesktopFormFactor is supported. We will add TabletFormFactor and PhoneFormFactor in the future-->
      <DesktopFormFactor>
        <!--Function file is an html page that includes the javascript where functions for ExecuteAction will be called.
        Think of the FunctionFile as the "code behind" ExecuteFunction-->
        <FunctionFile resid="Contoso.FunctionFile.Url" />

        <!--PrimaryCommandSurface==Main Office app ribbon-->
        <ExtensionPoint xsi:type="PrimaryCommandSurface">
          <!--Use OfficeTab to extend an existing Tab. Use CustomTab to create a new tab -->
          <!-- Documentation includes all the IDs currently tested to work -->
          <CustomTab id="Contoso.Tab1">
            <!--Group ID-->
            <Group id="Contoso.Tab1.Group1">
              <!--Label for your group. resid must point to a ShortString resource -->
              <Label resid="Contoso.Tab1.GroupLabel" />
              <Icon>
              <!-- Sample Todo: Each size needs its own icon resource or it will look distorted when resized -->
                <!--Icons. Required sizes: 16, 32, 80; optional: 20, 24, 40, 48, 64. You should provide as many sizes as possible for a great user experience. -->
                <!--Use PNG icons and remember that all URLs on the resources section must use HTTPS -->
                <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
              </Icon>

              <!--Control. It can be of type "Button" or "Menu" -->
              <Control xsi:type="Button" id="Contoso.FunctionButton">
                <!--Label for your button. resid must point to a ShortString resource -->
                <Label resid="Contoso.FunctionButton.Label" />
                <Supertip>
                  <!--ToolTip title. resid must point to a ShortString resource -->
                  <Title resid="Contoso.FunctionButton.Label" />
                  <!--ToolTip description. resid must point to a LongString resource -->
                  <Description resid="Contoso.FunctionButton.Tooltip" />
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="Contoso.FunctionButton.Icon16" />
                  <bt:Image size="32" resid="Contoso.FunctionButton.Icon32" />
                  <bt:Image size="80" resid="Contoso.FunctionButton.Icon80" />
                </Icon>
                <!--This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane-->
                <!--Look at the FunctionFile.html page for reference on how to implement the function -->
                <Action xsi:type="ExecuteFunction">
                  <!--Name of the function to call. This function needs to exist in the global DOM namespace of the function file-->
                  <FunctionName>writeText</FunctionName>
                </Action>
              </Control>

              <Control xsi:type="Button" id="Contoso.TaskpaneButton">
                <Label resid="Contoso.TaskpaneButton.Label" />
                <Supertip>
                  <Title resid="Contoso.TaskpaneButton.Label" />
                  <Description resid="Contoso.TaskpaneButton.Tooltip" />
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                  <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                  <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
                </Icon>
                <Action xsi:type="ShowTaskpane">
                  <TaskpaneId>Button2Id1</TaskpaneId>
                  <!--Provide a url resource id for the location that will be displayed on the task pane -->
                  <SourceLocation resid="Contoso.Taskpane1.Url" />
                </Action>
              </Control>
              <!-- Menu example -->
              <Control xsi:type="Menu" id="Contoso.Menu">
                <Label resid="Contoso.Dropdown.Label" />
                <Supertip>
                  <Title resid="Contoso.Dropdown.Label" />
                  <Description resid="Contoso.Dropdown.Tooltip" />
                </Supertip>
                <Icon>
                  <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                  <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                  <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
                </Icon>
                <Items>
                  <Item id="Contoso.Menu.Item1">
                    <Label resid="Contoso.Item1.Label"/>
                    <Supertip>
                      <Title resid="Contoso.Item1.Label" />
                      <Description resid="Contoso.Item1.Tooltip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                      <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                      <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <TaskpaneId>MyTaskPaneID1</TaskpaneId>
                      <SourceLocation resid="Contoso.Taskpane1.Url" />
                    </Action>
                  </Item>

                  <Item id="Contoso.Menu.Item2">
                    <Label resid="Contoso.Item2.Label"/>
                    <Supertip>
                      <Title resid="Contoso.Item2.Label" />
                      <Description resid="Contoso.Item2.Tooltip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Contoso.TaskpaneButton.Icon16" />
                      <bt:Image size="32" resid="Contoso.TaskpaneButton.Icon32" />
                      <bt:Image size="80" resid="Contoso.TaskpaneButton.Icon80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <TaskpaneId>MyTaskPaneID2</TaskpaneId>
                      <SourceLocation resid="Contoso.Taskpane2.Url" />
                    </Action>
                  </Item>

                </Items>
              </Control>

            </Group>

            <!-- Label of your tab -->
            <!-- If validating with XSD it needs to be at the end -->
            <Label resid="Contoso.Tab1.TabLabel" />
          </CustomTab>
        </ExtensionPoint>
      </DesktopFormFactor>
    </Host>
  </Hosts>
  <Resources>
    <bt:Images>
      <bt:Image id="Contoso.TaskpaneButton.Icon16" DefaultValue="https://myCDN/Images/Button16x16.png" />
      <bt:Image id="Contoso.TaskpaneButton.Icon32" DefaultValue="https://myCDN/Images/Button32x32.png" />
      <bt:Image id="Contoso.TaskpaneButton.Icon80" DefaultValue="https://myCDN/Images/Button80x80.png" />
      <bt:Image id="Contoso.FunctionButton.Icon" DefaultValue="https://myCDN/Images/ButtonFunction.png" />
    </bt:Images>
    <bt:Urls>
      <bt:Url id="Contoso.FunctionFile.Url" DefaultValue="https://commandsimple.azurewebsites.net/FunctionFile.html" />
      <bt:Url id="Contoso.Taskpane1.Url" DefaultValue="https://commandsimple.azurewebsites.net/Taskpane.html" />
      <bt:Url id="Contoso.Taskpane2.Url" DefaultValue="https://commandsimple.azurewebsites.net/Taskpane2.html" />
    </bt:Urls>
    <bt:ShortStrings>
      <bt:String id="Contoso.FunctionButton.Label" DefaultValue="Execute Function" />
      <bt:String id="Contoso.TaskpaneButton.Label" DefaultValue="Show Taskpane" />
      <bt:String id="Contoso.Dropdown.Label" DefaultValue="Dropdown" />
      <bt:String id="Contoso.Item1.Label" DefaultValue="Show Taskpane 1" />
      <bt:String id="Contoso.Item2.Label" DefaultValue="Show Taskpane 2" />
      <bt:String id="Contoso.Tab1.GroupLabel" DefaultValue="Test Group" />
       <bt:String id="Contoso.Tab1.TabLabel" DefaultValue="Test Tab" />
    </bt:ShortStrings>
    <bt:LongStrings>
      <bt:String id="Contoso.FunctionButton.Tooltip" DefaultValue="Click to Execute Function" />
      <bt:String id="Contoso.TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane" />
      <bt:String id="Contoso.Dropdown.Tooltip" DefaultValue="Click to Show Options on this Menu" />
      <bt:String id="Contoso.Item1.Tooltip" DefaultValue="Click to Show Taskpane1" />
      <bt:String id="Contoso.Item2.Tooltip" DefaultValue="Click to Show Taskpane2" />
    </bt:LongStrings>
  </Resources>
</VersionOverrides>
</OfficeApp>

See also this article and the samples it links to. And check out Validate and Troubleshoot your Manifest too.

ContentLicense: CC BY-SA 4.0


问:
Displaying Decimal Points In C++, Problems with Calculations
I'm taking a C++ online class (probably a mistake) and I'm trying to figure out how to correct this code. I had to write a program from scratch and I'm totally stumped as to what I'm doing incorrectly.

This is what should come out:

Blockquote  Welcome to name’s carpet calculator!

Enter the name of the room to be carpeted:  bedroom

Enter the length of the room in feet: 10

Enter the width of the room in feet: 10

Enter the price of the carpet per yard: 3.49

Enter the padding cost: 35

```<code>                                         Carpet estimate for bedroom
</code>```

Total square feet of the room: 100

Total square yards of the room: 12

Total cost of the carpet needed:          41.88

Total cost of labor (at $6.03/yd):        72.36

Padding Cost:                                       35.00

Subtotal:                                             149.24

Tax:                                                        8.50

Total:                                                   157.74

Blockquote

Some additional rules are: Square yardage for a room is calculated by dividing the total square feet by 9. Add 1 yard for any fractional differences.
The labor cost of installing the carpet is $6.03/yard
Tax rate is currently 5.7%

Here's my current code:

```<code>    // John Mayer Learning Unit 2 Assessment

#include <iostream>
using namespace std;

int main()
{
    string roomName; // declarations
    int roomLength;
    int roomWidth;
    int squareFeet;
    int carpetPrice;
    int paddingCost;
    int totalCarpetCost;
    const int TAX_RATE = .057;
    int laborCost;
    const int LABOR_RATE = 6.03;
    int squareYard;
    int subtotal;
    int taxCost;
    int totalCost;

    cout << "Welcome to John Mayer's Carpet Calculator!"; // displays this at the top
    cout << "\n\n What is the name of the room to be carpeted?"; // asks for the room name
    cin >> roomName; // stores the room name
    cout << "\n What is the length of the room (in feet)?"; // asks for the length
    cin >> roomLength; // stores the length
    cout << "\n What is the width of the room (in feet)?"; // asks for the width
    cin >> roomWidth; // stores the width
    cout << "\n What is the price of the carpet per yard?"; // asks for the price of the carpet
    cin >> carpetPrice; // stores the price
    cout << "\n What is the padding cost?"; // asks for the padding cost
    cin >> paddingCost; // stores the padding cost **DOES NOT WORK**

    squareFeet = roomLength * roomWidth; // finds square feet by multiplying length and width
    squareYard = (squareFeet / 9) + 1; // finds the square feet and rounds up to the next yard
    totalCarpetCost = carpetPrice * squareYard; // finds the carpet cost by multiplying the input carpet price by the square yardage
    laborCost = squareYard * LABOR_RATE; // finds the labor cost by multiplying the yardage by the labor rate of 6.03
    subtotal = (totalCarpetCost + paddingCost + laborCost); // finds the subtotal by adding the labor cost, carpet cost, and padding cost
    taxCost = subtotal * TAX_RATE; // finds the tax cost by multiplying the subtotal by the tax rate of .057 (5.7%)
    totalCost = taxCost + subtotal; // adds the subtotal and tax to find the total overall cost

    cout << "\n Carpet estimate for " << roomName; // displays text and the room name

    cout << "\n Total square feet of the room: " << squareFeet; //displays the square feet calculation **CORRECT
    cout << "\n Total square yards of the room: " << squareYard; // displays the square yards calculation **CORRECT
    cout << "\n\n Total cost of the carpet needed: " << totalCarpetCost; // displays the carpet cost **INCORRECT
    cout << "\n Total cost of labor (at $6.03/yd): " << laborCost; // displays the labor cost
    cout << "\n Padding Cost: " << paddingCost; // displays the padding cost
    cout << "\n\n Subtotal: " << subtotal; // displays the subtotal
    cout << "\n Tax: " << taxCost; // displays the tax calculation
    cout << "\n Total: " << totalCost;  // displays the final total cost
    cout << "\n"; // line break

    system("PAUSE");
  return 0;

}
</code>```

答:
If you are using decimals then you need to use double instead of int. A double is a floating point type. An int (integer) is a whole number and a number that is not a fraction. Therefore, using int for decimal won't work

```<code>int a = 1.22;
cout << a << endl;
//this will display 1
double b = 1.22;
cout << b << endl;
//this will display 1.22
</code>```

because your compiler will use the whole number in front of the decimal not anything after it.

Body:
I'm taking a C++ online class (probably a mistake) and I'm trying to figure out how to correct this code. I had to write a program from scratch and I'm totally stumped as to what I'm doing incorrectly.

This is what should come out:

Blockquote  Welcome to name’s carpet calculator!

Enter the name of the room to be carpeted:  bedroom

Enter the length of the room in feet: 10

Enter the width of the room in feet: 10

Enter the price of the carpet per yard: 3.49

Enter the padding cost: 35

                                         Carpet estimate for bedroom

Total square feet of the room: 100

Total square yards of the room: 12

Total cost of the carpet needed:          41.88

Total cost of labor (at $6.03/yd):        72.36

Padding Cost:                                       35.00

Subtotal:                                             149.24

Tax:                                                        8.50

Total:                                                   157.74

Blockquote

Some additional rules are: Square yardage for a room is calculated by dividing the total square feet by 9. Add 1 yard for any fractional differences.
The labor cost of installing the carpet is $6.03/yard
Tax rate is currently 5.7%

Here's my current code:

    // John Mayer Learning Unit 2 Assessment

#include <iostream>
using namespace std;

int main()
{
    string roomName; // declarations
    int roomLength;
    int roomWidth;
    int squareFeet;
    int carpetPrice;
    int paddingCost;
    int totalCarpetCost;
    const int TAX_RATE = .057;
    int laborCost;
    const int LABOR_RATE = 6.03;
    int squareYard;
    int subtotal;
    int taxCost;
    int totalCost;

    cout << "Welcome to John Mayer's Carpet Calculator!"; // displays this at the top
    cout << "\n\n What is the name of the room to be carpeted?"; // asks for the room name
    cin >> roomName; // stores the room name
    cout << "\n What is the length of the room (in feet)?"; // asks for the length
    cin >> roomLength; // stores the length
    cout << "\n What is the width of the room (in feet)?"; // asks for the width
    cin >> roomWidth; // stores the width
    cout << "\n What is the price of the carpet per yard?"; // asks for the price of the carpet
    cin >> carpetPrice; // stores the price
    cout << "\n What is the padding cost?"; // asks for the padding cost
    cin >> paddingCost; // stores the padding cost **DOES NOT WORK**

    squareFeet = roomLength * roomWidth; // finds square feet by multiplying length and width
    squareYard = (squareFeet / 9) + 1; // finds the square feet and rounds up to the next yard
    totalCarpetCost = carpetPrice * squareYard; // finds the carpet cost by multiplying the input carpet price by the square yardage
    laborCost = squareYard * LABOR_RATE; // finds the labor cost by multiplying the yardage by the labor rate of 6.03
    subtotal = (totalCarpetCost + paddingCost + laborCost); // finds the subtotal by adding the labor cost, carpet cost, and padding cost
    taxCost = subtotal * TAX_RATE; // finds the tax cost by multiplying the subtotal by the tax rate of .057 (5.7%)
    totalCost = taxCost + subtotal; // adds the subtotal and tax to find the total overall cost

    cout << "\n Carpet estimate for " << roomName; // displays text and the room name

    cout << "\n Total square feet of the room: " << squareFeet; //displays the square feet calculation **CORRECT
    cout << "\n Total square yards of the room: " << squareYard; // displays the square yards calculation **CORRECT
    cout << "\n\n Total cost of the carpet needed: " << totalCarpetCost; // displays the carpet cost **INCORRECT
    cout << "\n Total cost of labor (at $6.03/yd): " << laborCost; // displays the labor cost
    cout << "\n Padding Cost: " << paddingCost; // displays the padding cost
    cout << "\n\n Subtotal: " << subtotal; // displays the subtotal
    cout << "\n Tax: " << taxCost; // displays the tax calculation
    cout << "\n Total: " << totalCost;  // displays the final total cost
    cout << "\n"; // line break

    system("PAUSE");
  return 0;

}

Body:
If you are using decimals then you need to use double instead of int. A double is a floating point type. An int (integer) is a whole number and a number that is not a fraction. Therefore, using int for decimal won't work

int a = 1.22;
cout << a << endl;
//this will display 1
double b = 1.22;
cout << b << endl;
//this will display 1.22

because your compiler will use the whole number in front of the decimal not anything after it.


问:
SQL error: 1170
I am getting the following error when running the below code...what is wrong with it?

Error Code:1170. BLOB/TEXT column 'message" used in key specification without a key length.

```<code>-- MySQL Script generated by MySQL Workbench
-- Sun Jun  4 21:25:42 2017
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

    SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
    CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
    USE `mydb` ;

-- -----------------------------------------------------
-- Table `mydb`.`users`
-- -----------------------------------------------------
    CREATE TABLE IF NOT EXISTS `mydb`.`users` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `first_name` VARCHAR(255) NOT NULL,
      `last_name` VARCHAR(255) NOT NULL,
      `email` VARCHAR(255) NOT NULL,
      `password` VARCHAR(255) NOT NULL,
      `created_at` DATETIME NOT NULL,
      `updates_at` DATETIME NOT NULL,
      PRIMARY KEY (`id`),
      UNIQUE INDEX `first_name_UNIQUE` (`first_name` ASC),
      UNIQUE INDEX `last_name_UNIQUE` (`last_name` ASC),
      UNIQUE INDEX `email_UNIQUE` (`email` ASC),
      UNIQUE INDEX `password_UNIQUE` (`password` ASC),
      UNIQUE INDEX `created_at_UNIQUE` (`created_at` ASC),
      UNIQUE INDEX `updates_at_UNIQUE` (`updates_at` ASC))
      ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `mydb`.`messages`
-- -----------------------------------------------------
    CREATE TABLE IF NOT EXISTS `mydb`.`messages` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `users_id` INT NOT NULL,
      `message` TEXT NOT NULL,
      `created_at` DATETIME NOT NULL,
      `updated_at` DATETIME NOT NULL,
      PRIMARY KEY (`id`),
      INDEX `fk_messages_users_idx` (`users_id` ASC),
      UNIQUE INDEX `id_UNIQUE` (`id` ASC),
      UNIQUE INDEX `users_id_UNIQUE` (`users_id` ASC),
      UNIQUE INDEX `message_UNIQUE` (`message` ASC),
      UNIQUE INDEX `created_at_UNIQUE` (`created_at` ASC),
      UNIQUE INDEX `updated_at_UNIQUE` (`updated_at` ASC),
      CONSTRAINT `fk_messages_users`
        FOREIGN KEY (`users_id`)
        REFERENCES `mydb`.`users` (`id`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION)
      ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `mydb`.`comments`
-- -----------------------------------------------------
    CREATE TABLE IF NOT EXISTS `mydb`.`comments` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `users_id` INT NOT NULL,
      `messages_id` INT NOT NULL,
      `comment` TEXT NOT NULL,
      `created_at` DATETIME NOT NULL,
      `updated_at` DATETIME NOT NULL,
      PRIMARY KEY (`id`),
      INDEX `fk_comments_users1_idx` (`users_id` ASC),
      INDEX `fk_comments_messages1_idx` (`messages_id` ASC),
      UNIQUE INDEX `id_UNIQUE` (`id` ASC),
      UNIQUE INDEX `users_id_UNIQUE` (`users_id` ASC),
      UNIQUE INDEX `messages_id_UNIQUE` (`messages_id` ASC),
      UNIQUE INDEX `comment_UNIQUE` (`comment` ASC),
      UNIQUE INDEX `created_at_UNIQUE` (`created_at` ASC),
      UNIQUE INDEX `updated_at_UNIQUE` (`updated_at` ASC),
      CONSTRAINT `fk_comments_users1`
        FOREIGN KEY (`users_id`)
        REFERENCES `mydb`.`users` (`id`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION,
      CONSTRAINT `fk_comments_messages1`
        FOREIGN KEY (`messages_id`)
        REFERENCES `mydb`.`messages` (`id`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION)
    ENGINE = InnoDB;

    SET SQL_MODE=@OLD_SQL_MODE;
    SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
    SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
</code>```

答:
InnoDB index maximum length is 767 bytes by default.

When you declare your unique index on your TEXT column, which has a maximum length of 65535 bytes, it exceeds the maximum index length by a lot.

```<code>UNIQUE INDEX `message_UNIQUE` (`message` ASC),
</code>```

You can enable innodb_large_prefix which makes it possible to make an index of 3072 bytes, that's also much too small for a complete TEXT column.

You can us a prefix index for a TEXT column, but that's not a good solution to enforce uniqueness.

```<code>INDEX `message` (`message`(255) ASC),
</code>```

You should reconsider whether you need a unique constraint on a TEXT column.

See also:

https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html

https://stackoverflow.com/a/16474039/20860

Title: SQL error: 1170

Body:
I am getting the following error when running the below code...what is wrong with it?

Error Code:1170. BLOB/TEXT column 'message" used in key specification without a key length.

-- MySQL Script generated by MySQL Workbench
-- Sun Jun  4 21:25:42 2017
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

    SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
    CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
    USE `mydb` ;

-- -----------------------------------------------------
-- Table `mydb`.`users`
-- -----------------------------------------------------
    CREATE TABLE IF NOT EXISTS `mydb`.`users` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `first_name` VARCHAR(255) NOT NULL,
      `last_name` VARCHAR(255) NOT NULL,
      `email` VARCHAR(255) NOT NULL,
      `password` VARCHAR(255) NOT NULL,
      `created_at` DATETIME NOT NULL,
      `updates_at` DATETIME NOT NULL,
      PRIMARY KEY (`id`),
      UNIQUE INDEX `first_name_UNIQUE` (`first_name` ASC),
      UNIQUE INDEX `last_name_UNIQUE` (`last_name` ASC),
      UNIQUE INDEX `email_UNIQUE` (`email` ASC),
      UNIQUE INDEX `password_UNIQUE` (`password` ASC),
      UNIQUE INDEX `created_at_UNIQUE` (`created_at` ASC),
      UNIQUE INDEX `updates_at_UNIQUE` (`updates_at` ASC))
      ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `mydb`.`messages`
-- -----------------------------------------------------
    CREATE TABLE IF NOT EXISTS `mydb`.`messages` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `users_id` INT NOT NULL,
      `message` TEXT NOT NULL,
      `created_at` DATETIME NOT NULL,
      `updated_at` DATETIME NOT NULL,
      PRIMARY KEY (`id`),
      INDEX `fk_messages_users_idx` (`users_id` ASC),
      UNIQUE INDEX `id_UNIQUE` (`id` ASC),
      UNIQUE INDEX `users_id_UNIQUE` (`users_id` ASC),
      UNIQUE INDEX `message_UNIQUE` (`message` ASC),
      UNIQUE INDEX `created_at_UNIQUE` (`created_at` ASC),
      UNIQUE INDEX `updated_at_UNIQUE` (`updated_at` ASC),
      CONSTRAINT `fk_messages_users`
        FOREIGN KEY (`users_id`)
        REFERENCES `mydb`.`users` (`id`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION)
      ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `mydb`.`comments`
-- -----------------------------------------------------
    CREATE TABLE IF NOT EXISTS `mydb`.`comments` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `users_id` INT NOT NULL,
      `messages_id` INT NOT NULL,
      `comment` TEXT NOT NULL,
      `created_at` DATETIME NOT NULL,
      `updated_at` DATETIME NOT NULL,
      PRIMARY KEY (`id`),
      INDEX `fk_comments_users1_idx` (`users_id` ASC),
      INDEX `fk_comments_messages1_idx` (`messages_id` ASC),
      UNIQUE INDEX `id_UNIQUE` (`id` ASC),
      UNIQUE INDEX `users_id_UNIQUE` (`users_id` ASC),
      UNIQUE INDEX `messages_id_UNIQUE` (`messages_id` ASC),
      UNIQUE INDEX `comment_UNIQUE` (`comment` ASC),
      UNIQUE INDEX `created_at_UNIQUE` (`created_at` ASC),
      UNIQUE INDEX `updated_at_UNIQUE` (`updated_at` ASC),
      CONSTRAINT `fk_comments_users1`
        FOREIGN KEY (`users_id`)
        REFERENCES `mydb`.`users` (`id`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION,
      CONSTRAINT `fk_comments_messages1`
        FOREIGN KEY (`messages_id`)
        REFERENCES `mydb`.`messages` (`id`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION)
    ENGINE = InnoDB;

    SET SQL_MODE=@OLD_SQL_MODE;
    SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
    SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

Body:
InnoDB index maximum length is 767 bytes by default.

When you declare your unique index on your TEXT column, which has a maximum length of 65535 bytes, it exceeds the maximum index length by a lot.

UNIQUE INDEX `message_UNIQUE` (`message` ASC),

You can enable innodb_large_prefix which makes it possible to make an index of 3072 bytes, that's also much too small for a complete TEXT column.

You can us a prefix index for a TEXT column, but that's not a good solution to enforce uniqueness.

INDEX `message` (`message`(255) ASC),

You should reconsider whether you need a unique constraint on a TEXT column.

See also:

https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html

https://stackoverflow.com/a/16474039/20860


问:
Getting Max date in Linq Query
I want to get maxdate in linq where clause. If i try like below, it throws an error.

```<code>var dt1 = dtCurTopSQL.AsEnumerable()
     .Where (l =>
        l.Field<DateTime>("SAMPLE_TIME").Max() >= DateTime.Now.AddSeconds(lastxminutes))
</code>```

Error:

Error  CS1929  'DateTime' does not contain a definition for 'Max'

答:
.Max() only operates on a collection, not a field.

You need to calculate the maximum value first, from the entire collection:

```<code>var maxDate = dtCurTopSQL.Max(r => r.Whatever);
</code>```

You can then use that variable in other queries.

Title: Getting Max date in Linq Query

Body:
I want to get maxdate in linq where clause. If i try like below, it throws an error.

var dt1 = dtCurTopSQL.AsEnumerable()
     .Where (l =>
        l.Field<DateTime>("SAMPLE_TIME").Max() >= DateTime.Now.AddSeconds(lastxminutes))

Error:

Error  CS1929  'DateTime' does not contain a definition for 'Max'

Body:
.Max() only operates on a collection, not a field.

You need to calculate the maximum value first, from the entire collection:

var maxDate = dtCurTopSQL.Max(r => r.Whatever);

You can then use that variable in other queries.


问:
Error when I try to post to database. I am trying to calculate GPA
I am getting this error "ErrorException in scoresheetController.php line 259:
Object of class Illuminate\Database\Eloquent\Collection could not be converted to int" when I want to post the following into the database. Kindly find the code below.

```<code> <?php

    namespace App\Http\Controllers;

    use App\Http\Requests\scoresheetRequest;
    use App\Scoresheet;
    use App\StudentCourse;
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Input;
    use DB;
    use Excel;
    use Illuminate\Database\Eloquent\Collection;

    class scoresheetController extends Controller
    {
        /**
         * Create a new controller instance.
         *
         * @return void
         */
        public function __construct()
        {
            $this->middleware('auth');
        }

        /**
         * Display a listing of the resource.
         *
         * @return \Illuminate\Http\Response
         */
        public function index()
        {
            $scoresheet = Scoresheet::select('id', 'code', 'stud_id', 'term', 'year', 'CA_Score', 'exam_score', 'total', 'grade')->get();

            return view('admin.results')->with('scoresheet', $scoresheet);
        }

        /**
         * Show the form for creating a new resource.
         *
         * @return \Illuminate\Http\Response
         */
        public function create()
        {
            //
        }

        /**
         * Store a newly created resource in storage.
         *
         * @param  \Illuminate\Http\Request  $request
         * @return \Illuminate\Http\Response
         */
        public function store(scoresheetRequest $request)
        {
            //dd($request ->all());

            $scoresheet = new Scoresheet();

            $crdthr = StudentCourse::select('student_courses')
                                    ->join('scoresheets', 'student_courses.stud_id', '=', 'scoresheets.stud_id')
                                    ->select('student_courses.credit_hrs')
                                    ->get();

            //Calculate total
            $total  = $request['CA_Score'] + $request['exam_score'];

            //Calculate the grade
            switch ($grade = $total) {
                case $total >=93 && $total==100:
                   $grade =  "A+";
                    break;
                case $total>=85:
                    $grade = "A";
                    break;
                case $total >=77:
                    $grade = "B+";
                    break;
                case $total >=70:
                    $grade = "B";
                    break;
                case $total >=60:
                    $grade = "C";
                    break;
                case $total >=55:
                    $grade = "D+";
                    break;
                case $total >=50:
                    $grade = "D";
                    break;
                case $total <50:
                    $grade = "F";
                    break;
            }

            //Check for grade equivalent
            switch ($digit = $grade) {
                case $grade == "A+":
                    $digit =  "4.00";
                    break;
                case $grade == "A":
                    $digit =  "3.75";
                    break;
                case $grade == "B+":
                    $digit =  "3.50";
                    break;
                case $grade == "B":
                    $digit =  "3.00";
                    break;
                case $grade == "C+":
                    $digit =  "2.50";
                    break;
                case $grade == "C":
                    $digit =  "2.00";
                    break;
                case $grade == "D+":
                    $digit =  "1.50";
                    break;
                case $grade == "D":
                    $digit =  "1.00";
                    break;
                case $grade == "F":
                    $digit =  "0.00";
                    break;
            }

            //Calculate mini wgt
            $gpa = $digit * $crdthr;

            $scoresheet->code = $request['code'];
            $scoresheet->stud_id = $request['stud_id'];
            $scoresheet->term = $request['term'];
            $scoresheet->year = $request['year'];
            $scoresheet->CA_Score = $request['CA_Score'];
            $scoresheet->exam_score = $request['exam_score'];
            $scoresheet->total = $total;
            $scoresheet->grade = $grade;
            $scoresheet->grade_digit = $digit;
            $scoresheet->mini_wgt = $gpa;

            //dd($gpa);
            if ($scoresheet->save()){
                flash($request['name'].' successfully saved.')->success();
                /*echo 'saved';*/
            }else{
                flash($request['name'].' not saved.')->error();
                /*echo 'Not saved';*/
            }

            return redirect()->back();
        }

        /**
         * Display the specified resource.
         *
         * @param  int  $id
         * @return \Illuminate\Http\Response
         */
        public function show($id)
        {
            //
        }

        /**
         * Show the form for editing the specified resource.
         *
         * @param  int  $id
         * @return \Illuminate\Http\Response
         */
        public function edit($id)
        {
            $scoresheet =Scoresheet::findOrFail($id);

            return view('admin.result_edit') ->with('scoresheet', $scoresheet);
        }

        /**
         * Update the specified resource in storage.
         *
         * @param  \Illuminate\Http\Request  $request
         * @param  int  $id
         * @return \Illuminate\Http\Response
         */
        public function update(Request $request, $id)
        {
            $scoresheet = Scoresheet::findOrFail($id);

            $crdthr = StudentCourse::select('student_courses')
                ->join('scoresheets', 'student_courses.stud_id', '=', 'scoresheets.stud_id')
                ->select('student_courses.credit_hrs')
                ->get();

            $total = $request['CA_Score'] + $request['exam_score'];

            //Calculate the grade
            switch ($grade = $total) {
                case $total >=93 && $total==100:
                    $grade =  "A+";
                    break;
                case $total>=85:
                    $grade = "A";
                    break;
                case $total >=77:
                    $grade = "B+";
                    break;
                case $total >=70:
                    $grade = "B";
                    break;
                case $total >=60:
                    $grade = "C";
                    break;
                case $total >=55:
                    $grade = "D+";
                    break;
                case $total >=50:
                    $grade = "D";
                    break;
                case $total <50:
                    $grade = "F";
                    break;
            }

            //Check for grade equivalent
            switch ($digit = $grade) {
                case $grade == "A+":
                    $digit =  "4.00";
                    break;
                case $grade == "A":
                    $digit =  "3.75";
                    break;
                case $grade == "B+":
                    $digit =  "3.50";
                    break;
                case $grade == "B":
                    $digit =  "3.00";
                    break;
                case $grade == "C+":
                    $digit =  "2.50";
                    break;
                case $grade == "C":
                    $digit =  "2.00";
                    break;
                case $grade == "D+":
                    $digit =  "1.50";
                    break;
                case $grade == "D":
                    $digit =  "1.00";
                    break;
                case $grade == "F":
                    $digit =  "0.00";
                    break;
            }

            //Calculate mini wgt
            $gpa = $digit * $crdthr;

            $scoresheet->code = $request['code'];
            $scoresheet->stud_id = $request['stud_id'];
            $scoresheet->term = $request['term'];
            $scoresheet->year = $request['year'];
            $scoresheet->CA_Score = $request['CA_Score'];
            $scoresheet->exam_score = $request['exam_score'];
            $scoresheet->total = $total;
            $scoresheet->grade = $grade;
            $scoresheet->grade_digit = $digit;
            $scoresheet->mini_wgt = $gpa;

            if ($scoresheet->save()){
                flash($request['name'].' successfully saved.')->success();
                /*echo 'saved';*/
            }else{
                flash($request['name'].' not saved.')->error();
                /*echo 'Not saved';*/
            }

            return redirect() ->to('/scoresheet');
        }

        /**
         * Remove the specified resource from storage.
         *
         * @param  int  $id
         * @return \Illuminate\Http\Response
         */
        public function destroy($id)
        {
            $scoresheet = Scoresheet::findOrFail($id);

            if (Scoresheet::destroy($id)){
                flash ('deleted successfully')->success();
            }else{
                flash ('failed to delete')->warning();
            }

            return redirect()->back();
        }

    }
</code>```

I would be glad if assistance can be given as soon as possible.

答:
Looking quickly at your code I can say that your problem is in this bit of code :

```<code>$crdthr = StudentCourse::select('student_courses')
   ->join('scoresheets', 'student_courses.stud_id', '=', 'scoresheets.stud_id')
   ->select('student_courses.credit_hrs')
   ->get();
</code>```

Since you are returning an Eloquent Collection from here later below in your code you are trying to make math operations over this Collection :

```<code>   //Calculate mini wgt
   $gpa = $digit * $crdthr;
</code>```

Body:
I am getting this error "ErrorException in scoresheetController.php line 259:
Object of class Illuminate\Database\Eloquent\Collection could not be converted to int" when I want to post the following into the database. Kindly find the code below.

 <?php

    namespace App\Http\Controllers;

    use App\Http\Requests\scoresheetRequest;
    use App\Scoresheet;
    use App\StudentCourse;
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Input;
    use DB;
    use Excel;
    use Illuminate\Database\Eloquent\Collection;

    class scoresheetController extends Controller
    {
        /**
         * Create a new controller instance.
         *
         * @return void
         */
        public function __construct()
        {
            $this->middleware('auth');
        }

        /**
         * Display a listing of the resource.
         *
         * @return \Illuminate\Http\Response
         */
        public function index()
        {
            $scoresheet = Scoresheet::select('id', 'code', 'stud_id', 'term', 'year', 'CA_Score', 'exam_score', 'total', 'grade')->get();

            return view('admin.results')->with('scoresheet', $scoresheet);
        }

        /**
         * Show the form for creating a new resource.
         *
         * @return \Illuminate\Http\Response
         */
        public function create()
        {
            //
        }

        /**
         * Store a newly created resource in storage.
         *
         * @param  \Illuminate\Http\Request  $request
         * @return \Illuminate\Http\Response
         */
        public function store(scoresheetRequest $request)
        {
            //dd($request ->all());

            $scoresheet = new Scoresheet();

            $crdthr = StudentCourse::select('student_courses')
                                    ->join('scoresheets', 'student_courses.stud_id', '=', 'scoresheets.stud_id')
                                    ->select('student_courses.credit_hrs')
                                    ->get();

            //Calculate total
            $total  = $request['CA_Score'] + $request['exam_score'];

            //Calculate the grade
            switch ($grade = $total) {
                case $total >=93 && $total==100:
                   $grade =  "A+";
                    break;
                case $total>=85:
                    $grade = "A";
                    break;
                case $total >=77:
                    $grade = "B+";
                    break;
                case $total >=70:
                    $grade = "B";
                    break;
                case $total >=60:
                    $grade = "C";
                    break;
                case $total >=55:
                    $grade = "D+";
                    break;
                case $total >=50:
                    $grade = "D";
                    break;
                case $total <50:
                    $grade = "F";
                    break;
            }

            //Check for grade equivalent
            switch ($digit = $grade) {
                case $grade == "A+":
                    $digit =  "4.00";
                    break;
                case $grade == "A":
                    $digit =  "3.75";
                    break;
                case $grade == "B+":
                    $digit =  "3.50";
                    break;
                case $grade == "B":
                    $digit =  "3.00";
                    break;
                case $grade == "C+":
                    $digit =  "2.50";
                    break;
                case $grade == "C":
                    $digit =  "2.00";
                    break;
                case $grade == "D+":
                    $digit =  "1.50";
                    break;
                case $grade == "D":
                    $digit =  "1.00";
                    break;
                case $grade == "F":
                    $digit =  "0.00";
                    break;
            }

            //Calculate mini wgt
            $gpa = $digit * $crdthr;

            $scoresheet->code = $request['code'];
            $scoresheet->stud_id = $request['stud_id'];
            $scoresheet->term = $request['term'];
            $scoresheet->year = $request['year'];
            $scoresheet->CA_Score = $request['CA_Score'];
            $scoresheet->exam_score = $request['exam_score'];
            $scoresheet->total = $total;
            $scoresheet->grade = $grade;
            $scoresheet->grade_digit = $digit;
            $scoresheet->mini_wgt = $gpa;

            //dd($gpa);
            if ($scoresheet->save()){
                flash($request['name'].' successfully saved.')->success();
                /*echo 'saved';*/
            }else{
                flash($request['name'].' not saved.')->error();
                /*echo 'Not saved';*/
            }

            return redirect()->back();
        }

        /**
         * Display the specified resource.
         *
         * @param  int  $id
         * @return \Illuminate\Http\Response
         */
        public function show($id)
        {
            //
        }

        /**
         * Show the form for editing the specified resource.
         *
         * @param  int  $id
         * @return \Illuminate\Http\Response
         */
        public function edit($id)
        {
            $scoresheet =Scoresheet::findOrFail($id);

            return view('admin.result_edit') ->with('scoresheet', $scoresheet);
        }

        /**
         * Update the specified resource in storage.
         *
         * @param  \Illuminate\Http\Request  $request
         * @param  int  $id
         * @return \Illuminate\Http\Response
         */
        public function update(Request $request, $id)
        {
            $scoresheet = Scoresheet::findOrFail($id);

            $crdthr = StudentCourse::select('student_courses')
                ->join('scoresheets', 'student_courses.stud_id', '=', 'scoresheets.stud_id')
                ->select('student_courses.credit_hrs')
                ->get();

            $total = $request['CA_Score'] + $request['exam_score'];

            //Calculate the grade
            switch ($grade = $total) {
                case $total >=93 && $total==100:
                    $grade =  "A+";
                    break;
                case $total>=85:
                    $grade = "A";
                    break;
                case $total >=77:
                    $grade = "B+";
                    break;
                case $total >=70:
                    $grade = "B";
                    break;
                case $total >=60:
                    $grade = "C";
                    break;
                case $total >=55:
                    $grade = "D+";
                    break;
                case $total >=50:
                    $grade = "D";
                    break;
                case $total <50:
                    $grade = "F";
                    break;
            }

            //Check for grade equivalent
            switch ($digit = $grade) {
                case $grade == "A+":
                    $digit =  "4.00";
                    break;
                case $grade == "A":
                    $digit =  "3.75";
                    break;
                case $grade == "B+":
                    $digit =  "3.50";
                    break;
                case $grade == "B":
                    $digit =  "3.00";
                    break;
                case $grade == "C+":
                    $digit =  "2.50";
                    break;
                case $grade == "C":
                    $digit =  "2.00";
                    break;
                case $grade == "D+":
                    $digit =  "1.50";
                    break;
                case $grade == "D":
                    $digit =  "1.00";
                    break;
                case $grade == "F":
                    $digit =  "0.00";
                    break;
            }

            //Calculate mini wgt
            $gpa = $digit * $crdthr;

            $scoresheet->code = $request['code'];
            $scoresheet->stud_id = $request['stud_id'];
            $scoresheet->term = $request['term'];
            $scoresheet->year = $request['year'];
            $scoresheet->CA_Score = $request['CA_Score'];
            $scoresheet->exam_score = $request['exam_score'];
            $scoresheet->total = $total;
            $scoresheet->grade = $grade;
            $scoresheet->grade_digit = $digit;
            $scoresheet->mini_wgt = $gpa;

            if ($scoresheet->save()){
                flash($request['name'].' successfully saved.')->success();
                /*echo 'saved';*/
            }else{
                flash($request['name'].' not saved.')->error();
                /*echo 'Not saved';*/
            }

            return redirect() ->to('/scoresheet');
        }

        /**
         * Remove the specified resource from storage.
         *
         * @param  int  $id
         * @return \Illuminate\Http\Response
         */
        public function destroy($id)
        {
            $scoresheet = Scoresheet::findOrFail($id);

            if (Scoresheet::destroy($id)){
                flash ('deleted successfully')->success();
            }else{
                flash ('failed to delete')->warning();
            }

            return redirect()->back();
        }

    }

I would be glad if assistance can be given as soon as possible.

Body:
Looking quickly at your code I can say that your problem is in this bit of code :

$crdthr = StudentCourse::select('student_courses')
   ->join('scoresheets', 'student_courses.stud_id', '=', 'scoresheets.stud_id')
   ->select('student_courses.credit_hrs')
   ->get();

Since you are returning an Eloquent Collection from here later below in your code you are trying to make math operations over this Collection :

   //Calculate mini wgt
   $gpa = $digit * $crdthr;


问:
Error loading SMFL shared library
So, I made a program in Linux(OpenSUSE), using C++ and SFML.

I tried to send the compiled program to a friend of mine (also on Linux) but it said it was missing the DLL's. So I included all the ".so" that I used (audio, graphics, window, and system) but when he tries to run it, it keeps giving an error:

```<code>error while loading shared libraries: libsfml-audio.so.2.4: cannot open shared object file: No such file or directory
</code>```

So I went to check, and I definitely included the "libsfml-audio.so.2.4" file.

I really don't want to have to make him install SFML just so he can run it.

Thanks in advance for any help.

答:
Linux is a bit more nitpicky when it comes to loading shared libraries.

Easiest solution is to indeed bundle your shared libraries and tell the program to actually load them from there.

Let's assume the shared libraries are next to your executable, you'd launch it like this:

```<code>LD_LIBRARY_PATH=. ./yourExecutableName
</code>```

Title: Error loading SMFL shared library

Body:
So, I made a program in Linux(OpenSUSE), using C++ and SFML.

I tried to send the compiled program to a friend of mine (also on Linux) but it said it was missing the DLL's. So I included all the ".so" that I used (audio, graphics, window, and system) but when he tries to run it, it keeps giving an error:

error while loading shared libraries: libsfml-audio.so.2.4: cannot open shared object file: No such file or directory

So I went to check, and I definitely included the "libsfml-audio.so.2.4" file.

I really don't want to have to make him install SFML just so he can run it.

Thanks in advance for any help.

Body:
Linux is a bit more nitpicky when it comes to loading shared libraries.

Easiest solution is to indeed bundle your shared libraries and tell the program to actually load them from there.

Let's assume the shared libraries are next to your executable, you'd launch it like this:

LD_LIBRARY_PATH=. ./yourExecutableName


问:
Why does __mul__() expect integer arguments?
I'm getting TypeError: 'float' object cannot be interpreted as an integer.  It appears __mul__() is expecting an integer only argument.  Did I not define it correctly?

```<code># Running Python 3.6.0
from math import sqrt

class Vector(object):
    def __init__(self, coordinates):
        try:
            self.dimension = len(coordinates)
            if self.dimension < 2 or self.dimension > 3:
                raise ValueError
            self.coordinates = tuple(coordinates)

        except ValueError:
            raise ValueError('Must have at least 2 coordinates and no more than 3. Length = {}'.format(self.dimension))

        except TypeError:
            raise TypeError('The coordinates must be an iterable')

        self.magnitude = sqrt(sum([n ** 2 for n in self.coordinates]))

    # This fails with a type error
    def normalized(self):
        try:
            normalized = self.coordinates.__mul__(1.0 / self.magnitude)
        except ZeroDivisionError:
            raise Exception("Cannot normalize zero vector")
        return normalized

    # This fails with a type error
    # def normalized(self):
    #     try:
    #         normalized = self.coordinates * (1.0 / self.magnitude)
    #     except ZeroDivisionError:
    #         raise Exception("Cannot normalize zero vector")
    #     return normalized

    # This works fine
    # def normalized(self):
    #     try:
    #         normalized = [n / self.magnitude for n in self.coordinates]
    #     except ZeroDivisionError:
    #         raise Exception("Cannot normalize zero vector")
    #     return Vector(normalized)

    def __iter__(self):
        return self.coordinates

    def __mul__(self, scalar):
        # Vector scalar multiplication
        return Vector([e * scalar for e in self.coordinates])

    def __str__(self):
        return 'Vector: {}'.format(self.coordinates)

# Run the test...
if __name__ == "__main__":
    v1 = Vector([1.996, 3.108, -4.554])
    print(v1)
    print(v1.normalized())
</code>```

EDIT:

Now that I understand what happened I'd like to clarify the answer for anyone who might run into this in the future.

The problem was here:

```<code>normalized = self.coordinates.__mul__(1.0 / self.magnitude)
</code>```

Which, for the purpose of this explanation simplifies to:

```<code>a = b.__mul__(c)
</code>```

or

```<code>a = b * c
</code>```

Here b is a tuple and c is a number, a real number.

In Python

```<code>(1, 2) * 3
</code>```

results in

```<code>(1, 2, 1, 2, 1, 2)
</code>```

In other words the * operator applied to a tuple results in the replication of that tuple N times.

Which also means we can't multiply a tuple by a float, it makes no sense.  Hence the error:

```<code>TypeError: 'float' object cannot be interpreted as an integer
</code>```

Makes sense.

My error was in that I multiplied the tuple by self.magnitude rather than to multiply my Vector object by self.magnitude, like this:

```<code>normalized = self.__mul__(1.0 / self.magnitude)
</code>```

Given my definition of __mul__() this makes sense and works fine.  And this works too:

```<code>normalized = self * (1.0 / self.magnitude)
</code>```

答:
You are applying __mul__ to the tuple coordinates. That returns n copies, which clearly requires an integer.

Since you've written a __mul__ function, you probably meant to call that

```<code>normalized = self.__mul__(1.0 / self.magnitude)
</code>```

or directly

```<code>normalized = Vector([e * 1.0 / self.magnitude for e in self.coordinates])
</code>```

Body:
I'm getting TypeError: 'float' object cannot be interpreted as an integer.  It appears __mul__() is expecting an integer only argument.  Did I not define it correctly?

# Running Python 3.6.0
from math import sqrt

class Vector(object):
    def __init__(self, coordinates):
        try:
            self.dimension = len(coordinates)
            if self.dimension < 2 or self.dimension > 3:
                raise ValueError
            self.coordinates = tuple(coordinates)

        except ValueError:
            raise ValueError('Must have at least 2 coordinates and no more than 3. Length = {}'.format(self.dimension))

        except TypeError:
            raise TypeError('The coordinates must be an iterable')

        self.magnitude = sqrt(sum([n ** 2 for n in self.coordinates]))

    # This fails with a type error
    def normalized(self):
        try:
            normalized = self.coordinates.__mul__(1.0 / self.magnitude)
        except ZeroDivisionError:
            raise Exception("Cannot normalize zero vector")
        return normalized

    # This fails with a type error
    # def normalized(self):
    #     try:
    #         normalized = self.coordinates * (1.0 / self.magnitude)
    #     except ZeroDivisionError:
    #         raise Exception("Cannot normalize zero vector")
    #     return normalized

    # This works fine
    # def normalized(self):
    #     try:
    #         normalized = [n / self.magnitude for n in self.coordinates]
    #     except ZeroDivisionError:
    #         raise Exception("Cannot normalize zero vector")
    #     return Vector(normalized)

    def __iter__(self):
        return self.coordinates

    def __mul__(self, scalar):
        # Vector scalar multiplication
        return Vector([e * scalar for e in self.coordinates])

    def __str__(self):
        return 'Vector: {}'.format(self.coordinates)

# Run the test...
if __name__ == "__main__":
    v1 = Vector([1.996, 3.108, -4.554])
    print(v1)
    print(v1.normalized())

EDIT:

Now that I understand what happened I'd like to clarify the answer for anyone who might run into this in the future.

The problem was here:

normalized = self.coordinates.__mul__(1.0 / self.magnitude)

Which, for the purpose of this explanation simplifies to:

a = b.__mul__(c)

or

a = b * c

Here b is a tuple and c is a number, a real number.

In Python

(1, 2) * 3

results in

(1, 2, 1, 2, 1, 2)

In other words the * operator applied to a tuple results in the replication of that tuple N times.

Which also means we can't multiply a tuple by a float, it makes no sense.  Hence the error:

TypeError: 'float' object cannot be interpreted as an integer

Makes sense.

My error was in that I multiplied the tuple by self.magnitude rather than to multiply my Vector object by self.magnitude, like this:

normalized = self.__mul__(1.0 / self.magnitude)

Given my definition of __mul__() this makes sense and works fine.  And this works too:

normalized = self * (1.0 / self.magnitude)

Body:
You are applying __mul__ to the tuple coordinates. That returns n copies, which clearly requires an integer.

Since you've written a __mul__ function, you probably meant to call that

normalized = self.__mul__(1.0 / self.magnitude)

or directly

normalized = Vector([e * 1.0 / self.magnitude for e in self.coordinates])


问:
Angular Looped HTTP Request Map Value to Responses
In my service class I am looping an http get request and using rxjs forkJoin to combine all the responses into an observable which I return to my component.  For each response that comes back I need to add two properties to the json (readySystem which is an object and serviceType which is a string).  The value of each of these is different for each iteration of the loop.

How do I keep/store/retain the values for both and and map/add them to the correct response?

With the way I've attempted to do it below, the values for both are the same in every response returned in the final observable.

```<code>  getServices() {

  for (var x = 0; x < this.service.items.length; x++ ){
        var num = Object.keys(this.service.items[x].links).length;

         for (var key in this.service.items[x].links) {
            var systemName = this.service.items[x].systemName;
            var environment = this.service.items[x].environment;
            var server = this.service.items[x].server;
            var port = this.service.items[x].port;
            var linkName = this.service.items[x].links[key];
            var serviceType = key;
            this.observables.push(
            this.http.get('http://localhost:3000/myapi/get/service?server=' + server + '&service=' + linkName)
            .map((res:Response) => {
                var output = res.json()
                for (var obj in output) {
                    if (output.hasOwnProperty(obj)){

                        var readySystem = new System(systemName,
                         environment,
                         server,
                         port,
                         linkName);

                    output[obj].System = readySystem;
                    output[obj].serviceType = serviceType;
                    }
                }
                return output;
        })
            );
        }
        };
        return Observable.forkJoin(this.observables);
};
</code>```

Update: With the suggested code changes provided in the answer below, I get output like:

```<code>0: Array(33)
1: System
    systemName: "my system"
    environment: "my environment"
    etc.
2: "myservice"
3: Array(35)
4: System
   etc.
5: "myotherservice"
</code>```

However, what is needed is:

```<code>0: Array(33)
 0: Object
  > System
      systemName: "my system"
      environment: "my environment"
      etc.
   serviceType: "myservice"
 1: Object
  > System
      systemName: "my system"
      environment: "my environment"
      etc.
   serviceType: "myotherservice"
 etc.
1: Array(35)
 0: Object
</code>```

答:
It may be a simple classic JS closure issue. When all asynchronous calls (http.gets and Observable.forkJoin) are resolved, all function scoped vars (x, num, key, systemName, environment, server, port, ... etc.) within for loops are set to their last value. The easiest solution would be to use ES6 block scoped let or const declarations.

So try to change your code to something like:

```<code>for (let x = 0; x < this.service.items.length; x++ ){
  let num = Object.keys(this.service.items[x].links).length;

  for (let key in this.service.items[x].links) {
    let systemName = this.service.items[x].systemName;
    let environment = this.service.items[x].environment;
    let server = this.service.items[x].server;
    let port = this.service.items[x].port;
    let linkName = this.service.items[x].links[key];
    let serviceType = key;

    let url = `http://localhost:3000/myapi/get/service?server=${server}&service=${linkName}`;
    this.observables.push(this.http.get(url)
      .map((res:Response) => {
        let output = res.json();
        for (let obj in output) {
          if (output.hasOwnProperty(obj)) {

            let readySystem = new System(systemName,
              environment,
              server,
              port,
              linkName
            );

            output[obj].System = readySystem;
            output[obj].serviceType = serviceType;
          }
        }
        return output;
      }
    ));
  }};
  return Observable.forkJoin(this.observables);
};
</code>```

and in general, there is no reason not to use new ES6 features when coding with Angular 2/4.

You could also rewrite your first for loop using Array.forEach() function (I assume that this.service.items is an array because of its length property):

```<code>this.service.items.forEach(item => {
  let num = Object.keys(item.links).length;

  for (let key in item.links) {
    let systemName = item.systemName;
    let environment = item.environment;
    let server = item.server;
    let port = item.port;
    let linkName = item.links[key];
    let serviceType = key;

    let url = `http://localhost:3000/myapi/get/service?server=${server}&service=${linkName}`;
    this.observables.push(this.http.get(url)
      .map((res:Response) => {
        let output = res.json();
        for (let obj in output) {
          if (output.hasOwnProperty(obj)) {

            let readySystem = new System(systemName,
              environment,
              server,
              port,
              linkName
            );

            output[obj].System = readySystem;
            output[obj].serviceType = serviceType;
          }
        }
        return output;
      }
    ));
  }};
  return Observable.forkJoin(this.observables);
});
</code>```

Body:
In my service class I am looping an http get request and using rxjs forkJoin to combine all the responses into an observable which I return to my component.  For each response that comes back I need to add two properties to the json (readySystem which is an object and serviceType which is a string).  The value of each of these is different for each iteration of the loop.

How do I keep/store/retain the values for both and and map/add them to the correct response?

With the way I've attempted to do it below, the values for both are the same in every response returned in the final observable.

  getServices() {

  for (var x = 0; x < this.service.items.length; x++ ){
        var num = Object.keys(this.service.items[x].links).length;

         for (var key in this.service.items[x].links) {
            var systemName = this.service.items[x].systemName;
            var environment = this.service.items[x].environment;
            var server = this.service.items[x].server;
            var port = this.service.items[x].port;
            var linkName = this.service.items[x].links[key];
            var serviceType = key;
            this.observables.push(
            this.http.get('http://localhost:3000/myapi/get/service?server=' + server + '&service=' + linkName)
            .map((res:Response) => {
                var output = res.json()
                for (var obj in output) {
                    if (output.hasOwnProperty(obj)){

                        var readySystem = new System(systemName,
                         environment,
                         server,
                         port,
                         linkName);

                    output[obj].System = readySystem;
                    output[obj].serviceType = serviceType;
                    }
                }
                return output;
        })
            );
        }
        };
        return Observable.forkJoin(this.observables);
};

Update: With the suggested code changes provided in the answer below, I get output like:

0: Array(33)
1: System
    systemName: "my system"
    environment: "my environment"
    etc.
2: "myservice"
3: Array(35)
4: System
   etc.
5: "myotherservice"

However, what is needed is:

0: Array(33)
 0: Object
  > System
      systemName: "my system"
      environment: "my environment"
      etc.
   serviceType: "myservice"
 1: Object
  > System
      systemName: "my system"
      environment: "my environment"
      etc.
   serviceType: "myotherservice"
 etc.
1: Array(35)
 0: Object

Body:
It may be a simple classic JS closure issue. When all asynchronous calls (http.gets and Observable.forkJoin) are resolved, all function scoped vars (x, num, key, systemName, environment, server, port, ... etc.) within for loops are set to their last value. The easiest solution would be to use ES6 block scoped let or const declarations.

So try to change your code to something like:

for (let x = 0; x < this.service.items.length; x++ ){
  let num = Object.keys(this.service.items[x].links).length;

  for (let key in this.service.items[x].links) {
    let systemName = this.service.items[x].systemName;
    let environment = this.service.items[x].environment;
    let server = this.service.items[x].server;
    let port = this.service.items[x].port;
    let linkName = this.service.items[x].links[key];
    let serviceType = key;

    let url = `http://localhost:3000/myapi/get/service?server=${server}&service=${linkName}`;
    this.observables.push(this.http.get(url)
      .map((res:Response) => {
        let output = res.json();
        for (let obj in output) {
          if (output.hasOwnProperty(obj)) {

            let readySystem = new System(systemName,
              environment,
              server,
              port,
              linkName
            );

            output[obj].System = readySystem;
            output[obj].serviceType = serviceType;
          }
        }
        return output;
      }
    ));
  }};
  return Observable.forkJoin(this.observables);
};

and in general, there is no reason not to use new ES6 features when coding with Angular 2/4.

You could also rewrite your first for loop using Array.forEach() function (I assume that this.service.items is an array because of its length property):

this.service.items.forEach(item => {
  let num = Object.keys(item.links).length;

  for (let key in item.links) {
    let systemName = item.systemName;
    let environment = item.environment;
    let server = item.server;
    let port = item.port;
    let linkName = item.links[key];
    let serviceType = key;

    let url = `http://localhost:3000/myapi/get/service?server=${server}&service=${linkName}`;
    this.observables.push(this.http.get(url)
      .map((res:Response) => {
        let output = res.json();
        for (let obj in output) {
          if (output.hasOwnProperty(obj)) {

            let readySystem = new System(systemName,
              environment,
              server,
              port,
              linkName
            );

            output[obj].System = readySystem;
            output[obj].serviceType = serviceType;
          }
        }
        return output;
      }
    ));
  }};
  return Observable.forkJoin(this.observables);
});


问:
This code can't find first element
```<code>def c(stringenter):
    last = 1
    commandsline = [['a', 'first'], ['b', 'second'], ['c', 'third']]
    for commandblock in commandsline:
        last = last + 1
        if commandblock[0] == stringenter:
            realcommand = str(commandblock[1])
        elif last == len(commandsline):
            realcommand = stringenter
    return realcommand
</code>```

Hello!!! This code can find and return second, third but can't find first how  resolve problem?

答:
While @Damian's answer correctly answers your question, you may find the two other forms of your function easier:

```<code>def c(stringenter):
    commandsline = [['a', 'first'], ['b', 'second'], ['c', 'third']]
    for key, cmd in commandsline:
        if stringenter == key:
            return cmd
    return stringenter
</code>```

Or just use a dictionary directly:

```<code>def c(stringenter):
    commandsline = {'a': 'first', 'b': 'second', 'c': 'third'}
    return commandsline.get(stringenter, stringenter)
</code>```

Title: This code can't find first element

Body:
def c(stringenter):
    last = 1
    commandsline = [['a', 'first'], ['b', 'second'], ['c', 'third']]
    for commandblock in commandsline:
        last = last + 1
        if commandblock[0] == stringenter:
            realcommand = str(commandblock[1])
        elif last == len(commandsline):
            realcommand = stringenter
    return realcommand

Hello!!! This code can find and return second, third but can't find first how  resolve problem?

Body:
While @Damian's answer correctly answers your question, you may find the two other forms of your function easier:

def c(stringenter):
    commandsline = [['a', 'first'], ['b', 'second'], ['c', 'third']]
    for key, cmd in commandsline:
        if stringenter == key:
            return cmd
    return stringenter

Or just use a dictionary directly:

def c(stringenter):
    commandsline = {'a': 'first', 'b': 'second', 'c': 'third'}
    return commandsline.get(stringenter, stringenter)


问:
How to remove lines from File A that are in File B in Windows command shell?
This other question is excellent for joining two files.  I need to do sort of the opposite.  I need to remove lines from File A that are in File B.

This question is similar to this other question, except that question is for unix and this is for the windows command shell (cmd.exe).

I would like to use tools that are native to Windows 7 Pro.

Update:

The files are hosts files.  Each one has lines consisting of:

127.0.0.1   host.domain.com

or

0.0.0.0   host.domain.com

or

# this is a comment

Files may have up to 200,000 lines.  Spaces and tabs may be present.

Although I prefer it to be preserved, order does not affect function.

Here are some examples of hosts files:

https://adaway.org/hosts.txt

https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext

https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts

https://hosts-file.net/ad_servers.txt

http://winhelp2002.mvps.org/hosts.txt

http://someonewhocares.org/hosts/hosts

(Don't worry about 0.0.0.0 vs '127.0.0.1` for this question.)

答:
You did not provided a single specification for this problem! May the files have special characters or spaces? How many lines they may have? Must the output file be in the same order of FileA?

This solution may or may not work depending on a series of factors...

```<code>@echo off
setlocal

rem Load lines from File A into "fileA" array
for /F "delims=" %%a in (FileA.txt) do set "fileA["%%a"]=1"

rem Remove elements from "fileA" array that are in File B
for /F "delims=" %%b in (FileB.txt) do set "fileA["%%b"]="

rem Show remaining elements
for /F "tokens=2 delims=[]" %%a in ('set fileA[') do echo(%%~a
</code>```

Body:
You did not provided a single specification for this problem! May the files have special characters or spaces? How many lines they may have? Must the output file be in the same order of FileA?

This solution may or may not work depending on a series of factors...

@echo off
setlocal

rem Load lines from File A into "fileA" array
for /F "delims=" %%a in (FileA.txt) do set "fileA["%%a"]=1"

rem Remove elements from "fileA" array that are in File B
for /F "delims=" %%b in (FileB.txt) do set "fileA["%%b"]="

rem Show remaining elements
for /F "tokens=2 delims=[]" %%a in ('set fileA[') do echo(%%~a