I have an (some ten years old) one which I use in the %ZSTART routine. Sometimes (for maintenance or whatever other reasons) you have to (re)start Cache and nowdays IRIS, but you want to start just some of the automatic processes listed in %ZSTART. If you forgot to disable those other before shutdown a init-file comes handy to disable things before start. A sample section looks like this:

[Start]
# 0 = do not start
# 1 = start
LoginServer = 1
UserLogin = 0
SystemTasks = 1
UserTasks = 0

I added some more comments to the class, you can download the InitFile.xml (class export) from my FTP server (which will be open for the next few days).

Addr: ftp.kavay.at
User: dcmember
Pass: member-of-DC

The general syntax for calling routines from another namespace is:

do label^|namesapce|routine

where

- you can omit the label and

- namespace is either the name of the namespace (like set namesapce="USER") or the path to the database (preceded by two carets), where the routine resides.

I see right now, Config.MapGlobals accesses the ^SYS global via the path to the database (take a look at the Storage section) - so in theory, you  can  call all classmethods from the above class as:

do zClassmethodname^|"%SYS"|Config.MapGlobals.1(args...)

merely, I do NOT recommend to do this (the cass is in deployed mode, so we do not know, what the code really does and (instance)methods are private, so you can't call them from outside).

First, the correct (or better) way for the above code snipet were:

new $NAMESPACE
zn "%SYS"
do ##class(Config.MapGlobals).Delete(...)
quit

second, one can call routines (and (class)methodes are compiled to rotines) from another namespace by using extended syntax, but in that case such a routine uses the globals (if the routine does a global access) from the CALLING namespace. In Your case this won't work because the Config.MapGlobals uses globals which resides in %SYS namespace and not in the namesspace you are in.

you miss the object reference!

set context.strDocumentEncoded = B64EncodeStream(request.streamPDF)
// ---------------------------^^^^^^^ this should be something
set context.strDocumentEncoded = ##(your.class).B64EncodeStream(request.streamPDF)

but you have another problems too: your context.strDocument and  context.strDocumentEncoded are currently STRING properties (according to the operation you try to do), which are limitet to a maxlength of 3.47MB!

You have to change both to a STREAM, so you can handle PDFs  larger then ca. 2.6MB (because 2.6 * 4 / 3 ==> 3.46MB, the limit for a string variable).

After you change context.strDocument and context.strDocumentEncoded to a stream properties, you could use this code:

Class DC.Someclass Extends %RegisteredObject
{

Parameter CHUNKSIZE = 2097144;

ClassMethod ToBase64(src As %Stream.Object, dst As %Stream.Object) As %Status
{
	i ..#CHUNKSIZE#3=0, src.Rewind(), dst.Rewind() {
		set sts=$$$OK
		while 'src.AtEnd,sts {
			do dst.Write($system.Encryption.Base64Encode(src.Read(..#CHUNKSIZE,.sts),1))
		}
	} else { set sts=$$Error^%apiOBJ(5001,"Chunksize or src/dst-problem") }
	
	quit sts
}

}
if ##class(your.class).ToBase64(context.strDocument,context.strDocumentEncoded) write "OK"

It seems, this task will take some time... you have to check, how context.strDocument is populated and  how context.strDocumentEncoded is later in code used. Good luck.

it looks like an OREF but it is just a string, try

set obj = [1,2]
write obj --> NN@%Library.DynamicArray
write $isobject(obj) --> 1
set ^myGlobal = obj
set obj=^myGlobal
write obj --> NN@%Library.DynamicArray
write $isobject(obj) --> 0

see also my answer in https://community.intersystems.com/post/handling-globalcharacterstream-production-service?page=1#comment-189746

As an ObjectScript routine, remove the "ClassMethod" keyword (which, as the name indicates, belongs to classes. Then either  add a "Public" keyword or you remove the brackets ("{", "}") too, but then all variables will have the same scope:

ProcData(file = "c:\temp\zipcitystate.csv") Public
{
    set str=##class(%Stream.FileCharacter).%New()
    do str.LinkToFile(file)
    while 'str.AtEnd {
        set $listbuild(ZIP,CITY,STATE)=$listfromstring(str.ReadLine())
        
        // now you have the individual columns
        // in ZIP, CITY and STATE variables for further processing
        write "Zip=",ZIP,?12,"City=",CITY,?40,"State=",STATE,!
    }
    
    // depending on the way of your implementation, a "kill str"
    // would be needed to free up the file
    kill str
}

Oh, and to invoke the above procedure just do a:

do ProcData^YourRoutineName()
// or
do ProcData^YourRoutineName("path-to-file")

A simple method like


ClassMethod ProcData(file = "c:\temp\zipcitystate.csv")
{
    set str=##class(%Stream.FileCharacter).%New()
    do str.LinkToFile(file)
    while 'str.AtEnd {
        set $listbuild(ZIP,CITY,STATE)=$listfromstring(str.ReadLine())
        
        // now you have the individual columns
        // in ZIP, CITY and STATE variables for further processing
        write "Zip=",ZIP,?12,"City=",CITY,?40,"State=",STATE,!
    }
    
    // depending on the way of your implementation, a "kill str"
    // would be needed to free up the file
    kill str
}

to do the job. Then call the method as

do ##class(your.class).ProcData()
// or
do ##class(your.class).ProcData("path-to-the-file")

To get all the jobGUIDs you need two loops:

f i=1:1:list1.Size f j=1:1:list1.GetAt(i).sensors.Size w list1.GetAt(i).sensors.GetAt(j).jobGUID,!
0b955ee7-9a54-4b13-9af1-7019721faeab
8f9e85ab-31e7-4835-8969-6d72d142a2f1
68cea9d3-54cd-43f2-ae37-aaf47ed43e6b
7602764e-8951-451f-9653-ceb84834a1a6
88d2e472-a1e4-40b3-a108-f2d32a2023e5
116f2ac6-da5f-46da-a7c7-92d9eaf98c89
a878e527-f519-4aaa-bf5d-0d65f72de119
be570b14-0555-4b86-ab9f-e37c40c79216
3a13e243-d6ed-4788-98b2-52e9213bee00
54969869-c4f6-43f6-a74a-2a67f9a73fc5
700af7d3-77b3-4a84-ba11-ea49602d6558
18dc3370-c291-468b-af1f-0361d95bb02c
35d0d2e7-1199-4c18-8941-4fff6dbdba1f
8044560c-94d2-4da7-87f5-07328d9e62c1
b636a2f5-d35f-4c82-9646-e09572336e23
9c9a4bf4-e8af-4b8d-9de2-a99cdff150ed
a576d235-6eb6-4312-a1ff-7b1f767b88ce
654cf21e-daad-4a11-b676-86a7bc8a3360
2be4efc8-6616-4bff-87ba-30fe388a1b34
a5374d6c-311c-44d0-8d06-3a31f33dd3a8
955529c5-36be-4f3e-b768-0e3b377804a7
60a7cdb0-499e-4d02-b4d3-06ee58e40481
e84eda78-1491-49af-9e34-d647e817a251
9bcd5fe6-6f05-4482-ad78-612f35c60b41

Try this one. The idea is, find the state (including the separators), everything before is the city and everything after is the zip code. Then we remove the separator chars (whitespaces, commas and dots).

ClassMethod Disjoin(data, cty, sta, zip)
{
    i $locate(data,"(\s|,|\.)[A-Za-z]{2}(\s|,|\.)",3,,sta) {
        s $lb(cty,zip)=$lfs(data,sta), sta=$$s(sta), cty=$$s(cty), zip=$$s(zip)
        
    } else { s (cty,sta,zip)="" }
    
    q sta]""
    
s(x)	q $zstrip(x,"<>w",",.")
}
Some examples
i ##class(DC.Test).Disjoin("CANTON,TX.,75103",.c,.s,.z) w c,", ",s,", ",z --> CANTON, TX, 75103
i ##class(DC.Test).Disjoin("MILFORD, OH 45150",.c,.s,.z) w c,", ",s,", ",z --> MILFORD, OH, 45150
i ##class(DC.Test).Disjoin("MILFORD OH 45150",.c,.s,.z) w c,", ",s,", ",z --> MILFORD, OH, 45150
i ##class(DC.Test).Disjoin("KANSAS CITY, MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> KANSAS CITY, MO, 12345
i ##class(DC.Test).Disjoin("KANSAS CITY MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> KANSAS CITY, MO, 12345
i ##class(DC.Test).Disjoin("ST. LOUIS MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> ST. LOUIS, MO, 12345
i ##class(DC.Test).Disjoin("  ST. LOUIS MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> ST. LOUIS, MO, 12345

OK, something like this gives a wrong result...
i ##class(DC.Test).Disjoin("   ST. LOUIS MO, 12345",.c,.s,.z) w c,", ",s,", ",z --> , ST, LOUIS MO, 12345

Class DC.Test Extends %RegisteredObject
{
/// Return TRUE if val contains an string
ClassMethod IsString(val) As %Boolean
{
    q $a($lb(val),2)<3
}
/// Return TRUE if val contains a number (int, real or double)
ClassMethod IsNumber(val) As %Boolean
{
    q $a($lb(val),2)>3
}
}

w ##class(DC.Test).IsString("abc") //--> 1
w ##class(DC.Test).IsString("123") //--> 1
w ##class(DC.Test).IsString(123) //--> 0
w ##class(DC.Test).IsNumber(123) //--> 1
w ##class(DC.Test).IsNumber("abc") //--> 0
w ##class(DC.Test).IsNumber("123") //--> 0
w ##class(DC.Test).IsNumber(123_345) //--> 0
w ##class(DC.Test).IsNumber(123+345) //--> 1
w ##class(DC.Test).IsString(123_456) //--> 1
w ##class(DC.Test).IsString(123+456) //--> 0

s x=123, y="123"
w ##class(DC.Test).IsString(x) //--> 0
w ##class(DC.Test).IsString(y) //--> 1

I'm quite shure, the above code won't work as expected, or with the words of Joseph Weizenbaum: “A computer will do what you tell it to do, but that may be much different from what you had in mind.”

The content of your myf variable is always 0 (the result of comparing nullstring with a filename), the size of tmpFile stream is also 0 (you never write into the stream).

Sometimes it's faster to write a "oneliner" to solve a simple problem then searching and downloading a solution from openexchange or from whereever... That's the beauty of the ObjectScript.

And if you think, the oneliner is worth to be reused, then make it to a method, add some small adjustments for a general usability...

The oneliner

s str="",tmp=##class(%File).TempFilename("txt") o tmp:"NWRU":0 i $t { u tmp zw ^||fruit s s=$zpos r:'$zseek(0) str#s c tmp:"D" }

The more general version

ClassMethod ToString(ref,max=32000)
{
    s tmp=##class(%File).TempFilename("txt") o tmp:"NWRU":0 q:'$t ""
    u tmp zw @ref s siz=$zpos r:'$zseek(0) str#$s(siz>max:max,1:siz) c tmp:"D" q str
}

Use it as

write ##(your.class).ToString($na(^||fruit))


The simplest way is to create a classmethod, which returns the desired name:

Class DC.Evgenys.Data Extends %Persistent
{
/// which: 0=Fullname, 1=Schemaname, 2=Tablename
ClassMethod TableName(which = 0) [ CodeMode = objectgenerator ]
{
    set sch=%compiledclass.SqlSchemaName, tab=%compiledclass.SqlTableName
    do %code.WriteLine($c(9)_"quit $p("""_sch_"."_tab_","_sch_","_tab_""","","",which+1)")
    quit $$$OK
}
}

So you can do something like this:

for i=0:1:2 write ##class(DC.Evgenys.Data).TableName(i),!
DC_Evgenys.Data
DC_Evgenys
Data