Can we check a program from a program. - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Can we check a program from a program. (/thread-9030.html) |
Can we check a program from a program. - webmasterpdx - 09-10-2017 03:56 AM I'm writing a custom program editor and want to be able to check the code like the regular editor can. Since the function is already there to provide the functionality for the CHECK button in the existing editor, I'm wondering if there is a way for a program to access that function, to either take a program or the contents as a string and check it and return the location of the error if there is one (like the existing editor does). Thanks -Donald RE: Can we check a program from a program. - Carlos295pz - 09-10-2017 09:39 PM Erwin Ried created PrimeMom a few months ago, manages to cover the detection of compilation errors like what you are looking for. http://www.hpmuseum.org/forum/thread-7948.html RE: Can we check a program from a program. - webmasterpdx - 09-10-2017 10:12 PM That seems to be on the PC, but I want to do this on the calculator....but I'll take a look at what he does... I know the code already exists on the prime since it's done in the existing editor....I'd hate to have to rewrite it. Thx -D RE: Can we check a program from a program. - cyrille de brébisson - 09-11-2017 05:11 AM Hello, As far as I remember doing Programs("name"):=string will return 0 or 1 (0 means error). However, it does not return the position of the error, sorry. Cyrille RE: Can we check a program from a program. - webmasterpdx - 09-11-2017 05:17 AM Carlos' suggestion is a csharp program in windows and that won't work for what I want to do. The other suggestion....I'll have to look at that. Program("name"):=string writes the program....but even checking for an error might be good enough....I'll have to check that...Thx RE: Can we check a program from a program. - webmasterpdx - 09-11-2017 05:53 AM I could remove one line at a time and execute Program("name"):=string until the error goes away, to isolate the failing line. However, this won't work for multiple errors. I think the best approach is to treat the original editor as a debugger and to have the user run that after using my editor.... That's really the best approach as long as HP doesn't give us access to the check/debug functionality. RE: Can we check a program from a program. - Tim Wessman - 09-11-2017 06:36 PM How would this be for you? On program store and successful compile, returns { } Programs("name"):="EXPORT test()\nBEGIN\n\nEND;" ----> {} On program store and failure on compile, returns { line_number_failure, character_position_failure, <reserved for future use> } Programs("name"):="EXPORT test(\nBEGIN\n\nEND;" ----> {#2:64h,#12:64h} That is the info you get in the CHECK button, note how the cursor position is placed at the end of BEGIN there which corresponds to the numbers I've given in the example. AProgram would behave similarly. RE: Can we check a program from a program. - webmasterpdx - 09-11-2017 08:22 PM That would be great! It doesn't do this now though :-) Thanks -Donald |