Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.clipper.visual-objects

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-06-2007, 08:22 AM
Martin
Guest
 
Posts: n/a
Default Array access bug

One thing I used to do a lot was to call a function returning an array and
get the element I wanted straight away.

eg

a := Function()[1]

This doesn't work very well

I have to do

LOCAL b AS ARRAY

b := Function()
a := b[1]

Any ideas please?


Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 11-06-2007, 08:38 AM
richard.townsendrose@googlemail.com
Guest
 
Posts: n/a
Default Re: Array access bug

martin

try declaring the function as an array

function fred as array
local anarray as array
anarray:={1,2,3,4,5}
return anarray

getting beyond me here, but compiler needs to know what it is its
handling...

richard

Reply With Quote
  #3 (permalink)  
Old 11-06-2007, 10:47 AM
Arne Ortlinghaus
Guest
 
Posts: n/a
Default Re: Array access bug

Perhaps also using Arrayget(Function(), 1) should work. But Robert did
always warn to have too complex expressions and better use temporary
variables to avoid problems with the garbage collector. In the last years I
have changed my style of coding: better more rows of code with short clear
statements.

Arne Ortlinghaus

"Martin" <nospam@spam.spam> schrieb im Newsbeitrag
news:fgpbpm$6vn$1$8300dec7@news.demon.co.uk...
> One thing I used to do a lot was to call a function returning an array and
> get the element I wanted straight away.
>
> eg
>
> a := Function()[1]
>
> This doesn't work very well
>
> I have to do
>
> LOCAL b AS ARRAY
>
> b := Function()
> a := b[1]
>
> Any ideas please?
>



Reply With Quote
  #4 (permalink)  
Old 11-06-2007, 11:49 AM
Martin
Guest
 
Posts: n/a
Default Re: Array access bug

First thing I tried Richard - wish it had failed compile - only went wrong
at run time.


Reply With Quote
  #5 (permalink)  
Old 11-06-2007, 11:50 AM
Martin
Guest
 
Posts: n/a
Default Re: Array access bug

>>Perhaps also using Arrayget(Function(), 1) should work. But Robert did
>>always warn to have too complex expressions and better use temporary
>>variables to avoid problems with the garbage collector. In the last years
>>I have changed my style of coding: better more rows of code with short
>>clear statements.


Didn't even think about it - went to a temporary variable


Reply With Quote
  #6 (permalink)  
Old 11-06-2007, 12:05 PM
Malcolm Gray
Guest
 
Posts: n/a
Default Re: Array access bug

richard.townsendrose@googlemail.com wrote:
> martin
>
> try declaring the function as an array
>
> function fred as array
> local anarray as array
> anarray:={1,2,3,4,5}
> return anarray


Remember that is not really strongly typed (as array pascal would be, or
strongly typing an argument if it had one)
Reply With Quote
  #7 (permalink)  
Old 11-06-2007, 12:05 PM
Malcolm Gray
Guest
 
Posts: n/a
Default Re: Array access bug

Martin wrote:
> One thing I used to do a lot was to call a function returning an array and
> get the element I wanted straight away.


Which build (e.g. are you saying it used to do it a lot and it does not
work in Vo2.8 gold)
Have you reported it to grafx?
What does it do (for those of us who are in the middle of other things)
Reply With Quote
  #8 (permalink)  
Old 11-06-2007, 08:36 PM
Geoff Schaller
Guest
 
Posts: n/a
Default Re: Array access bug

Martin.

Irrespective of whether this should work or not, it is a horrible syntax
and I certainly wouldn't want to work with it. What is so wrong with:

> b := Function()
> a := b[1]


This is at least thoroughly clear and will give you much better compile
time error handling.

Geoff


Reply With Quote
  #9 (permalink)  
Old 11-07-2007, 03:58 PM
Martin
Guest
 
Posts: n/a
Default Re: Array access bug

>>Martin.
>>
>>Irrespective of whether this should work or not, it is a horrible syntax
>>and I certainly wouldn't want to work with it. What is so wrong with:
>>
>>> b := Function()
>>> a := b[1]

>>
>>This is at least thoroughly clear and will give you much better compile
>>time error handling.
>>
>>Geoff
>>


Converted from code where every LOCAL takes 14bytes


Reply With Quote
  #10 (permalink)  
Old 11-07-2007, 03:58 PM
Martin
Guest
 
Posts: n/a
Default Re: Array access bug

>>Which build (e.g. are you saying it used to do it a lot and it does not
>>work in Vo2.8 gold)
>>Have you reported it to grafx?
>>What does it do (for those of us who are in the middle of other things)


2.7B


Reply With Quote
  #11 (permalink)  
Old 11-07-2007, 07:39 PM
Geoff Schaller
Guest
 
Posts: n/a
Default Re: Array access bug

Martin.

What do you mean by this?

The 14 bytes is created whether you declare a local variable or not
because one has to be created internally if you don't but who cares! A
whole 14 bytes? <g>

But as code goes it is hard to read, poor for maintenance and terrible
for debugging.

Cheers,

Geoff



"Martin" <nospam@spam.spam> wrote in message
news:fgsqrk$ght$1$8300dec7@news.demon.co.uk:

> >>Martin.
> >>
> >>Irrespective of whether this should work or not, it is a horrible syntax
> >>and I certainly wouldn't want to work with it. What is so wrong with:
> >>
> >>> b := Function()
> >>> a := b[1]
> >>
> >>This is at least thoroughly clear and will give you much better compile
> >>time error handling.
> >>
> >>Geoff
> >>

>
> Converted from code where every LOCAL takes 14bytes


Reply With Quote
  #12 (permalink)  
Old 11-22-2007, 09:11 AM
Martin
Guest
 
Posts: n/a
Default Re: Array access bug

>>Martin.
>>
>>What do you mean by this?
>>
>>The 14 bytes is created whether you declare a local variable or not
>>because one has to be created internally if you don't but who cares! A
>>whole 14 bytes? <g>


Clipper where DGROUP is precious


Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: MAX of _TEMPORARY_ array? Venky Chakravarthy Newsgroup comp.soft-sys.sas 0 06-27-2005 09:19 PM
Re: MAX of _TEMPORARY_ array? nospam@HOWLES.COM (Howard Schreier Newsgroup comp.soft-sys.sas 0 06-27-2005 04:51 PM
Re: MAX of _TEMPORARY_ array? Jack Hamilton Newsgroup comp.soft-sys.sas 0 06-25-2005 06:25 AM
SAS Access to Oracle ma015b8234 Newsgroup comp.soft-sys.sas 0 06-02-2005 06:23 PM
Re: find maximum vaule in sas array Paul M. Dorfman Newsgroup comp.soft-sys.sas 0 04-27-2005 05:27 AM



All times are GMT. The time now is 03:14 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.