我正在M中创建一个程序,它读取某种格式的名称输入。一旦用户放置一个空值,它就会打印出所有值。我陷入困境的地方是阅读全局变量。我期待着我能收到的任何意见。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<connectionStrings>
<add name="ModelBXContainer" connectionString="metadata=res://*/ModelBX.csdl|res://*/ModelBX.ssdl|res://*/ModelBX.msl;provider=System.Data.SqlClient;provider connection string="data source=GOBELET-PC\SQLEXPRESS;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.serviceModel>
<services>
<service name="BXSportWCFLib.ServiceBX" behaviorConfiguration="MyServiceBehavior">
<endpoint name="rest" address="" binding="webHttpBinding" contract="BXSportWCFLib.ServiceBX" behaviorConfiguration="restBehavior" />
<endpoint name="mex" address="mex" binding="mexHttpBinding" contract="BXSportWCFLib.ServiceBX" />
<endpoint name="soap" address="soap" binding="basicHttpBinding" contract="BXSportWCFLib.ServiceBX" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="restBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<directoryBrowse enabled="true" />
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
</configuration>
答案 0 :(得分:1)
你的代码看起来很奇怪。首先,这一行s val="" f in=1:1 s val=$O(^ZNAME(val)) q:val=""
是无用的,只需在全局的第一个下标中排序所有值。然后,当输入的val将传递您的模式时,您的代码将失败,并且对于完成变量会出现UNDEFINED
错误。最后它从全局^ZNAME
获得新值,无论输入什么,它都会一直得到一个值。
答案 1 :(得分:0)
我不完全明白你想做什么,但这就是我所建立的:
你走了:
readlist
N prompt,val
S prompt="Enter a name (LAST,FIRST MI): "
F W !,prompt R val Q:val="" D
. I val'?1.A1",".1" "1.A.1(1" "1A) W !,"Invalid name"
. E S ^ZNAME(val)=""
F S val=$O(^ZNAME(val)) Q:val="" D
. W !,"You entered: ",val
Q
示例(使用GTM):
GTM>D readlist^ZZTEST
Enter a name (LAST,FIRST MI): first,last
Enter a name (LAST,FIRST MI): name,surname
Enter a name (LAST,FIRST MI):
You entered: first,last
You entered: name,surname
GTM>zwr ^ZNAME
^ZNAME("first,last")=""
^ZNAME("name,surname")=""