Nueva publicación

Encontrar

Pregunta
· 25 abr, 2024

Complete novice question

I'm trying to learn M programing for an Epic db class prerequisite. They said to download the IRIS Studio software to do the testing. I'm having a very difficult time finding information the language. I'm trying to run some examples that Epic has provided (like in below) but the compiler complains that it isn't valid. Of course, it doesn't tell you why it isn't valid.

 

r !,"Enter the hour: ",hr  
 r !,"Enter the minute: ",min 
 r !,"Enter the second: ",sec 
 s Mtime=$$ConvertToMTime(hr,min,sec)
 w !,"Equivalent M time: ",Mtime  
 q
ConvertToMTime(h,m,s)
 q (h*3600)+(m*60)+(s)

I get these errors:

ERROR: zipcodevalidate.int(11) #8: <NOLINE>
 TEXT: s Mtime=$$ConvertToMTime(hr,min,sec)
ERROR: zipcodevalidate.int(14) #1026: Invalid command : 'ConvertToMTime(h,m,s)' : Offset:15
 TEXT: ConvertToMTime(h,m,s)

 

Would appreciate any guidance on why this doesn't work or some sources to better understand how to use Studio.

8 comentarios
Comentarios (8)4
Inicie sesión o regístrese para continuar
Artículo
· 25 abr, 2024 Lectura de 3 min

Making A Variable Watch Itself

I came up with a challenge for myself to come up with a way to make a variable watch itself for a certain value and do something when it hits that value without having to check it every time something touches it. Basically, a way to say "if at any point during the execution of this code, if x = 0 (or whatever the condition is) do this thing." The class I ended up with watches a %Status:

Class User.WatchedStatus Extends %RegisteredObject
{
Property sc As %Status [ InitialExpression = 1, SqlComputeCode = {set {*} = ##class(User.WatchedStatus).Reset({sc},{resetSelf})}, SqlComputed, SqlComputeOnChange = isErr ];
Property isErr As %Boolean [ InitialExpression = 0, SqlComputeCode = {set {*} = ##class(User.WatchedStatus).ErrCheck({sc},{writeSelf},{logSelf},{throwSelf})}, SqlComputed, SqlComputeOnChange = sc ];
Property throwSelf As %Boolean [ InitialExpression = 0 ];
Property logSelf As %Boolean [ InitialExpression = 0 ];
Property writeSelf As %Boolean [ InitialExpression = 0 ];
Property resetSelf As %Boolean [ InitialExpression = 0 ];

/// Handles status according to flags set, then sets isErr.
ClassMethod ErrCheck(sc, writeSelf, logSelf, throwSelf) As %Boolean [ Internal ]
{
	if $$$ISERR(sc){
		if writeSelf{
			write $SYSTEM.Status.GetErrorText(sc)
		}
		if logSelf = 1{
			do ##class(%Exception.StatusException).CreateFromStatus(sc).Log()
		}
		if throwSelf = 1{
			$$$ThrowStatus(sc)
		}
		quit 1
	}
	else{
		quit 0
	}
}

/// If resetSelf is true, resets the status code after error handling occurs.
ClassMethod Reset(sc, resetSelf) As %Status [ Internal ]
{
	return:resetSelf $$$OK
	return sc
}

/// flags is a string which determines status behavior when an error occurs
/// T = throw the status
/// L = log the status as an exception
/// W = write the status error text
/// R = reset status after error handling; if set, isErr goes back to 0 and sc goes back to 1
ClassMethod New(flags As %String) As User.WatchedStatus
{
	set status = ##class(User.WatchedStatus).%New()
	set flags = $ZCVT(flags,"U")
	set:(flags [ "T") status.throwSelf = 1
	set:(flags [ "L") status.logSelf = 1
	set:(flags [ "W") status.writeSelf = 1
	set:(flags [ "R") status.resetSelf = 1
	return status
}

}

If I create a new instance of this class using set status = ##class(User.WatchedStatus).New("wr"), then when I call methods that return a %Status, I can use set status.sc = (whatever method here) and if it returns an error status, it will write that status without me having to check if it's an error and tell it to do that every time, then reset itself for its next use. I also have a t or an l flag for if I want the status to throw itself or log itself as an exception in the system logs. (Note that if I didn't include the r flag, it wouldn't reset itself so that you could still check out the status code afterward.)

This uses SqlComputeCode in a way that it probably isn't meant to be used, and you have to be careful writing it this way. Since isErr computes itself on change of sc and sc computes itself on change of isErr, you could get yourself into a loop. That won't happen here because the the whole system will eventually settle again.

I'm not sure how much mileage everyone else will get out of this %Status example, but I'm documenting how I did it here anyway in case anyone else is ever trying to figure this out for a different kind of object.

Comentarios (0)1
Inicie sesión o regístrese para continuar
Comentarios (1)1
Inicie sesión o regístrese para continuar
Pregunta
· 25 abr, 2024

is there anyway to find the current UTC by city

We are using the IRIS cloud. and I am working on a DTL .

so the source side timestamp is  local time for example 20240110134740,  I know it is a local time. so the requirement is I need to append the UTC at the end, like -0400 or -0500 depending on if it is daylight saving time.  

so is there function to return if current day is at daylight saving time, so I can decide if I need to append the -400 or -500? or a function to return the current UTC by location? 

3 comentarios
Comentarios (3)2
Inicie sesión o regístrese para continuar
Artículo
· 25 abr, 2024 Lectura de 7 min

Guide de création d'une IA personnalisée avec ChatGPT en utilisant LangChain, étape par étape

En tant que modèle linguistique d'IA, ChatGPT est capable d'effectuer une variété de tâches telles que traduire, écrire des chansons, répondre à des questions de recherche et même générer du code informatique. Avec ses capacités impressionnantes, ChatGPT est rapidement devenu un outil populaire pour diverses applications, des chatbots à la création de contenu.
Mais malgré ses capacités avancées, ChatGPT n'est pas en mesure d'accéder à vos données personnelles. Mais malgré ses capacités avancées, ChatGPT n'est pas en mesure d'accéder à vos données personnelles. Ainsi, dans cet article, je vais démontrer les étapes suivantes pour construire une IA ChatGPT personnalisée en utilisant le LangChain Framework:

1 Comentario
Comentarios (1)1
Inicie sesión o regístrese para continuar