ccroft Posted October 8, 2007 Share Posted October 8, 2007 Here's something that I've been meaning to ask for....I don't know....a couple years? I have a two menu commands that were written and performed fine in 8.5, that started giving me some trouble in 11. These both take values, perform a bunch of calculations, and output the result. They're fairly complex calculators. One gets it's input from user values entered in a dialog, and the other from existing values in record fields attached to objects. On the first run of either after a fresh launch of Vworks, they both choke on Str2Num. The error reads "error converting string to number" over and over until the last line "not enough memory to continue execution". (Note that I had no such errors in 8.5, and that the pref to stop vectorscript on warnings has no effect on this behavior.) On subsequent runs they perform with no errors, so my workaround has been to do a dummy run and then run them again. Not entirely satisfying. From time to time I resolve to do something about this, but ultimately end up letting it slide. The solution for the one that works from a dialog would seem to be re-writing using Modern Dialog with CreateEditReal fields. It's something that I might consider doing if I knew that this would solve half the problem, though it's quite a lot of work. Can anyone give me reasonable assurance that this'll solve the dialog problem? Does anyone have any suggestions for fixing the one that reads record fields? And does anyone know why this change in behavior? My guess is that it has to do with the increase floating point accuracy of the newer versions. Thanks for any insight Charles Quote Link to comment
MullinRJ Posted October 9, 2007 Share Posted October 9, 2007 Hi Charles, ???I've never had any trouble with Str2Num(). Have you verified that your string has only numeric values in it when you try to convert it? Leading or trailing blanks seem to be OK, but any other alpha character will make it fail. ???I use ValidNumStr() to test values before proceeding with dialog entries. It has Str2Num built in. If it fails, I loop back to the dialog and make the user try again or cancel. A message window with a prompt, hint or result is always nice, and it gives you a chance to display the string that fails without having to enter debug mode. if not ValidNumStr(Str, XDiam) then RepeatSecondGrade else ContinueOn_or_DoGoodStuffHere; Raymond Quote Link to comment
Petri Posted October 9, 2007 Share Posted October 9, 2007 Charles, Are you using RealDialog & Numeric field type? Quote Link to comment
ccroft Posted October 9, 2007 Author Share Posted October 9, 2007 Thanks guys. The dialog is a Classic and uses AddField to creat editable text fields into which the values are entered by user and read by the script. The one that reads records is reading "Number" fields and has no dialog. They do sometimes contain fractions like 23 7/8. I'll have to test that with whole numbers for the heck of it, but I have many other scripts that have no trouble with this. The odd thing is that it only fails the first time...every time...and then it executes fine after that even with the same values that failed in the first place. (!?) I'll try playing with IsValid. Any more de-bug ideas are welcome. On another note: How are your older scripts behaving in V13? This is the kind of thing that makes me such a late-adopter. Thanks Again c Quote Link to comment
Petri Posted October 9, 2007 Share Posted October 9, 2007 On another note: How are your older scripts behaving in V13? This is the kind of thing that makes me such a late-adopter. So far, so good, but I haven't tried too many yet. Reading the list of obsolete functions is a frightening experience, though. No new ones this time, but I have tens of scripts with functions marked obsolete several versions ago and one day the axe will fall. Quote Link to comment
Petri Posted October 9, 2007 Share Posted October 9, 2007 Any more de-bug ideas are welcome. Have you tried setting a "junk" value first, before reading user input? I have a vague recollection of getting something remotely similar fixed this way. Quote Link to comment
ccroft Posted October 10, 2007 Author Share Posted October 10, 2007 (edited) and one day the axe will fall. yeah....i'm sure it will. Um....(sheeplike)....I don't think Str2Num is the problem. After a trip or two thru debugger and a closer look at the error log, Str2 is only causing warnings. The actual error is in a function called last_L. It's the part of a bubble sort that finds the last open slot in an array. I suspect a problem with the escape conditions of the While loop....iThink. Probably faulty logic on my part. Further fiddling required. I have to say it's odd if that turns out to be the problem as it didn't show in version 8, and that they run OK in 11 after a dummy run (real trouble understanding that). Maybe there isn't an empty slot in the first creation of the array...... Thanks to you both for helping me see beyond Str2. If you hadn't said so clearly that you've never had a problem I might still be puzzling on field types and so forth. Charles Edited October 10, 2007 by ccroft Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.