Puzzled by LC 9.6.2 error
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Puzzled by LC 9.6.2 error
Thanks Bernard for taking the time to invent and try that test. So it seems there's nothing magical about item 289 that chokes LC 9.x. (Frankly, it would've been truly weird if that had been the case.)
To my mind, the *real* puzzle is that the same stack processes .csv datafiles up to and including LC 8.10 perfectly, yet not in LC 9.x.
I suppose it could be that LC 9.x is more strict and disallows something sloppy that wasn't caught in LC 8.10.
Once I recover from the frustration, I will do a deeper dive by stepping through the code as well as trying out some alternatives.
I'll report back to you and fellow forum members as soon as I know more.
jeff k
To my mind, the *real* puzzle is that the same stack processes .csv datafiles up to and including LC 8.10 perfectly, yet not in LC 9.x.
I suppose it could be that LC 9.x is more strict and disallows something sloppy that wasn't caught in LC 8.10.
Once I recover from the frustration, I will do a deeper dive by stepping through the code as well as trying out some alternatives.
I'll report back to you and fellow forum members as soon as I know more.
jeff k
Re: Puzzled by LC 9.6.2 error
Your frustration is understandable.
After I'd gone to bed I realised I should have offered you some more help.
The try...catch should enable you to see more of what's going on in the debugger. Check your CSV data around the 289th item. Check your other variables to see they have what you expect. Do your sLocalVars get changed by any other part of your code?
Also perhaps use your LC 8.x IDE to extract the CSV data for us a few lines before 289 and a few lines after. Post that data here, we might see something.
After I'd gone to bed I realised I should have offered you some more help.
Code: Select all
function doReverseScore pReverseItem
local tResult
local tThisResponse
try
put item pReverseItem of sScoreList into tThisResponse
catch tError
put item pReverseItem-1 of sScoreList
breakpoint
end try
switch
case tThisResponse is "F"
put sValuePresent into tResult
break
case tThisResponse = "T"
put sValueAbsent into tResult
break
default
put sValueAbsent into tResult
break
end switch
return tResult
end doReverseScore
Also perhaps use your LC 8.x IDE to extract the CSV data for us a few lines before 289 and a few lines after. Post that data here, we might see something.
Re: Puzzled by LC 9.6.2 error
Try/catch may well find the issue.
In interest of simplifying the remaining code, I would also point out that the switch block is unnecessary. There are only 2 states to assign to tResult and only one condition that sets this to sValuePresent.
Therefore the entire switch block can be replaced with 2 lines:
In interest of simplifying the remaining code, I would also point out that the switch block is unnecessary. There are only 2 states to assign to tResult and only one condition that sets this to sValuePresent.
Therefore the entire switch block can be replaced with 2 lines:
Code: Select all
put sValueAbsent into tResult
If tThisResponse =“F” then put sValuePresent into tResult
-
- VIP Livecode Opensource Backer
- Posts: 7229
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Puzzled by LC 9.6.2 error
I agree the problem seems to be in the data itself and how LC 9 is processing it, though if it's just a series of letters then I can't think why. And it also doesn't make sense that it only errors on one particular entry.
Edit: if this handler is being called by another handler then the value passed in the parameter is probably wrong. Check what it is exactly (are there extra characters? Something different? Is it really what it should be?) Use the execution contexts button to go back through the calling handler to see if it's passing the parameter properly.
Edit: if this handler is being called by another handler then the value passed in the parameter is probably wrong. Check what it is exactly (are there extra characters? Something different? Is it really what it should be?) Use the execution contexts button to go back through the calling handler to see if it's passing the parameter properly.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Puzzled by LC 9.6.2 error
Thanks so much to everyone -- Bernard, Richmond, Stam, Craig, SparkOut, Jacque -- who have contributed thoughts and suggestions. Over the next few days I will take a very deep dive into the code with all of your comments in mind. I'm truly grateful.
What I simply find so maddening is that the app runs just fine when built as a Win/Mac standalone using LC Indy 8.10, yet breaks when built using LC 9.x from the identical stack, then trying to process the identical .csv datafiles created previously.
I will update here when/if I learn something new. I assume that I need to build the standalone using LC 9.6.2 to ensure that it will run in the most recent versions of macOS and Windows 10.
jeff k
What I simply find so maddening is that the app runs just fine when built as a Win/Mac standalone using LC Indy 8.10, yet breaks when built using LC 9.x from the identical stack, then trying to process the identical .csv datafiles created previously.
I will update here when/if I learn something new. I assume that I need to build the standalone using LC 9.6.2 to ensure that it will run in the most recent versions of macOS and Windows 10.
jeff k
Re: Puzzled by LC 9.6.2 error
I understand your frustration. It could be that a bug was identified and fixed in LC post 8.10, and it's this fix that has "broken" your app.
The best attitude in this situation is to remind oneself that one will know more about solving problems in code afterwards. Last week I spent a couple of days tracking down why something we've known to be true for 20 years was not true in the case of problem someone was having. So that wasn't even a problem I was having, but something was anomalous and I just had to understand why (because one day it may affect me).
We are all fascinated to know the result of what you find.
The best attitude in this situation is to remind oneself that one will know more about solving problems in code afterwards. Last week I spent a couple of days tracking down why something we've known to be true for 20 years was not true in the case of problem someone was having. So that wasn't even a problem I was having, but something was anomalous and I just had to understand why (because one day it may affect me).
We are all fascinated to know the result of what you find.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Puzzled by LC 9.6.2 error
I wonder (this is the standalone builder for LC 8.1.10):I assume that I need to build the standalone using LC 9.6.2 to ensure that it will run in the most recent versions of macOS and Windows 10.
- -
I shall run off a random stack as a 64-bit standalone 'here' on one of my happy 2006 POlycarbonate Macs running MacOS 10.7.5
and take it home tonight and try it out on my "Monterey Jack" (MacOS 12 beta 3) Mac Mini, and report back.
Let's just hope 'Experimental' doth not mean 'Mental' . . .
AND . . . come to think of things . . . have you tried any standalones run off from earlier members of the 9.X.X series?
After all, there is quite a slew of versions midst 8.1.10 and 9.6.2.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Puzzled by LC 9.6.2 error
OK, I apologise, I went home and built an EXPERIMENTAL 64-bit Mac standalone with
LiveCode 8.2.0 dp2 on MacOS 12 beta 3 rather than what I had intended to do: run one off from
LiveCode 8.1.10 on MacOS 10.7.5 at work.
The standalone built in this way works 100% on MacOS 12 beta 3.
LiveCode 8.2.0 dp2 on MacOS 12 beta 3 rather than what I had intended to do: run one off from
LiveCode 8.1.10 on MacOS 10.7.5 at work.
The standalone built in this way works 100% on MacOS 12 beta 3.
Re: Puzzled by LC 9.6.2 error
(1) In reply to Bernard and Richmond -- thanks to Bernard's encouragement in writing,
(2) To Jacque --
(3) To Stam -- You wrote,
Because psychologists use this test for the purpose of clinical diagnosis, I need to include a default so that anything other than "T" or "F" does not count as evidence of psychopathology.
(BTW, the program had to be written as fully bilingual, inasmuch as it will be used mainly in Spanish-speaking countries -- a challenge, insasmuch as I do not speak Spanish. So whatever problem we find with the code, the correction must be made to both the English and Spanish branches of the code.)
jeff k
Along that line, Richmond speculated (pointing to the change in labeling from "Experimental" for macOS 64-bit between LC 8 and 9):I understand your frustration. It could be that a bug was identified and fixed in LC post 8.10, and it's this fix that has "broken" your app.
Actually, I have found that the app breaks in as early as in LC 9.04. I will implement Bernard's try/catch routine.Have you tried any standalones run off from earlier members of the 9.X.X series?
(2) To Jacque --
I'm not convinced of the first half of the statement, but definitely agree with the second. Although I've been watching the values of the variables in debugging mode -- which reveal no error in the raw .csv datafile -- I do need to modify the code a bit to copy the custom stack variable into a temp variable so it can be examined along with the others. This may reveal whether your guess is correct.I agree the problem seems to be in the data itself and how LC 9 is processing it.
(3) To Stam -- You wrote,
Ideally that would be true. But the use of switch and a default case was included in order to cope with the (hopefully rare) case that the test respondents -- mostly persons who may not be all that familiar with using a computer -- make a mistake that results in an entry that is neither one of the two expected ("T" or "F") responses. (The code initially prevents the user from entered any other response, but my colleague insisted on including a perilous feature that permits the respondent to go back and change a previous entry, which introduces the possibility of unexpected error.)In interest of simplifying the remaining code, I would also point out that the switch block is unnecessary. There are only 2 states to assign to tResult and only one condition that sets this to sValuePresent.
Because psychologists use this test for the purpose of clinical diagnosis, I need to include a default so that anything other than "T" or "F" does not count as evidence of psychopathology.
(BTW, the program had to be written as fully bilingual, inasmuch as it will be used mainly in Spanish-speaking countries -- a challenge, insasmuch as I do not speak Spanish. So whatever problem we find with the code, the correction must be made to both the English and Spanish branches of the code.)
jeff k
Re: Puzzled by LC 9.6.2 error
Hey Jeff,jmk_phd wrote: ↑Fri Jul 23, 2021 10:01 pmIdeally that would be true. But the use of switch and a default case was included in order to cope with the (hopefully rare) case that the test respondents -- mostly persons who may not be all that familiar with using a computer -- make a mistake that results in an entry that is neither one of the two expected ("T" or "F") responses. (The code initially prevents the user from entered any other response, but my colleague insisted on including a perilous feature that permits the respondent to go back and change a previous entry, which introduces the possibility of unexpected error.)
That's not quite right...You don't need a switch block to cope with unknown responses.
Your switch block says: if "F" then put sValuePresent. If "T" then put sValueAbsent. If something else, then put sValueAbsent.
The only time your switch block puts sValuePresent into tResult is if tThisResponse = "F".
Therefore you can just assign sValueAbsent to tResult blindly (which covers both "T" and 'anything else') and then check if actually this tThisResponse is "F" and change tThisResult to sValuePresent.
The end-result is you convey the same logic in 2 lines as you do in the 11 lines of the switch block.
There are many ways to skin a cat as they say... my preferences is to minimise text (which minimises chance of errors!), but each to his own
Re: Puzzled by LC 9.6.2 error
Thanks, Stam. Your explanation makes perfect sense now and is indeed more elegant:
jeff k
If/when I track down the error causing the app to fail in LC 9.x, I will rewrite that function accordingly. I don't know how much is saved by eliminating the extra lines -- I never cease to be amazed by how fast a thousand-line script runs in LC. But having had no formal training in computer science beyond preparing punchcards for a class project 45 years ago, I welcome learning and adopting best practices in coding.You don't need a switch block to cope with unknown responses. <snip> The end-result is you convey the same logic in 2 lines as you do in the 11 lines of the switch block. <snip> my preference is to minimise text (which minimises chance of errors!)
jeff k
Re: Puzzled by LC 9.6.2 error
Quick update for everyone. (Your help has been much appreciated!) :
No success yet in tracking down the problem when stepping through the code that broke in the LC 9.6.2 IDE and the standalone it generated. I will persist, but I've had to do something in the meantime in order for the app to remain available to visitors wanting to download this from my colleague's website.
Short term, I built Win and Mac standalones (as 64-bit) using LC 8.10 on an older Mac (using the identical stacks), then copied these standalones to a newer Mac running Catalina (and Parallels to test in Windows 10). The not-yet-signed Mac standalone runs fine in Catalina, and a signed Windows .msi installer file downloaded (with the expected "uncommonly downloaded" message) and runs fine in Windows 10 via Parallels.
I've not yet tried the new LC 9.6.3 -- on the chance that something has been fixed -- but I don't have enough information yet to submit a bug report.
I will post another update if/when I learn something more.
jeff k
No success yet in tracking down the problem when stepping through the code that broke in the LC 9.6.2 IDE and the standalone it generated. I will persist, but I've had to do something in the meantime in order for the app to remain available to visitors wanting to download this from my colleague's website.
Short term, I built Win and Mac standalones (as 64-bit) using LC 8.10 on an older Mac (using the identical stacks), then copied these standalones to a newer Mac running Catalina (and Parallels to test in Windows 10). The not-yet-signed Mac standalone runs fine in Catalina, and a signed Windows .msi installer file downloaded (with the expected "uncommonly downloaded" message) and runs fine in Windows 10 via Parallels.
I've not yet tried the new LC 9.6.3 -- on the chance that something has been fixed -- but I don't have enough information yet to submit a bug report.
I will post another update if/when I learn something more.
jeff k
Re: Puzzled by LC 9.6.2 error
Here's some other options.
1. Try a CSV validator to see if it catches something strange in your CSV file. https://csvlint.io
2. Try the csvToTab or csvToArray Livecode scripts here. https://github.com/macMikey/csvToText
3. Post your CSV file here (or send it to one of us in private) and see if another pair of eyes can spot the problem.
1. Try a CSV validator to see if it catches something strange in your CSV file. https://csvlint.io
2. Try the csvToTab or csvToArray Livecode scripts here. https://github.com/macMikey/csvToText
3. Post your CSV file here (or send it to one of us in private) and see if another pair of eyes can spot the problem.
Re: Puzzled by LC 9.6.2 error
Hi,
what I do in case of CSV parsing problems:
Version A:
what I do in case of CSV parsing problems:
Version A:
- I create a variable before the loop: "put 1 into myVar".
- Then I add a line of code at the start of the loop: "put myVar"
- When it crashes I see the line number in the CSV where the culprit is hiding.
- I add a parameter check before the line where the error occurs. By post 3 here I'd do something like:
("put item pReverseItem of sScoreList into tThisResponse" crashes, as I understand)Code: Select all
if ((pReverseItem is not a number) OR \ -- first check pReverseItem (pReverseItem < 1) OR \ (pReverseItem > 359)) OR \ ((sScoreList is empty) OR \ -- then check sScoreList & item (pReverseItem < the number of items of sScoreList) OR \ (pReverseItem > the number of items of sScoreList)) then put item pReverseItem of sScoreList into myItem breakpoint else put item pReverseItem of sScoreList into tThisResponse end if
- Now LC should hit the breakpoint when there's dubious values in the line handled. "myItem" contains the offending item (that causes the error when "put into").
- At first I change my script so that it loads its CSV from, for instance, SpecialFolderPath("desktop") & "/test.csv".
- Then I open both "test.csv" and "original.csv" in my text editor.
- Now I paste ~50% of "original.csv" into "test.csv" & save.
- If LC processes it w/o error, I delete this part from "original.csv". Else I delete the other half.
- Now I go back to 3.
- Once I have narrowed my "original.csv" down to a few lines, I step through in the debugger until I have found the culprit.
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
Re: Puzzled by LC 9.6.2 error
Hi Jeff, just catching the end of this thread. It would be really helpful if you could post a link to the raw CSV file that you are loading. This would allow others to test more efficiently. Also we could examine the CSV file to check if there are any other issues, e.g. hidden returns or line ends etc that later versions of Livecode may have less tolerance for.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search