Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #708 > unrolled thread
| Started by | Terje Slettebø <tslettebo@gmail.com> |
|---|---|
| First post | 2011-09-10 15:11 -0700 |
| Last post | 2011-09-12 03:17 -0700 |
| Articles | 5 — 2 participants |
Back to article view | Back to comp.sys.acorn.programmer
Parsing command-line arguments for module commands Terje Slettebø <tslettebo@gmail.com> - 2011-09-10 15:11 -0700
Re: Parsing command-line arguments for module commands Martin Bazley <martin.bazley@blueyonder.co.uk> - 2011-09-11 00:13 +0100
Re: Parsing command-line arguments for module commands Terje Slettebø <tslettebo@gmail.com> - 2011-09-11 01:31 -0700
Re: Parsing command-line arguments for module commands Martin Bazley <martin.bazley@blueyonder.co.uk> - 2011-09-11 14:32 +0100
Re: Parsing command-line arguments for module commands Terje Slettebø <tslettebo@gmail.com> - 2011-09-12 03:17 -0700
| From | Terje Slettebø <tslettebo@gmail.com> |
|---|---|
| Date | 2011-09-10 15:11 -0700 |
| Subject | Parsing command-line arguments for module commands |
| Message-ID | <e3d7d3e1-79aa-4e91-8b6b-6a1d0b273aca@s12g2000yqm.googlegroups.com> |
I may be overlooking something obvious, but when implementing a module, the command entry point receives the command tail, and the number of arguments there is, but the arguments are not separated in any way. Is there a way using RISC OS to split the tail up, to get e.g. an array of arguments, in a way that takes into account quoted strings (like RISC OS apparently does when it counts the arguments)? Regards, Terje
[toc] | [next] | [standalone]
| From | Martin Bazley <martin.bazley@blueyonder.co.uk> |
|---|---|
| Date | 2011-09-11 00:13 +0100 |
| Message-ID | <91d5c21052.martin@blueyonder.co.uk> |
| In reply to | #708 |
The following bytes were arranged on 10 Sep 2011 by Terje Slettebø : > I may be overlooking something obvious, but when implementing a > module, the command entry point receives the command tail, and the > number of arguments there is, but the arguments are not separated in > any way. > > Is there a way using RISC OS to split the tail up, to get e.g. an > array of arguments, in a way that takes into account quoted strings > (like RISC OS apparently does when it counts the arguments)? SWI "OS_ReadArgs". Good luck wrangling with the explanation of the syntax string format, though; it took me hours of experimentation to determine exactly what each letter code did, and what they did when combined. Let me know if you need help and I'll see if I can dig out my old notes. -- __<^>__ "Your pet, our passion." - Purina / _ _ \ "Your potential, our passion." - Microsoft, a few months later ( ( |_| ) ) \_> <_/ ======================= Martin Bazley ==========================
[toc] | [prev] | [next] | [standalone]
| From | Terje Slettebø <tslettebo@gmail.com> |
|---|---|
| Date | 2011-09-11 01:31 -0700 |
| Message-ID | <d2558f02-edee-4af6-9912-0b309fbc8b53@j19g2000yqc.googlegroups.com> |
| In reply to | #709 |
On Sep 11, 1:13 am, Martin Bazley <martin.baz...@blueyonder.co.uk> wrote: > SWI "OS_ReadArgs". > > Good luck wrangling with the explanation of the syntax string format, > though; it took me hours of experimentation to determine exactly what > each letter code did, and what they did when combined. Let me know if > you need help and I'll see if I can dig out my old notes. Hi Martin. Thanks. I did look at OS_ReadArgs, but it seemed to only support parameters of the type "-<name>[ <value>]", so you couldn't use it e.g. to parse the parameters of a command like "*copy <from> <to>". In any case, I found that in my case, I'll manage with a simple way of doing this, since it doesn't need to handle quoted strings. Regards, Terje
[toc] | [prev] | [next] | [standalone]
| From | Martin Bazley <martin.bazley@blueyonder.co.uk> |
|---|---|
| Date | 2011-09-11 14:32 +0100 |
| Message-ID | <cf6f111152.martin@blueyonder.co.uk> |
| In reply to | #710 |
The following bytes were arranged on 11 Sep 2011 by Terje Slettebø : > On Sep 11, 1:13 am, Martin Bazley <martin.baz...@blueyonder.co.uk> > wrote: > > > SWI "OS_ReadArgs". > > > Thanks. I did look at OS_ReadArgs, but it seemed to only support > parameters of the type "-<name>[ <value>]", so you couldn't use it > e.g. to parse the parameters of a command like "*copy <from> <to>". Yes, you can. I do it all the time. The <name> part in the syntax string is entirely optional - all you need are the commas separating each argument, and /A inserted between them if a parameter is compulsory. As the StrongHelp manual puts it, "," is a perfectly valid syntax string. Presumably the null string is also. The last time I used this, I was writing a utility to save memory starting from a certain address to a file (determining the length of memory to save from the contents of the address given being the purpose of the utility). I used the string "/A,/A/E". One thing you do have to watch out for is that OS_ReadArgs generates a rather unhelpful error if the parameters are junk, so standard practice is to call it with the X flag set and, if V set, print a message of your own along the lines of, "Syntax: <program> [-<arg1>] -<arg2>". -- __<^>__ "Your pet, our passion." - Purina / _ _ \ "Your potential, our passion." - Microsoft, a few months later ( ( |_| ) ) \_> <_/ ======================= Martin Bazley ==========================
[toc] | [prev] | [next] | [standalone]
| From | Terje Slettebø <tslettebo@gmail.com> |
|---|---|
| Date | 2011-09-12 03:17 -0700 |
| Message-ID | <450b0a72-a1b7-45b0-81af-fffbf564a50d@1g2000vbu.googlegroups.com> |
| In reply to | #714 |
On Sep 11, 3:32 pm, Martin Bazley <martin.baz...@blueyonder.co.uk> wrote: > The following bytes were arranged on 11 Sep 2011 by Terje Slettebø : > > > On Sep 11, 1:13 am, Martin Bazley <martin.baz...@blueyonder.co.uk> > > wrote: > > > > SWI "OS_ReadArgs". > > > Thanks. I did look at OS_ReadArgs, but it seemed to only support > > parameters of the type "-<name>[ <value>]", so you couldn't use it > > e.g. to parse the parameters of a command like "*copy <from> <to>". > > Yes, you can. I do it all the time. The <name> part in the syntax > string is entirely optional - all you need are the commas separating > each argument, and /A inserted between them if a parameter is > compulsory. > > As the StrongHelp manual puts it, "," is a perfectly valid syntax > string. Presumably the null string is also. The last time I used this, > I was writing a utility to save memory starting from a certain address > to a file (determining the length of memory to save from the contents of > the address given being the purpose of the utility). I used the string > "/A,/A/E". > > One thing you do have to watch out for is that OS_ReadArgs generates a > rather unhelpful error if the parameters are junk, so standard practice > is to call it with the X flag set and, if V set, print a message of your > own along the lines of, "Syntax: <program> [-<arg1>] -<arg2>". Ah, great, thanks for the info. I'll try it out. Regards, Terje
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.acorn.programmer
csiph-web