Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Invalid subscript error
Message
From
29/09/1999 10:38:24
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
29/09/1999 10:22:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00270497
Message ID:
00270510
Views:
31
>Hello:
>
>I'm trying to load an array into my grid and am getting invalid subsript.
>I add a record, save and then do this statmenet to load into my grid.
>
>My select statement is :
>
>select gidetail.sin, client.surname,client.firstname, client.phone1;
>from gidetail, client;
>where gidetail.sin = client.sin;
>and gisum.sessionkey = gidetail.sessionkey;
>into array aclient
>
>in the control source of my grid for column2 of the grid(surname) I have :
>iif(empty(gidetail.sin), "",surdesc("Aclient", gidetail.sin))
>
>my function surdesc is as follows:
>
>Function surdesc
>Parameters arrname, cd
>tmpnum = Ascan((arrname), cd)
>if empty(tmpnum)
>return " "
>else
>return &arrname(round(tmp/4,0),2)
>endif
>
>I've set up my arrays as : public array aclient(1,4)
>
>Shouldn't this just redimension itself when it loads from the
>select statement. I can't understand why I'm getting this error.
>Any input would be appreciated.


Sheena,
I hope this would help :
dimension myarray[6,4]
for ix = 1 to 6
 for jx = 1 to 4
  myarray[ix,jx] = ix*10+jx
 endfor
endfor
disp memo like myArray
lnPos = ascan(myArray,33)
? lnPos, ;
  asubscript(myArray,lnPos,1), ;
  myArray[asubscript(myArray,lnPos,1),2]
return
* So your routine might be like
Function surdesc
Parameters arrname, cd
tmpnum = Ascan((arrname), cd)
if empty(tmpnum)
 return " "
else
 return arrname[asubscript(arrname,tmpnum,1),2]
endif

* Also call like :
iif(empty(gidetail.sin), "",surdesc(@Aclient, gidetail.sin))
* if array is not public
* if public you do not need to pass its name
* and directly use infunction
* but this would kill function's generiousity
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform