Julius Kavay · Sep 30, 2022 go to post

Hence I wrote to OP, quote from my answer, "you ask WRC for a 'WriteStream()' method" 

Julius Kavay · Sep 30, 2022 go to post

According to WebSocket protocol, the maximum payload size is (2**(8*8))-1 octets, if I recall it right.

Julius Kavay · Sep 30, 2022 go to post

The documentation of the %ToJSON() method is correct and yes, you can do 

 do obj.%ToJSON()
 

merely, this works only "on devices without protocol" like terminal, (sequential) file, etc. Everywhere, wehere the data bytes goes direct to the target. WebSocket isn't such a device. There is a "header part", with information fields like the command, masking, the length of the data, etc.

You have two possibilities, a) you ask WRC for a "WriteStream()" method or b) you handle the whole WebSocket by hand (is not impossible) or c) you change your application logic and send the those messages in chunks.

Julius Kavay · Sep 29, 2022 go to post

Yes, it would

kill
set $p(data,"x",2E6+1)=""
set dynArr=[].%Push(data).%Push(data).%Push(data)
set stream=##class(%Stream.GlobalCharacter).%New()
do dynArr.%ToJSON(stream)
try { set x=dynArr.%ToJSON() } catch e { write e.Name,! }
write stream.Size,!
write $length(data),!

The output is

<MAXSTRING>
6000010
2000000

As Steven Hobbs  wrote, the limit is only set by the size of the (virtual) memory.

Julius Kavay · Sep 28, 2022 go to post

It depends on two things,
a) the (user) interface, your user uses and (telnet, web, an application, etc)
b) where your inputs are handled (on server, on users device)
 

Julius Kavay · Sep 28, 2022 go to post

The only important thing is,  do they accept data with the arbitrary length. It's not of importance for you, how their API the  incomming data handles: as string, as longstring, as stream, as array of bytes, etc.

Julius Kavay · Sep 27, 2022 go to post

So one has a DEFAULT length of 50 and the other 3641144. But I thought more of the difference HOW MANY characters can they hold.

Julius Kavay · Sep 27, 2022 go to post

Just a dumb question, what is the very difference between %VarString and %String regarding the storable string length? As far as I know, both have a length limit of 3641144 characters.

Julius Kavay · Sep 27, 2022 go to post

I have nothing in common with HealtShare... but a property (Property rsXML As %String), like you mentioned, can hold up to 3.6E6 chars. If your data are longer then 3641144 characters then you definitely need to use streams (and if you intend to Base64 encode the data, then your data will be 33% longer)! You need to change the above property to something like

Property rsXML As %GlobalBinaryStream;

BUT this means, you have to adapt all your programs, methods, etc. where this property is in use!

That won't be a joy rather a pain

Julius Kavay · Sep 19, 2022 go to post

Hmm, ... will be difficult, but I give it a try

ClassMethod DNA(dna) As %String
{
	q $tr(dna,"CGAT","GCTA")
}
Julius Kavay · Sep 19, 2022 go to post

The spirit of the time... we have to save water, energy, etc. Maybe we should save bytes too...

   // instead of this line
   if (($zabs($a($e(s1,cnt)) - $a($e(s2,cnt))) '= 32)) { return 0 }
   // try this one
   return:$zabs($a(s1,cnt)-$a(s2,cnt))-32 0
Julius Kavay · Sep 19, 2022 go to post

That's is easy for the ASCII character set... (you didn't give any restrictions)

ClassMethod CheckOpposite(s1,s2) As %Boolean
{
    q $zb(s1," ",6)=s2
}
Julius Kavay · Sep 15, 2022 go to post

what you need is a SIMPLE compare of two strings

Set Ret=RSet.Execute()
set currentTS = $zdt($h,3)    // get onece the current timestamp
 While RSet.Next()
  { Set routeGuid="" 
Set nextScheduled=RSet.GetData(9)
//I $ZDATETIME($h,3,1)>nextScheduled S ^badis("datetime",Id)=$ZDATETIME($h,3,1)_"|"_nextScheduled
if currentTS ] nextScheduled S ^badis("datetime",Id)=currentTS_"|"_nextScheduled
}

In words: if currentTS follows (i.e. greater) nextScheduled - that's all.

Julius Kavay · Sep 14, 2022 go to post

If you can't find the methods Vitaliy mentioned because (for example) your Cache version is too old, you can always reinvent the wheel and write your own encoder/decoder method. Where is the problem? This snippet could be a starting point

Parameter Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

ClassMethod Base64Enc(x)
{
    s f=-$l(x)#3, x=x_$e($c(0,0),1,f), y=..#Base64, z="" zt:$ziswide(x) "WIDE"
    f i=1:3:$l(x) s a=$a(x,i)*256+$a(x,i+1)*256+$a(x,i+2), c=262144 f j=1:1:4 s z=z_$e(y,a\c+1), a=a#c, c=c\64
    s:f z=$e(z,1,$l(z)-f)_$e("==",1,f) q z
}
Julius Kavay · Sep 14, 2022 go to post

I assume, you want to change ALL ..#WhiteSpace chars to the delimiter, used by $piece()

  s $P(replace,",",$L(..#WhiteSpace) + 1)=""
Julius Kavay · Sep 13, 2022 go to post

Some comments...

(1) you can generate a string with the necessary commas, (2) also, the variable "l" is unnecessary and (3) after assigning to "m" the length of the first word, start the for-loop with the next (second) word...

According to problem description, the string will never be empty, so an early "q 0" is also not necessary and for the case, this happens, the first piece of the string will have a length of 0.

Parameter WhiteSpace = {$C(9,10,13,32,160)};

ClassMethod Short(t) As %Integer
{
  s t=$zstrip($TR(t,..#WhiteSpace,$tr($j("",$l(..#WhiteSpace))," ",",")),"<=>",",")
  s m=$L($P(t,","))
  f i=2:1:$L(t,",") {s n=$L($P(t,",",i)) s:n<m m=n}
  q m
}
Julius Kavay · Sep 13, 2022 go to post

You count the alpha-only words, "Let's, 21inc, ..." would't pass the check. So I changed your code to

ClassMethod findShort(s) As %Integer
{
 s s=" "_s_" " f i=1:1 { ret:s?@(".e1"" """_i_"anp1"" "".e") i }
}

I hope, it's OK...

Julius Kavay · Sep 13, 2022 go to post

In case, the shortest word is longer then  200 chars, than the result will be wrong. Instead of using a constant (200)

  s l=$L(t,","),m=200
  f i=1:1:l {s n=$L($P(t,",",i)) s:((n>0)&&(n<m)) m=n}

use a more generic approach

  s l=$L(t,","),m=$L($P(t,","))
  f i=2:1:l {s n=$L($P(t,",",i)) s:((n>0)&&(n<m)) m=n}

Also, removing the unnecessary delimiters (commas) simplifies the code too

ClassMethod Short(t) As %Integer
{
  s t=$zstrip($TR(t,$C(9,10,13,32,160),",,,,,"),"<=>",",")
  s m=$L($P(t,","))
  f i=2:1:$l(t,",") {s n=$L($P(t,",",i)) s:n<m m=n}
  q m
}
Julius Kavay · Sep 13, 2022 go to post

A small change (two bytes longer) to your solution makes it perfect, I think, for all cases

ClassMethod findShort(s) As %Integer
{
 f i=1:1 ret:$locate(" "_s_" "," [^ ]{"_i_"} ") i
}

BUT, and that's, what I want to say: this function is an awesome demonstration of economic nature of ObjectScript in comparison to Java. Your one-liner vs. a whole page of code... I love ObjectScript!

Sorry, that had to be said...

Julius Kavay · Sep 2, 2022 go to post

Take a look on the documentation of an (old) Cache instance (download the latest Cache 2018.x from WRC, if neccessary). There is a ZEN tutorial. You can follow the samples on IRIS, the ZEN classes are part of IRIS installation. Do not ask me for details, I have never used ZEN.

Julius Kavay · Aug 17, 2022 go to post

I'm sure, someone has a more elegant solution, anyway, I do it the quick-and-dirty way:

ClassMethod Lines(nsp = {$namespace})
{
    s (cls,sum)=""
    s glo=$na(^|"^"_##class(%SYS.Namespace).GetGlobalDest(nsp,"oddDEF")|oddDEF)
    f  {s cls=$o(@glo@(cls)),mth="" q:cls=""
        f  s mth=$o(@glo@(cls,"m",mth)) q:mth=""  s sum=sum+$g(^(mth,30))
    }
    q sum
}
Julius Kavay · Aug 15, 2022 go to post

The only tricky thing is the (web)management portal. Put the following few lines into a "test.html" file and the open it with your favorite browser.

<html>
<head></head>
<body>
A   simple  text     with    some spaces<br>
<pre>A   simple  text     with    some spaces</pre>
</body>
</html>

You see the difference?

Julius Kavay · Aug 15, 2022 go to post

Did you check this or are you just saying that? What does this query show?

select MyColumn, length(MyColumn) from TableA
Julius Kavay · Jul 27, 2022 go to post

You can take the line from your own code, but with a suitable parameter

Set BASE64=BASE64_file.Read(someCount) // someCount = aNumber * 3

For example 30000 instead of 32000. By the way, you read (8 bit) bytes, so there is no need to do the output-UTF8 conversion.

Julius Kavay · Jul 27, 2022 go to post

First of all, it's meaningless to post several KB of raw data. Either provide it somewhere for download or make an attachment (if possible).

Second, Base64 encodings converts 3 (incoming) bytes into 4 (outgoing) bytes, this means you always (except the last one) have to read multiple of 3 bytes at once, convert it, and put into the output stream. Your file.Read() reads 32000 bytes, which is NOT a multiple of 3!