Sporadic bug in date or string function

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Heinz57
Junior Coder
Posts: 28
Joined: Wed Jul 22, 2015 6:10 pm
Location: A Berliner just east of Wien

Sporadic bug in date or string function

Post by Heinz57 » Fri Jun 30, 2023 10:33 am

Hello,

there must be some sporadic bug due to the compiler and ONLY in the compiled version. I have had two such errors and I am explaining the more obscure and more obvious one here rather for your and other reader's information as I have fixed this myself (see second code snippet) through a work-around:

1) This is the code that caused the bug (see screenshot)

[snippet=]SRT>msGetTimeNowAsSortableString
GetTime>msTimeTmp
MidStr>msTimeTmp,1,2,msTimeTmp2
Let>msTimeHHMMSS=msTimeTmp2
MidStr>msTimeTmp,4,2,msTimeTmp3
ConCat>msTimeHHMMSS,%msTimeTmp3%
MidStr>msTimeTmp,7,2,msTimeTmp4
ConCat>msTimeHHMMSS,%msTimeTmp4%
END>msGetTimeNowAsSortableString[/snippet]

In a few hundred test runs this happened only once in that a wrong string position was copied that contained a colon ang it happened in a compiled version. There was no manual interaction during this run and I cannot understand how the above code produced this colon.

Screenshot

I then changed the code and no more error occurred in again a couple of hundred runs.

[snippet=]SRT>msGetTimeNowAsSortableString
GetTime>msTimeTmp
MidStr>msTimeTmp,1,2,msTimeTmp2
Format>%.2d,msTimeTmp2,%resultVarTime%
Let>msTimeHHMMSS=%resultVarTime%
MidStr>msTimeTmp,4,2,msTimeTmp3
Format>%.2d,msTimeTmp3,%resultVarTime%
ConCat>msTimeHHMMSS,%resultVarTime%
MidStr>msTimeTmp,7,2,msTimeTmp4
Format>%.2d,msTimeTmp4,%resultVarTime%
ConCat>msTimeHHMMSS,%resultVarTime%
END>msGetTimeNowAsSortableString
[/snippet]

Just to make clear: There is no action expected from you by my side. This is just meant as a hint and information to other users expecially since another error ocurred almost reproducably only in the compiled version but this would be difficult to explain and I am about to circumvent this.

Best regards
Heinz

Please be so kind and fix the link. The path is correct but for some reason embedding the link is false. Tx

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1378
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Sporadic bug in date or string function

Post by Dorian (MJT support) » Fri Jun 30, 2023 10:56 am

I've fixed the URL for you but the image is not there.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1378
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Sporadic bug in date or string function

Post by Dorian (MJT support) » Fri Jun 30, 2023 11:23 am

I'm pretty sure it's not a bug as I am able to replicate this at will.

It's related to the time display system settings (Specifically Long Time) on the problematic machine, and the hour being single digit.

GetTime : Returns the current time in the specified variable. The format of the time depends on the regional settings of the system.

So if your system settings on that machine are set to, for example, 9:40:00 instead of 09:40:00, the first two characters will always contain the colon if the hour is single digit.

So you can either change the setting on that machine, or try the method below. I just tested with the 9:40:00 setting and set my clock back 5hrs, and the TheHour returned 07.

Code: Select all

hour>TheHour
min>TheMin
sec>TheSec
let>msTimeHHMMSS=%TheHour%%TheMin%%TheSec%
Of course splitting and formatting works too.
Yes, we have a Custom Scripting Service. Message me or go here

Heinz57
Junior Coder
Posts: 28
Joined: Wed Jul 22, 2015 6:10 pm
Location: A Berliner just east of Wien

Re: Sporadic bug in date or string function

Post by Heinz57 » Fri Jun 30, 2023 1:16 pm

Well, Dorian,

that sounds plausible but only in principle and theory, because this case ocurred in the middle of a longer run, where many previous executions performed well and so did all following ones after I restarted the exe immediately after this crash / stop happened (I had it in the view, because I was testing recent changes).

Secondly, this occurred in a VirtualBox VM, which runs on one machine together with 10 or more others and all mostly with the same jobs. No VM has any private settings at all or settings different from its host.

I have encountered other peculiarities in the compiled version and differences to the dev environment but this is difficult to describe and I have already reworked the entire code and modules where this happened.

Best regrds
Heinz

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1378
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Sporadic bug in date or string function

Post by Dorian (MJT support) » Fri Jun 30, 2023 1:33 pm

No problem. Thank you for clarifying.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts