CToD() new incompatibility to VO

This forum is meant for questions and discussions about the X# language and tools
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

CToD() new incompatibility to VO

Post by Horst »

Hello
I think there is still a problem, i had to go back to 2.14 because i had an error on this

Code: Select all

SELF:odbSina:LockCurrentRecord ()
SELF:odbSina:FIELDPUT (#DatePrint, DToC (Today())+NTrim (Seconds()))
SELF:odbSina:Unlock ()
the error msg was
bei XSharp.RT.Functions.DefError(Object oErr)
bei XSharp.RT.Functions.<>c.b__84_0(__Usual oError)
bei <>f__AnonymousType1.Eval(__Usual[] Xs$Args)
bei XSharp.RT.Functions.Eval(ICodeblock block, __Usual[] args)
bei XSharp.RT.Functions.Eval(__Usual uCodeBlock, __Usual[] args)
bei VO.DbServer.Error(__Usual[] Xs$Args)
bei VO.DbServer.FIELDPUT(__Usual[] Xs$Args)

i am not on my working computer so i cant say more at the moment. but before there was no problem.

Horst
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

CToD() new incompatibility to VO

Post by wriedmann »

Hi Horst,
the problem described on this thread was about to CToD(), not DToC().
How is your DatePrint field defined?
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

CToD() new incompatibility to VO

Post by robert »

Horst,
What is the datatype of the field #DatePrint. I assume it is a string?
What is the size of this field ?
What is the Date Format ?
Is it possible that the result of the expression :"DToC (Today())+NTrim (Seconds())" produces a value that is larger than the size of that field ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

DToC() new incompatibility to VO

Post by Horst »

Hello Wolfgang
Its string, the msg says also i have to lock the record.
As i said , i am not on my pc . so i cant say anything at this time. maybe its a lock problem. but runs perfect before i compiled with 2.16

Horst
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

DToC() new incompatibility to VO

Post by wriedmann »

Hi Horst,
maybe the record is locked by another process, so it cannot be locked by your current process.
Normally, you should always check the return value LockCurrentRecord():

Code: Select all

if oServer:LockCurrentRecord()
  oServer:FieldPut( "xxx", yyy" )
  oServer:Commit()
  oServer:Unlock()
else
  // Error handling - record cannot be locked
endif
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

DToC() new incompatibility to VO

Post by Horst »

Hello Robert and Wolfgang
I will check that this week. When i have access to my pc

Horst
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

DToC() new incompatibility to VO

Post by Chris »

Hi Horst,

In addition to what others said, is the problem always reproducible, does it happen always when you run the app? If yes, then temporarily please remove the Seconds() part where you create the new text to see if the problem still happens. Then add back the seconds() part and remove the DToC() part, then even try to fieldput an empty string. This will tell us if the problem has to do with one of the functions, if it is related to the total length of the string, or it is a completely different problem.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Horst
Posts: 336
Joined: Tue Oct 13, 2015 3:27 pm

CToD() new incompatibility to VO

Post by Horst »

Hello
It's not the DtoC Function, something with the locking.
On my localhost comes no error, only on the internet server machine.
At the moment i have no time to analyse that.

Horst
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

CToD() new incompatibility to VO

Post by wriedmann »

Hi Horst,
in the code you have posted there was no "unlock()" call.
Please make sure that you always release your locks.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

CToD() new incompatibility to VO

Post by Chris »

Wolfgang, there does exist an Unlock() in the code, in the last line. But indeed there's no check if the locking failed, as you pointed out.

Horst, can you please check if your call to LockCurrentRecord() returns false indeed? If it does, can you please set in XIDE in the menu Debug->Handled Exceptions->Break Always, then start the app in debug mode and see if you get a runtime exception in that call to LockCurrentRecord()? If yes, can you please post the full error message shown?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply