PDA

View Full Version : MsgBox function causes the script to exit abnormally



xLeaves
11-07-2019, 06:59
Write a simple script like the one below:


MsgBox(0, "test1")
MsgBox(0, "test2")
MsgBox(0, "test3")
MsgBox(0, "test4")
MsgBox(0, "test5")
MsgBox(0, "test6")
MsgBox(0, "test7")
MsgBox(0, "test8")
MsgBox(0, "test9")
MsgBox(0, "test0")

After running, about one-twentieth of the probability of abnormal exit.

There is another way to reproduce this problem more easily.



Copy the code below to run:


USES "OS"



Function TBMain() As Long
Dim argc As Long = OS_GetCommands()
If (argc > 1) And (LCase$(OS_GetCommand(2)) = "-work") Then
Dim sWorkName As String = OS_GetCommand(3)
If sWorkName <> "" Then
If Function_Exists("Work_" & sWorkName) Then
Dim iRetVal As Long
Dim sWorkParam As String = Trim$(OS_GetCommand(4), """")
Call_IfExists "Work_" & sWorkName(sWorkParam) To iRetVal
Return iRetVal
Else
MsgBox 0, "您创建了任务,但任务执行流程 (Work_" & sWorkName & ") 不存在!", %MB_ICONWARNING, "灵智机器人"
Return -1
End If
Else
MsgBox 0, "缺少任务流程参数!", %MB_ICONWARNING, "灵智机器人"
Return -1
End If
Else
// 转入入口点
Dim iRet As Long
Call_IfExists "Main" To iRet
Return iRet
End If
End Function

// Create Work
Function Work_Create(ByVal sWorkName As String, ByVal sParam As String) As Long
Dim sExecute As String = OS_ProcessGetFullPath(OS_GetCurrentProcessId())
Dim sCmd as String
If Not(APP_IsBundled) Then
sExecute &= " " & OS_GetCommand(1)
End If
Dim iRet As Long = OS_Shell(sExecute & " -work " & sWorkName & " """ & sParam & """")
Return iRet
End Function



// Main Process
Function Main() As Long
Msgbox "Main Process start"

Dim Work1 As Long = Work_Create("Proc1", "param")

Work_Create("Proc2", "param 222222")

Msgbox "Main Process stop"
End Function



// Work1 Process
Function Work_Proc1(ByVal sParam As String) As Long
msgbox "Work1 Process Create : " & sParam
End Function



// Work2 Process
Function Work_Proc2(ByVal sParam As String) As Long
msgbox "Work2 Process Create : " & sParam
End Function

Will find that MsgBox pop-ups will always be less.

The probability of error is about 1/5.

xLeaves
11-07-2019, 07:01
I am from China, reading and posting here depends on google translation.

I hope that everyone understands that the English is not up to standard.

:喝:

xLeaves
11-07-2019, 08:12
The version is 1.10.7

DirectuX
11-07-2019, 10:43
Hi,
no problem here

try MsgboxW : message box with UTF8 strings (https://www.thinbasic.com/public/products/thinBasic/help/html/index.html?msgboxw.htm)

look at the sample : \thinBasic\SampleScripts\UI\SDKsdk_msgbox.tbasic

ErosOlmi
11-07-2019, 19:26
Also tested here with almost 100 MsgBox and sees ok.

You script example is creating parallel tasks invoking multiple instance of thinBasic.exe so each of them is a separated process.

xLeaves
12-07-2019, 07:17
I guess the cause of this problem is related to the system language.

For users of Chinese operating systems, this problem is quite common.

Or instability caused by MessageBoxTimeOutA.

ThinBasic can consider adding function pointer acquisition and change.

Facilitate some adjustments to ThinBasic in multilingual localization.

Of course, doing so will also destroy language compatibility, like Alias.

From the perspective of development tools, I hope to retain some user habits, let users use MsgBox instead of MsgBoxW

Support for the override mechanism is undoubtedly the best.