Finding ErrorStack
Finding ErrorStack
Hi 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
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Finding ErrorStack
Guys,
The VO Error class also assigns the ErrorStack() to the Stack field in the error object:
Do you want that in X# as well ?
Robert
The VO Error class also assigns the ErrorStack() to the Stack field in the error object:
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
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Finding ErrorStack
Hi Robert,
Thank you very much!
Wolfgang
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 ?
Thank you very much!
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Finding ErrorStack
Hi Robert,
Yes, the more original VO classes match themselves in XSharp, the better. Especially if the project properties specify VO Dialect.
Yesterday I finally started a full-fledged transporting of the projects of the main (huge) working projects from VO to XSharp. While it’s hard. The compiler throws a lot of errors. It’s easy to cope with some (DATE type in structures, some types of PCALL, etc.), and some take longer (for example, almost all structures associated with DB * became classes, and I have to not just edit, but redo the code). The ERRINFO structure is now missing, _VODBErrInfoPtr returns an Exception. All this has to be rewritten. And so far it has taken only one small AEF, and there are about 100 more such ones (much larger in terms of code).
Best regards,
Leonid
Yes, the more original VO classes match themselves in XSharp, the better. Especially if the project properties specify VO Dialect.
Yesterday I finally started a full-fledged transporting of the projects of the main (huge) working projects from VO to XSharp. While it’s hard. The compiler throws a lot of errors. It’s easy to cope with some (DATE type in structures, some types of PCALL, etc.), and some take longer (for example, almost all structures associated with DB * became classes, and I have to not just edit, but redo the code). The ERRINFO structure is now missing, _VODBErrInfoPtr returns an Exception. All this has to be rewritten. And so far it has taken only one small AEF, and there are about 100 more such ones (much larger in terms of code).
Best regards,
Leonid
Best regards,
Leonid
Leonid
Finding ErrorStack
HI Leonid,
Can you please give us some exact samples of the things that are not working in X#? Maybe it will not be necessary to actually rewrite (some of) this code...
Can you please give us some exact samples of the things that are not working in X#? Maybe it will not be necessary to actually rewrite (some of) this code...
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Finding ErrorStack
Hi Chris,
Errors are very different. In most cases, this is unmanaged code or very old code that started its life from Clipper and reached VO 2.8. The generation of programmers has already changed in our team, and some of the people who wrote this code no longer work for us (in retirement).
I will start in order of errors:
1. XS9002 Parser: unexpected input
Original Code:
Replaced by:
2. XS1665 Fixed size buffers must have a length greater than zero
Original Code:
Replaced by:
3. XS0182 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
Original Code:
Replaced by:
4. XS0246 The type or namespace name 'ERRINFO' could not be found (are you missing a using directive or an assembly reference?)
Original Code (this function as the first one and many others with the same error):
Replaced by (with rewriting internal and external code that interact with lpErrInfo):
5. XS1663 Fixed size buffer type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double
Original Code:
Replaced by: need to rewrite to class _RddList
6. XS9027 VoStruct member type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float, double, ptr, psz or vostruct
Original Code (and same other):
Replaced by (with rewriting internal and external code that interact with dStartDate and dEndDate):
example
7. XS0030 Cannot convert type 'byte*' to 'real8'
Original Code:
*
Replaced by:
8. XS0103 The name 'DefErrorGen' does not exist in the current context
Original Code:
Replaced by (nothing yet)
9. XS0029 Cannot implicitly convert type 'System.IntPtr' to 'XSharp._FieldNames'
Rewriting VO structure _FIELDNAMES to XSharp class _FieldNames
10. The name 'ErrorExec' does not exist in the current context
Original Code:
11. XS1503 Argument 2: cannot convert from 'PSZ' to 'string'
Original Code (and other same):
and etc.
12. XS0246 The type or namespace name '_LOCKLIST' could not be found (are you missing a using directive or an assembly reference?)
Original Code:
13. XS0246 The type or namespace name '_DBSCOPEINFO' could not be found (are you missing a using directive or an assembly reference?)
Original Code:
14. XS0246 The type or namespace name '_ITEM' could not be found (are you missing a using directive or an assembly reference?)
Original code:
15. XS0029 Cannot implicitly convert type 'XSharp._Codeblock'
Original Code (and other same):
16. XS0103 The name '_DynCheck' does not exist in the current context
17. XS0246 The type or namespace name '_GCDUMP' could not be found (are you missing a using directive or an assembly reference?)
18. PCALL(...)
19. And one more big problem with language resources.
we are using LoadResString(...)
xPorter does not convert string table:
And many more simple little things in the form of errors and warnings (cast and etc.)
This is only the first AEF. I don’t know what will happen next.
Best regards,
Leonid
Errors are very different. In most cases, this is unmanaged code or very old code that started its life from Clipper and reached VO 2.8. The generation of programmers has already changed in our team, and some of the people who wrote this code no longer work for us (in retirement).
I will start in order of errors:
1. XS9002 Parser: unexpected input
Original Code:
Code: Select all
RETURN [""]
Code: Select all
RETURN ‘””’
Original Code:
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
Original Code:
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)
Original Code (this function as the first one and many others with the same error):
Code: Select all
STATIC FUNCTION UseAreaWithLockQuery(…, lpErrInfo REF ERRINFO) AS LOGIC PASCAL
Code: Select all
STATIC FUNCTION UseAreaWithLockQuery(…, lpErrInfo REF Error) AS LOGIC PASCAL
Original Code:
Code: Select all
VOSTRUCT _RDDLIST5
MEMBER uiRDDCount AS DWORD
MEMBER DIM atomRDDName[5] AS SYMBOL
6. XS9027 VoStruct member type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float, double, ptr, psz or vostruct
Original Code (and same other):
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)
Original Code:
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)
Original Code:
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)
9. XS0029 Cannot implicitly convert type 'System.IntPtr' to 'XSharp._FieldNames'
Rewriting VO structure _FIELDNAMES to XSharp class _FieldNames
10. The name 'ErrorExec' does not exist in the current context
Original Code:
Code: Select all
ptrErrInfo := _VODBErrInfoPtr()
BREAK ErrorExec(ptrErrInfo)
Original Code (and other same):
Code: Select all
VODBRelation(wPos, @pszRelText)
VODBOrdSetFocus(cBagName, uOrder, @pszOrder)
12. XS0246 The type or namespace name '_LOCKLIST' could not be found (are you missing a using directive or an assembly reference?)
Original Code:
Code: Select all
LOCAL lockList AS _LOCKLIST
IF VODBInfo(DBI_LOCKCOUNT, @nRecords)
nLockCt := nRecords
lockList := tDBInfo(DBI_GETLOCKARRAY)
Original Code:
Code: Select all
LOCAL dbsci IS _DBSCOPEINFO
Original code:
Code: Select all
MemCopy(@dbOrdCondInfo.itmCobFor, @bFor, _SIZEOF(_ITEM))
Original Code (and other same):
Code: Select all
cS := MCompile(cExpr)
AAdd(a, {..., cS})
17. XS0246 The type or namespace name '_GCDUMP' could not be found (are you missing a using directive or an assembly reference?)
18. PCALL(...)
19. And one more big problem with language resources.
we are using LoadResString(...)
xPorter does not convert string table:
Code: Select all
RESOURCE APPLANGRES STRINGTABLE
BEGIN
...
END
This is only the first AEF. I don’t know what will happen next.
Best regards,
Leonid
Best regards,
Leonid
Leonid
Finding ErrorStack
Leonid,
You seem to be doing a lot of low level stuff in that AEF.
Please download the Runtime source and check for the types that you are missing. Many of the RDD related structs are still there but may have been changed to a class or you need to include a namespace to use them.
Some examples:
STRUCTURE _RddList exists inside namespace XSharp.RDD.Support
CLASS DbScopeInfo exists in the same namespace
_ITEM is no longer needed (look at the implementation of CLASS DbOrderCondInfo ). itmCobFor is now ForBlock as ICodeblock
DefErrorGen() is indeed not there. In VO there was an error structure and an error class. We only have an error class.
The Lock array is now returned as a managed array of Int32 values
and more.
If you need help, you can also send us your code and we might be able to get you started quicker.
Robert
You seem to be doing a lot of low level stuff in that AEF.
Please download the Runtime source and check for the types that you are missing. Many of the RDD related structs are still there but may have been changed to a class or you need to include a namespace to use them.
Some examples:
STRUCTURE _RddList exists inside namespace XSharp.RDD.Support
CLASS DbScopeInfo exists in the same namespace
_ITEM is no longer needed (look at the implementation of CLASS DbOrderCondInfo ). itmCobFor is now ForBlock as ICodeblock
DefErrorGen() is indeed not there. In VO there was an error structure and an error class. We only have an error class.
The Lock array is now returned as a managed array of Int32 values
and more.
If you need help, you can also send us your code and we might be able to get you started quicker.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Finding ErrorStack
Hi Robert,
Thanks for answer!
and etc.
Just a lot of routine work ahead. But I understand that this work cannot be avoided.
But as for the DATE type in structures, then, probably, it is easy to support it by means of the language? It is easily converted to DWORD.
The same applies to BYTE PTR, because in fact it is a variation of PTR. And it seems to me can be compiled without errors.
Best regards,
Leonid
Thanks for answer!
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
and etc.
Just a lot of routine work ahead. But I understand that this work cannot be avoided.
But as for the DATE type in structures, then, probably, it is easy to support it by means of the language? It is easily converted to DWORD.
The same applies to BYTE PTR, because in fact it is a variation of PTR. And it seems to me
Code: Select all
REAL8(<byte ptr>) := <real8value>
Best regards,
Leonid
Best regards,
Leonid
Leonid
Finding ErrorStack
Leonid,
VOSTRUCT is only in the product to interface with WIN32 API calls. The DATE type (which is actually the XSharp.__Date structure) has no meaning for Win32 API functions. So what are you using this for ?
If you declare the element in the the structure as DWORD you should be able to assign the Date to it if you cast it to a DWORD first:
W.r.t. the problem with the REAL8 values, try this:
USING System.IO
Robert
VOSTRUCT is only in the product to interface with WIN32 API calls. The DATE type (which is actually the XSharp.__Date structure) has no meaning for Win32 API functions. So what are you using this for ?
If you declare the element in the the structure as DWORD you should be able to assign the Date to it if you cast it to a DWORD first:
Code: Select all
FUNCTION Start AS VOID
LOCAL pTest IS dTest
pTest.d := (DWORD) Today()
? ptest.d
RETURN
VOSTRUCT dTest
MEMBER d AS DWORD
USING System.IO
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
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu