ObjectScript

Syndicate content 31 

Points to remember before you start: 

  1. It is not possible in a COS (Caché Object Script) job/process context to have multiple Named Pipes. It is a one Named Pipe per job/process limited line of communication. 

  1. Named Pipes, in Caché, like most pipes on most operating systems are Unidirectional. That means you open them for either Read or Write, but not both. 

+ 2   0 2
0

comments

355

views

+ 2

rating

Hello guys,

I've got this piece of code which runs the method "WebMethod", that belongs to %SOAP.WebBase.cls.

It grabs the outcome from an internal webservice we have and after that, it writes into a file.

The thing is, when I browse the file contents, I realize that in the place where a special character should be, I see a question mark.

By querying the same webservice from a special soap tool called "SoapSonar" (I've been using this for years), the outcome shows up this special character (shows it properly).

So I wonder... is there kind of encoding parameter I could use within the "WebMethod", so it'd return the correct output?

--

Last answer 31 January 2017 Last comment 2 February 2017
+ 1   0 2
2124

views

+ 1

rating

Have you ever thought what could be a reason why some development environment (database, language) would eventually become popular? What part of this popularity could be explain as language quality? What by new and idioms approaches introduced by early language adopters? What is due to healthy ecosystem collaboration? What is due to some marketing genius

Last comment 17 January 2017
+ 9   0 1
666

views

+ 9

rating

So I know it's been a while, and I hate to let my adoring fans down... just not enough to actually start writing again.  But the wait is over and I'm back!  Now bask in my beautiful ginger words!

For this series, I am going to look at some common problems we see in the WRC and discuss some common solutions.  Of course, even if you find a solution here, you are always welcome to call in and expression you gratitude, or just hear my voice!

This week's common problem: "My query returns no data."

Now, supposedly you've checked that your query SHOULD return data.  That is, if you do a "SELECT * FROM MyTable" and don't get back any data, I don't expect that your more complicated query with JOINs, a WHERE clause, and a GROUP BY will either.  So, if you've determined that the data lives in your table what else could be going wrong?

 

1) You're in the wrong namespace.

Last comment 16 January 2017
+ 7   0 2
276

views

+ 7

rating

Is there a way to have a Data Lookup table be automatically updated via a script or cache code? We have a file that is being created by our EMR, and we need to import it into Ensemble to update it. Just trying to see if we can automate this process.

 

Thanks

Scott Roth

Ohio State University Wexner Medical Center

Last answer 11 January 2017 Last comment 11 January 2017
0   0 0
472

views

0

rating

Cache rendering of an old classic:

 s enc="dQZ4nK1VzU7DMAy+I/EEveTcCWicpt3UU2VABTRA/AhBeYW+As/U7vE4VNhxypJuoAlhS1vixJ//"_
 "06TNsy5p4TppzRKTNqtMXuXQjSSrdEPSEmmtK1uZssp1l0Z3nHJ9fEQroJURlQLHNE35WPYWx7N3"_
 "YpJYkeRe4mQzkEKuGDwjkHTBP+9JW4oUsB+Y2CVj2JuttlkFAbhbfdIuRU/jhvZkryejtNok7UpO"_
 "Moww3JbdcPifW8APosVi4Q9Otwck5LMojmKOojNnDUIXe0XEvnVrdaEeiF95H8BYgXG38o6i0Vpg"_
 "lhSO00TVkN6VelRPaq1q9ehucnizrGopJ5TY+8zHzOBSPih8jjnLQWbyKSYy25Cpe+JXMTdM2dZS"_
 "cbAu3YP42EQw4GOq1a16VjfEtWoCGHJdS5dAjkPoYgRTCsw8DG4MaSAw2G++KfA6So0v9xTJVmHD"_
 "0UjTAeD4TQ7oRr1EMMbXm2N6IyO1AxtDLS2NCBqHiCIYX+9hLxGGtCxk2Me0D8Q5eknNcafW0j47"_
 "SiBNqVcYTSHEM3ASTfwvogDB4qFKc9G+YTzYg4yfqYyfqd2M6O6KqnOh3vgaK1SHIP8403/IitX/"_
 "khVb/JYVkBdCh4/53gmCHyZoh3kApk/BrNdcOsBMDzb/hCPEI+zfA/fnvjTWnn8BUo3vtEE=" 
 s enc=$SYSTEM.Util.Decompress($SYSTEM.Encryption.Base64Decode(enc))
 w enc

Share more ANSI art!

Merry XMas and a Happy New Year!

Last comment 31 December 2016
+ 16   0 9
627

views

+ 16

rating

I was benchmarking the populate utils when I noticed something strange. Consider this simple benchmarking method:

ClassMethod runBench(count As %Integer = 300000)
{
        s types=["name","ssn","company","title","phone","city","street","zip","mission","state","color","product","string","integer","float"]
        //s types=["name","ssn"]
        s iter=types.%GetIterator()
        while iter.%GetNext(.key,.value){
            s start=$P($ZTS,",",2)
            s opt={}
            s opt.type=value
            for i=1:1:count{
                s res=##class(DataGen.Generator).genVal(opt)            }
            s end=$P($ZTS,",",2)
            s total=end-start
            w value_$C(9)_" total time:"_total_$C(9)_" rate:  "_$NORMALIZE(count/total,2)_" per second",!
        }
}

With my genVal method being this

+ 4   0 2
0

comments

264

views

+ 4

rating

Hi, community!

Consider you need to exclude substring(s) from a string.

I did it with the following snippet:

/// excludes all the substrings from the string
ClassMethod ExcludeSubstring(substr,str as %String) As %String

{

 while ($L(str,substr)>1) {

 set str=$Piece(str,substr)_$Piece(str,substr,2,*)

            }

 quit str

}

 

So, for example:

USER> set str=”ExcludemeGoodstringExcludemeExcludemeGoodstring” w ##class(User.Utils).ExcludeSubstring(“Excludeme”,str)

GoodstringGoodstring

 

Is this the optimal approach or I reinvented the wheel?

Last answer 18 December 2016 Last comment 18 December 2016
0   0 0
234

views

0

rating

Does anyone have a good example of using %Net.SSH.Session  to do a scp copy of a file from one server to another? I tried calling do $ZF(-1,"scp /ensemble/Scott/sr1.dat egate@inteng3:/home/egate/Scott/") but did not have any success in getting the system to copy the file over to what I am calling inteng3.

Thanks

Scott

Last answer 9 December 2016 Last comment 12 December 2016
0   0 1
365

views

0

rating

How can I prevent large number truncation when using the DynamicObject and DynamicArray classes to create JSON in objectscript and then parsing the result in javascript. Are there any global settings that configure the output when using these classes?

 

I am looking at converting to the new DynamicObject and DynamicArray classes to build JSON. Our current (homegrown) JSON library forces string representation of numbers too long because of errors we were seeing with long numbers being truncated on the client, I am hoping to accomplish the same with the new classes.

 

USER>set longNum = 1234567890123456789
 
USER>w longNum
1234567890123456789   //valid cache  number, 19 digits
USER>s arr = [(longNum)]  
 
USER>w arr.%ToJSON()
[1234567890123456789]   //Valid JSON, however I would like this to be a quoted string so it can be parsed in javascript

//Parsed in javascrip

Last comment 9 December 2016
0   0 3
0

answers

431

views

0

rating

Is there any way that I can check the native type of an object script variable? (similar to the typeof check in javascript)

 

I see that the DynamicArray class uses the type of the variable for its output, I would like to do something similar when I receive a value as an argument to my method.

USER>s var1 = 123  //No quotes, number type
 
USER>s var2 = "123" //quotes, string type
 

//DynamicArray can tell the difference
USER>s arr = []
 
USER>d arr.%Push(var1)
 
USER>d arr.%Push(var2)
 
USER>w arr.%ToJSON()
[123,"123"] //first value is output without quotes, second value is quoted

 

Last answer 9 December 2016
+ 1   0 2
0

comments

275

views

+ 1

rating

Class Queries in InterSystems Caché is a useful tool that separates SQL queries from Caché Object Script code. Basically, it works like this: suppose that you want to use the same SQL query with different arguments in several different places.In this case you can avoid code duplication by declaring the query body as a class query and then calling this query by name. This approach is also convenient for custom queries, in which the task of obtaining the next row is defined by a developer. Sounds interesting? Then read on!

Last comment 9 December 2016
+ 14   0 9
3782

views

+ 14

rating

Using the following...

//Get PDF stream object previously saved
   Set pdfStreamContainer = ##Class(Ens.StreamContainer).%OpenId(context.StreamContainerID)
   Try {
     Set pdfStreamObj = pdfStreamContainer.StreamGet()
   }
   Catch {
      $$$TRACE("Error opening stream object ID = "_context.StreamContainerID)
      Quit
   }

Would it be possible to search the pdfStreamObj for certain values like a Medical Record, or Patient Name?

Thanks

Scott

Last answer 8 December 2016
0   0 3
0

comments

305

views

0

rating

Hi,

Thanks for your time.

Plain $ZF(-1) and $ZF(-2) calls from Cache Studio or Terminal have stopped launching the OS shell from Win10.

cmd (Windows Command Prompt) should be launched.

Configuration:

Windows 10 Anniversary Update, Ensemble 2016.2.0.585.0 Developer Edition x64

Is this common? I have enabled both %Developer role and a Cache CallOut privilege for all users that operate in this scenario.

In Terminal, W $ZF(-1) prints -1, W $ZF(-2) prints -1

In Studio, W $ZF(-1) hangs the IDE, W $ZF(-2) prints 0

In all four cases, cmd (Windows Command Prompt) is not launched!

Any ideas, anybody?

Thanks in advance. :-)

Last answer 8 December 2016 Last comment 8 December 2016
0   0 1
458

views

0

rating

We don't often use SQL within our org, which is mostly due to the performance issue we experience due to the quantity of data we are reviewing.

Aside from the standard performance measures for non-Caché databases, are there any recommended approaches when querying large tables?

The table would have roughly 50M records, but there are not a finite amount of sub-nodes.

Last answer 2 December 2016 Last comment 6 December 2016
0   0 4
443

views

0

rating

I would like to integrate SQL into our ObjectScript routines in order to illustrate how SQL can be used to minimize development time. However, there are two questions I have.

  1. How does one iterate through the results of a SELECT statement?
  2. How does one access a Table in another namespace?
Last answer 22 November 2016
+ 1   0 1
0

comments

742

views

+ 1

rating

Importance and Collection of Exact Version Information ($zv / $zversion)
 
The explanation of:
- why collecting $zv is important (The WHY),
- what the components of $zv mean (The WHAT),
- and how to collect $zv (The HOW). 
(The Ultimate $zv Guide to the ISC Galaxy in large, friendly letters)
Last comment 15 November 2016
+ 13   0 7
758

views

+ 13

rating

A new Health Connect customer has a few experienced Java folks on their interface team. As they get more into Health Connect and learn Caché ObjectScript they thought it would be useful to have a list of common Java statements with an equivalent statement in ObjectScript. They mentioned string manipulation as an example, but would be interested in other areas as well.
 
This seems like something that is probably already floating around somewhere. Does anyone have something like this or other "COS jumpstart for Java devs" materials?

Thanks,
Marc

 

Last answer 14 November 2016
+ 1   0 1
0

comments

223

views

+ 1

rating

Environment: Cache for Windows (x86-64) 2015.2.2 (Build 811U) Thu Mar 3 2016 12:55:48 EST [HealthShare Modules:Core:14.01.351 

When try the following to send back SOAP Fault, is the following correct way?

Set fault=##class(%SOAP.Fault).%New()
Set fault.faultcode=$$$FAULTServer
Set fault.faultstring="Processing Error"
Set fault.detail= "Error on server"
Do ..ReturnFault(fault)

Got the error 

Last answer 8 November 2016
0   0 0
0

comments

251

views

0

rating

Here are a few examples of conversions and operations you might need, along with links to documentation where you can learn more.

At the time I wrote this, Eastern Daylight Time was in effect for my Caché system.

How Caché keeps the time and date

Caché has a simple time format, with a longer range of recognized dates compared to some other technologies.

The current time is maintained in a special variable $HOROLOG ($H):

USER>WRITE $H

64146,54027

USER>

The first integer is the count of days since December 31, 1840. The second integer is the count of seconds since midnight of the current day.

You can also obtain the current time and date with $SYSTEM.SYS.Horolog()

Last comment 7 November 2016
+ 4   0 6
4463

views

+ 4

rating

Here's an easy one for you; before I spend another hour looking for the answer, how do you convert %ArrayOfDataTypes to an array (that could, say, fit into the %session.Data array, or maybe just some array named info()), and of course back again?

NS>s aodt=##class(%ArrayOfDataTypes).%New()
 
NS>w aodt.SetAt("lcavanaugh","username")
1
NS>w aodt.SetAt("organization","coolcompany")
1
NS>w ##class(%ArrayOfDataTypes).BuildValueArray(aodt,.array)
 
<LIST>zBuildValueArray+1^%Library.ArrayOfDataTypes.1

aodt must be serialzed.  What?

NS>zw array

NS>

Last answer 4 November 2016 Last comment 4 November 2016
0   0 1
380

views

0

rating

I try to run the cmd command in the studio terminal, but i am getting the <NOTOPEN> Error.

Even ZF(-1) also not working. Any help, Please!!!

 

Note: i restart the Cache instance service with full privilege

 

Code:

Set Path="mkdir E:\Sample\New"

Open Path:"QR":10

Error:<NOTOPEN>

 

This command working on my PC, but on server throws error.

 

Many Thanks

Last answer 4 November 2016 Last comment 4 November 2016
0   0 2
283

views

0

rating