1. Problem with printf
- Posted by Allen Robnett <alrobnett at alumni.princeton.edu> Dec 31, 2003
- 714 views
Printf works fine in my app, with sequence slice to limit the number of characters actually printed: printf(1,"%8s",data_array[rec_no][1..6]) for example. For reasons other than coding elegance, I need to have the arguments of printf read from another array. It works fine for everything except the slice specification. The interpreter will not accept 1..6 read into the final [ ] via a subscripted array element. As of now, I am using "if" statements to select between several different printf's with different sequence slice specs. Is there a better way? Allen
2. Re: Problem with printf
- Posted by Robert Craig <rds at RapidEuphoria.com> Dec 31, 2003
- 583 views
Allen Robnett wrote: > Printf works fine in my app, with sequence slice to limit the number of > characters actually printed: > > printf(1,"%8s",data_array[rec_no][1..6]) for example. You say it works fine, but I don't believe you. Please add braces: printf(1,"%8s",{data_array[rec_no][1..6]}) I know it looks strange, but in Euphoria it logically has to work this way. You have one %, so you should supply a sequence of length 1 (at the top-level), not 6, as the third argument. Otherwise only the first character of 6 will be printed. Everyone (including myself) falls into this trap sooner or later. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Problem with printf
- Posted by EUPHORiCK <euphoric at cklester.com> Dec 31, 2003
- 579 views
Allen Robnett wrote: > > >Printf works fine in my app, with sequence slice to limit the number of >characters actually printed: > >printf(1,"%8s",data_array[rec_no][1..6]) for example. > >For reasons other than coding elegance, I need to have the arguments of >printf read from another array. It works fine for everything except the >slice specification. The interpreter will not accept 1..6 read into the >final [ ] via a subscripted array element. > > Do you want something like this: atom x,y x=1 y=6 printf(1,"%8s",data_array[rec_no][x..y] or x = {1,6} printf(1,"%8s",data_array[rec_no][x[1]..x[2]] Either should work.
4. Re: Problem with printf
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Dec 31, 2003
- 592 views
----- Original Message ----- From: "C. K. Lester" <euphoric at cklester.com> To: <EUforum at topica.com> Subject: Re: Problem with printf > > > Allen Robnett wrote: > > > > >Printf works fine in my app, with sequence slice to limit the number of > >characters actually printed: > > > >printf(1,"%8s",data_array[rec_no][1..6]) for example. > > > >For reasons other than coding elegance, I need to have the arguments of > >printf read from another array. It works fine for everything except the > >slice specification. The interpreter will not accept 1..6 read into the > >final [ ] via a subscripted array element. > > > > > Do you want something like this: > > atom x,y > x=1 > y=6 > printf(1,"%8s",data_array[rec_no][x..y] > > or > > x = {1,6} > printf(1,"%8s",data_array[rec_no][x[1]..x[2]] > > Either should work. Or if the first element is always #1, then this is suffcient... integer len len=6 -- or whatever... printf(1,"%8s",{data_array[rec_no][1..len]}) -- Derek
5. Re: Problem with printf
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Dec 31, 2003
- 602 views
On Wed, 31 Dec 2003 03:17:26 +0000, Allen Robnett <alrobnett at alumni.princeton.edu> wrote: >The interpreter will not accept 1..6 read into the >final [ ] via a subscripted array element. Can you post the code and error message please Pete