|
Post by larrybtoys on Nov 18, 2023 0:45:10 GMT 1
Can anyone tell me why after 100's of times running this program over the last 2 weeks of development this code started crashing? Current_Time$ = Time$ Current_Hours& = Val(Left$(Current_Time$, 2)) Current_Minutes& = Val(Mid$(Current_Time$, 4, 2)) Total_Current_Minutes& = (Current_Hours& * 60) + Current_Minutes& The error is attached. Weirdly when I slide the same code is another part of the program it goes through it fine. Attachments:
|
|
|
Post by (X) on Nov 18, 2023 0:53:05 GMT 1
Works as is here...
Maybe try:
Dim Current_Hours& = Hour(Time) Dim Current_Minutes& = Minute(Time)
Dim Total_Current_Minutes& = (Current_Hours& * 60) + Current_Minutes&
|
|
|
Post by larrybtoys on Nov 18, 2023 0:59:07 GMT 1
Still crashes on my computer
|
|
|
Post by larrybtoys on Nov 18, 2023 1:48:39 GMT 1
OK well I have no explanation for this but it also crashed on my laptop so I deleted all the data files and had the program recreate them and it worked fine on both computers. Some how when I changed the time stored within the data file it must have corrupted the data file in such a way that GFA crashed even though it had not gotten to the point of using the data stored in the data file yet....OMG just glad it's working...
|
|
|
Post by dragonjim on Nov 18, 2023 10:14:48 GMT 1
There is a rare error with running code in the IDE where a simple change in code can cause what you describe. It is thought that it is down to either how the IDE or the Compiler parses the code but on the few times it has happened to me personally it has been either a simple case of doing exactly what you did and repositioning the code, a Windows Update waiting for a restart to install or, on one occasion, a corrupt Windows installation.
I'm glad you managed to sort this out yourself. It would be interesting to know if you were to repeat what you did again now, whether the error would return...
|
|
|
Post by larrybtoys on Nov 18, 2023 12:15:39 GMT 1
I did do that to see what happened and it was fine. I had the program create a data file during it's normal operation, pulled it up in Notepad, changed the time and resaved it. When running the program and using that data file it worked just fine. Somehow some nonprintable character or some crazy gremlin must have gotten into the data file when I resaved it the first time causing the computer to go crazy.....Not sure but I will take the win.
|
|
|
Post by Roger Cabo on Nov 20, 2023 18:04:48 GMT 1
Current_Hours&
while you use single? these values can be on only int. A part of the time can be only int, like a none floating point result. Single values can store approx 100000.x or 0.xxxxxxx. If the result is 999.99999999 it will cause an overflow.
Keep in mind to use only & single in 16bit alpi calls, but i can't recommendet in 32764 system.. because you never know what real values is giving back from any API internally that use eg. time. In any OCX - SUBs you can use SUB my_method(Code&,SHIFT&) for sure.
But in the normal code environment I would use only Int or Double to receive values into my own variables and calculate with. There is no speed difference in my opinion.
Further you can set up in "Eigenschaften -> Code " FP-Fehler früher melden Off.
Can you provide the text that produce Time$ in you country? Does it look like this:
"11-12-2023 12:12:18" ?
and in what line the error happens?
|
|
|
Post by larrybtoys on Nov 21, 2023 1:01:42 GMT 1
The error is corrected as there really was no issue with the code. There was a data file that had gotten corrupted. Once I deleted the data file and restored it the problem went away. I only use 2 byte integers when I know the value will be small like a screen coordinate and will always need to be an integer. Our time and date format is set using the GFA Command Mode Date "/"
|
|
|
Post by scalion on Nov 21, 2023 12:00:28 GMT 1
I haved this code error with Val() function. Try use ValInt or ValSng.
|
|
|
Post by larrybtoys on Nov 21, 2023 14:34:29 GMT 1
Thanks, will do
|
|