Finding ErrorStack
Posted: Wed Apr 15, 2020 4:05 pm
Hi Wolfgang,
Thanks for Info!
Best regards,
Leonid
Thanks for Info!
Best regards,
Leonid
You need to convert the var to INT for this, with a (INT)dwVar. Here's the final version of the function, will add it to the runtime code now. Only had to do a few minor changes, to make it 100% compatible with VO. But if you prefer the behavior of your own version, you can simply leave it in your code as is and the compiler will always pick yours, insted of the one defined in the X# runtime. Thanks again for doing all the important work already!leon_ts wrote:I did dwActivation as a DWORD at first, but the XSharp compiler threw a cast error (StackFrame:FrameCount declared as INT). I did not do type casting, but simply did nActivation as INT (without control over negative values).
Code: Select all
FUNCTION ErrorStack(wActivation := 1 AS DWORD) AS STRING
LOCAL oStackTrace AS System.Diagnostics.StackTrace
LOCAL cResult := "" AS STRING
oStackTrace := System.Diagnostics.StackTrace{TRUE}
IF wActivation + 1 <= oStackTrace:FrameCount - 1
FOR VAR i := wActivation + 1 UPTO (oStackTrace:FrameCount - 1)
VAR oFrame := oStackTrace:GetFrame((INT)i)
VAR oMethod := oFrame:GetMethod()
VAR cStackLine := oMethod:Name:ToUpper()
VAR oInnerType := oMethod:DeclaringType
DO WHILE ( oInnerType != NULL )
IF !( oInnerType:Name == "Functions" )
cStackLine := oInnerType:Name:ToUpper() + ":" + cStackLine
ENDIF
oInnerType := oInnerType:DeclaringType
ENDDO
cStackLine += " (Line: " + oFrame:GetFileLineNumber():ToString() + ")" + CRLF
cResult += cStackLine
NEXT
ELSE
cResult := "*EmptyCallStack*" + CRLF
ENDIF
RETURN cResult
Code: Select all
METHOD Init(uActivation) CLASS Error
LOCAL dwActivation AS DWORD
IF IsNumeric(uActivation)
dwActivation := uActivation
ELSE
dwActivation:=0
ENDIF
SELF:Stack:=ErrorStack(dwActivation)
SELF:SubSystem := _ExecName()
RETURN SELF
yes, please!The VO Error class also assigns the ErrorStack() to the Stack field in the error object:
Do you want that in X# as well ?
Code: Select all
RETURN [""]
Code: Select all
RETURN ‘””’
Code: Select all
STATIC VOSTRUCT __QS_STACK
MEMBER DIM Item[0] IS __QS_STACK_ITEM
Code: Select all
STATIC VOSTRUCT __QS_STACK
MEMBER DIM Item[1] IS __QS_STACK_ITEM
Code: Select all
FUNC tOrdScope(nScope AS DWORD, xVal := _CHR(0)+_CHR(0) AS USUAL) AS USUAL PASCAL
IF xVal == _CHR(0)+_CHR(0)
Code: Select all
FUNC tOrdScope(nScope AS DWORD, xVal := #DOUBLEZERO AS USUAL) AS USUAL PASCAL
IF xVal == #DOUBLEZERO .OR. xVal == _CHR(0)+_CHR(0)
Code: Select all
STATIC FUNCTION UseAreaWithLockQuery(…, lpErrInfo REF ERRINFO) AS LOGIC PASCAL
Code: Select all
STATIC FUNCTION UseAreaWithLockQuery(…, lpErrInfo REF Error) AS LOGIC PASCAL
Code: Select all
VOSTRUCT _RDDLIST5
MEMBER uiRDDCount AS DWORD
MEMBER DIM atomRDDName[5] AS SYMBOL
Code: Select all
VOSTRUCT TRMINFODATA
MEMBER nArea AS DWORD
MEMBER dStartDate AS DATE
MEMBER dEndDate AS DATE
Code: Select all
VOSTRUCT TRMINFODATA
MEMBER nArea AS DWORD
MEMBER dStartDate AS DWORD // DATE
MEMBER dEndDate AS DWORD // DATE
Code: Select all
tid.dStartDate := DWORD(_CAST, dDate) and dDate := DATE(_CAST, tid.dStartDate)
Code: Select all
CASE IsFloat(xValue)
REAL8(pMD.uData.pData) := REAL8(xValue)
Code: Select all
pData AS BYTE PTR
Code: Select all
CASE IsFloat(xValue)
REAL8( PTR(_CAST, pMD.uData.pData) ) := REAL8(xValue)
Code: Select all
ptrErrInfo := _VODBErrInfoPtr()
ptrErrInfo.pszSubSystem := String2Psz("DBCMD")
ptrErrInfo.dwGenCode := EG_ARG
ptrErrInfo.dwSeverity := ES_ERROR
ptrErrInfo.lCanDefault := FALSE
ptrErrInfo.lCanRetry := TRUE
ptrErrInfo.lCanSubstitute := FALSE
ptrErrInfo.dwArgType := dwArgType
ptrErrInfo.dwArgNum := dwArgNum
oError := DefErrorGen(ptrErrInfo)
Code: Select all
ptrErrInfo := _VODBErrInfoPtr()
BREAK ErrorExec(ptrErrInfo)
Code: Select all
VODBRelation(wPos, @pszRelText)
VODBOrdSetFocus(cBagName, uOrder, @pszOrder)
Code: Select all
LOCAL lockList AS _LOCKLIST
IF VODBInfo(DBI_LOCKCOUNT, @nRecords)
nLockCt := nRecords
lockList := tDBInfo(DBI_GETLOCKARRAY)
Code: Select all
LOCAL dbsci IS _DBSCOPEINFO
Code: Select all
MemCopy(@dbOrdCondInfo.itmCobFor, @bFor, _SIZEOF(_ITEM))
Code: Select all
cS := MCompile(cExpr)
AAdd(a, {..., cS})
Code: Select all
RESOURCE APPLANGRES STRINGTABLE
BEGIN
...
END
Yes, I understand what to do in some situations and have already rewritten part of the code, which I mentioned in a previous post:robert wrote: STRUCTURE _RddList exists inside namespace XSharp.RDD.Support
here I meant using the _FieldNames class, which provides the XSharp languageRewriting VO structure _FIELDNAMES to XSharp class _FieldNames
Code: Select all
REAL8(<byte ptr>) := <real8value>
Code: Select all
FUNCTION Start AS VOID
LOCAL pTest IS dTest
pTest.d := (DWORD) Today()
? ptest.d
RETURN
VOSTRUCT dTest
MEMBER d AS DWORD
Code: Select all
FUNCTION Start AS VOID
LOCAL pData AS BYTE PTR
LOCAL r8Value AS REAL8
pData := MemAlloc(8)
r8Value := PI
// This does not compile. You have told the compiler that pData points to a series of bytes
// so you cannot use pData as a REAL8 PTR
//REAL8( pData) := r8Value
// This compiles. With the cast to PTR you are now telling the compiler that pData is a "untyped" pointer and
// then the compiler assumes you know what you are doing.
REAL8( (PTR) pData) := r8Value
? REAL8( (PTR) pData)
MemFree(pData)
wait
RETURN