VBAndCs / sVB-Small-Visual-Basic

Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows OS.
Other
232 stars 16 forks source link

File.OpenFolderDialog not waiting, caller continues before dialog opens #14

Closed sjsepan3 closed 1 year ago

sjsepan3 commented 1 year ago

GetFolderName appears to return with empty value before dialog is shown; the value I select in the dialog is not getting into the variable I check.

` '------------------------------------------------ Function GetFolderName() returnValue = ""

WriteError("before") returnValue = File.OpenFolderDialog("c:\") WriteError("after") Return returnValue EndFunction

`

VBAndCs commented 1 year ago

@sjsepan3 I mistakenly called the SmallBasicApplication.BeginInvoke method at the start of the OpenFolderDialog function, which invokes the given method after the currnet method is completed. I just should call SmallBasicApplication.Invoke (which I use in all other places in the lib). Also, the Return "" statement at the end of the function must be removed. I fixed the bug and the fix will be available in the next update. Thanks.

VBAndCs commented 1 year ago

@sjsepan3 It's available now in sVB v2.8.4. In this version you can also use the turtle can fill an area, by calling the CreateFigure and FillFigure methods.

X = Turtle.X
Y = Turtle.Y

Turtle.CreateFigure()
Turtle.Move(200)
Turtle.TurnRight()
Turtle.Move(200)
Turtle.TurnRight()
Turtle.Move(200)
Turtle.TurnRight()
Turtle.Move(200)
Turtle.FillFigure()

Turtle.CreateFigure()
Turtle.TurnLeft()
Turtle.Move(200)
Turtle.MoveTo(200, 200)
Turtle.MoveTo(350, 200)
Turtle.MoveTo(X, Y)
GraphicsWindow.BrushColor = Colors.Red
Turtle.FillFigure()

image

sjsepan3 commented 1 year ago

File.OpenFolderDialog works great here too. Thanks!