Find

Article
· Dec 18, 2024 3m read

第五十二章 File 输入 输出 - OPEN模式参数

第五十二章 File 输入 输出 - OPEN模式参数

OPEN 模式参数

可以通过以下两种方式之一指定 OPEN 模式参数
- 用引号字符括起来的字母代码字符串,如 “VRWN”。每个字母都指定一个参数。字母代码可以按任何顺序指定;因为 IRIS 按照从左到右的顺序执行它们,所以在某些情况下,字母代码之间的交互可能会决定首选顺序。
- 一系列 /keyword 参数,未加引号。这些参数用冒号分隔。关键字参数可以按任意顺序指定;因为 IRIS 以从左到右的顺序执行它们,所以在某些情况下,参数之间的交互可能会决定首选顺序。

指定字母代码参数和关键字参数的组合时,请先指定字母代码字符串,然后指定关键字参数,用冒号分隔。以下示例指定三个字母代码参数,后跟两个关键字参数,后跟 reclen 和 timeout 参数。

Discussion (0)1
Log in or sign up to continue
Article
· Dec 18, 2024 2m read

HTTPアウトバウンドアダプタを使用して、クエリパラメータとボディを両方送付する方法

開発者の皆さん、こんにちは。

試していたWebAPIでは、POST要求時クエリパラメータとボディの両方を送る必要がありましたので、HTTPアウトバウンドアダプタが提供するメソッド:Post()/PostFormDataArray()/PostURL() 辺りをドキュメントで確認していたのですが、残念ながら両方を渡せるように作成された丁度良いメソッドがありませんでした。

ドキュメント:HTTPアウトバウンドアダプタが提供するメソッド

では、どのように送ったかというと、SendFormDataArray()の第3引数を利用して両方の情報を送付してみました。

具体的には、SendFormDataArray()の第2引数にはHTTPメソッド(GET、POST、PUT、DELETEなど)第3引数に%Net.HttpRequestのインスタンスが渡せる仕様になっていましたので、クエリパラメータとボディを%Net.HttpRequestのインスタンスに設定し、第3引数に指定して実行する方法をとりました。

  set status=..Adapter.SendFormDataArray(.pHttpResponse,"POST",httprequest)
  if $$$ISERR(status) {
    return status
  }

変数httprequestの中身は以下のように作成しています

  set httprequest=##class(%Net.HttpRequest).%New()
  set httprequest.ContentType="application/json"
  set httprequest.ContentCharset="utf-8"
  //ボディの設定
  //..JTemplateプロパティにJSONダイナミックオブジェクトが設定されていると仮定
  do ..JTemplate.%ToJSON(httprequest.EntityBody)
  
  // QueryParameterの設定(..QueryParamプロパティにクエリパラメータが設定されていると仮定)
  for cn=1:1:$length(..QueryParam,"&") {
    set name=$piece($piece(..QueryParam,"&",cn),"=",1)
    set val=$piece($piece(..QueryParam,"&",cn),"=",2)
    do httprequest.SetParam(name,val)
  }

例では、クエリパラメータとボディを設定してますが、HTTP要求のヘッダに情報を追加したいときにも同様の方法が利用できます。
(HTTPヘッダを追加するには、SetHeader(キー,値)が利用できます。)

ヘッダ追加の参考情報:HTTP要求時の認証の指定

 

HTTPアウトバウンドアダプタを使用せず、シンプルにObjectScriptでHTTP要求を行う方法については以下ObjectScriptクックブックの例をご参照ください。

Discussion (0)1
Log in or sign up to continue
Announcement
· Dec 18, 2024

[Video] AI Governance in IT solutions

Hey Community!

Check out the new video dedicated to Gen AI on our InterSystems Developers YouTube:

⏯ AI Governance in IT solutions

Learn the approaches to the AI governance in healthcare IT projects:

  • Integrate AI into Existing Processes
  • Establish an AI Committee
  • Emphasize Pilots for Trust Building
  • Monitor Ongoing Use

These points provide a practical framework for responsibly adopting AI in healthcare.

🗣  Presenter@Don Woodlock, Vice President, Healthcare Solutions Development, InterSystems

Enjoy watching, and look forward to more videos! 👍

Discussion (0)1
Log in or sign up to continue
Announcement
· Dec 18, 2024

HealthShare Unified Care Record Overview-Virtual January 22-23, 2025 - Registration space available

  • HealthShare Unified Care Record Overview – Virtual January 22-23, 2025
    • The HealthShare Unified Care Record Overview course is a great way for anyone to become familiar with Unified Care Record, but especially those who need to understand its capabilities but not how to configure HealthShare Unified Care Record.
    • This is a non-technical, instructor-led in person training course providing a comprehensive introduction to HealthShare Unified Care Record.
    • This course is for anyone who needs to know about the functionality and architecture of HealthShare Unified Care Record.  (If you need information on configuring and troubleshooting Unified Care Record, consider the HealthShare Unified Care Record Fundamentals class.)
    • No prior knowledge or experience is required for the Overview class and any InterSystems employee may enroll.

 

Discussion (0)1
Log in or sign up to continue
Question
· Dec 18, 2024

The right side of a logical double AND (&&) riddle

References:

ObjectScript always follows strict left-to-right execution of arithmetic operators. 

The && operator evaluates the left operand and returns a value of FALSE (0) if it evaluates to a value of zero. Only if the left operand is nonzero does the && operator then evaluates the right operand. It returns a value of FALSE (0) if the right operand evaluates to a value of zero. Otherwise it returns a value of TRUE (1).

So here is a riddle then. Given the expression

write (1=0) && (1=0)

 we get the result "0", which is expected. But if we remove the parenthesis we should in theory (to my understanding) should get the same result, but we do not! We instead get "1" for the following

write 1=0 && 1=0

if this is truly left to right only operational procedence, then shouldn't it still be "0"?

1=0 && 1=0
0 && 1=0
0 (since the left side is 0, the right side shouldn't be evaluated according to docs)

But what appears to be happening is:
1=0 && 1=0
0 && 1=0
0=0

It was not clear that the right side of the `&&` operator does not extend past the "1" but literally checks only "0 && 1" and then continues to check "0=0"

I assumed that anything past a "&&" would be considered the "right side" and would exit early.
 

5 Comments
Discussion (5)2
Log in or sign up to continue