cloos@acsu.buffalo.edu (James H. Cloos) (10/21/90)
Hello, all. Back in September, someone posted the addresses of routines you can SYSEVAL to convert strings to names and visa-versa. As I understood it, these addresses did no argument checking. Given this, & some addresses from Rick Grevelle's posting of PRG\-> and \->PRG, here are routines that do the string->name and name->string functions which include aregument checking. There is one oddity here I would like to note. Based on Rick's artice, and on my followup showing how to do ALG\-> and \->ALG, we find that the rpl routine at <#18FB2h> check whatever is in stack level one (better be something there :) to see if its TYPE is appropriate to your program. The format is: 18FB2 : check for type nnnnn : <#xh> where #x is the short integer at address #nnnnnh Now, PRG\-> used the hort int <8h> to check for a program; this matches the user language (usrlang) TYPE command's output when given a program. Similarly, I used <#9h> for an algebraic as the TYPE of an algebraic is 9. For S\->N I tried to use <#2h>, as the TYPE of a string is 2. This did not work; it turns out that you have to use <#3h> with the routine at #18FB2h to check for a string. <#2h> will check for a complex number. <#1h> tests for a real. <#5h> does test for a list, and it turns out that <#4h> will test for any array, real or complex, 1D or 2D, and given the internal structure of the arrays, I'd assume it would accept arrays of strings, etc., as well. Any way here are the breakdowns of S\->N and N\->S. (As a side note, except where speed is extreemly important, you might as well just use \<< "" + \>> for N\->S; it's easy to enter, does the same job, takes up only 5 more nybbles than what I show below, and is more robust-- actually, I'd recomend that you just do a "" + in the program where you want to do a N\->S rather than worrying about any external code.) For completeness sake, though, it is included: S\->N 02d9d : :: 18ab2 : need_1_arg 18fb2 : chk_1_arg_for_type 0400d : <#3h> 05b15 : string>name (or $>ID ) 0312b : ; 3f05 : crc of above therefore: %%HP: T(3)A(D)F(.); "D9D202BA812BF81D004051B50B21305F03" and N\->S 02d9d : :: 18ab2 : need_1_arg 18fb2 : chk_1_arg_for_type 0402b : <#6h> 05be9 : name>string (or ID>$ ) 0312b : ; 3cd9 : crc of above therefore: %%HP: T(3)A(D)F(.); "D9D202BA812BF8210409EB50B21309DC3" (NB, this would only work with a global name (ID), not with a local name (LAM).) [If we all had access to all of the rpl addresses, there would be some GREAT software being posted here--even better and more often than there is now!] (Yes, that is a hint. ;-)> ) l8r, -JimC -- James H. Cloos, Jr. Phone: +1 716 673-1250 cloos@ACSU.Buffalo.EDU Snail: PersonalZipCode: 14048-0772, USA cloos@ub.UUCP Quote: <DOWN FOR SERVICE: U L8R BAK C !@$%...>