LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2002, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 30 Jun 2002 19:33:22 +1000
Reply-To:     doug g <queanbeyan@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         doug g <queanbeyan@HOTMAIL.COM>
Subject:      Re: populate scl list and list box with text file
Comments: To: dward@sashelp.com
Content-Type: text/plain; format=flowed

Thanks David,

I am struggling to learn AF and SCL in my own time at home. I am too busy with ordinary SAS (or extra-ordinary SAS) at work to devote time there so it's mainly a 'trial and error' affair. I have a version 6 SCL manual at home but it was written in 1991 and is not particularly user friendly.

Do you know of any good books on applications development? In the past, Richard DeVenezia has provided me with some SCL syntax related assistance (which I greatly appreciated), but I don't like bothering people with repeat questions that may sound rather simple (but not to me). I suggested to Richard that I would buy a book on SCL if he were to write one!

Thank you once again, for not just showing me the correct syntax but also explaining the meaning of your amendments to my code. The SAS-L group is amazing - with people such as yourself, Richard, and others who are prepared to take the time to assist. I haven't been to your SAShelp website for some time (I used to go there quite often and to Charles Patridge's excellent site too). The current format looks great, so I will add it to my favourites and spend some time browsing - maybe it might save me a post of two on SAS-L.

Cheers

Doug

>From: "David L. Ward" <dward@sashelp.com> >To: "Doug" <queanbeyan@HOTMAIL.COM>, <SAS-L@LISTSERV.UGA.EDU> >Subject: RE: populate scl list and list box with text file >Date: Sat, 29 Jun 2002 14:22:40 -0400 > >Doug, > >Your code shows a few misunderstandings about SAS/AF. First, you don't >need >to set the items property of the listbox - when the widget is instantiated >the list that listbox.items is the list identifier of is automatically >created. In effect what the code listbox.items=mydata is doing is to set >the list identifier to missing, which will later result in errors when you >try to do anything with the listbox. > >Secondly, you need to declare the variable mydata as type char: >Dcl char mydata; >so that the fget will properly get the text in the each line of the file. >To actually add the text as an item in the listbox, you should use >insertc() >to place the text in the list as an item. Here's code that works: > >Dcl char data; > >init: > listbox1.title = 'Selection'; > > * allocate filename ; > rc=filename('elec','C:\temp\temp.txt'); > * open the file ; > fid=fopen('elec'); > * if open then read the items; > if (fid>0) then do while (fread(fid)=0); > rc=fget(fid,data,50); > rc=insertc(listbox1.items,data,-1); > end; > * close file ; > rc=fclose(fid); > listbox1.items=listbox1.items; >return; > >The last line where listbox1.items is set to itself is a shortcut way to >trigger the correct refresh method to show the contents of the list that >has >been manipulated in the loop. > >Hope this helps > >David Ward > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Doug >Sent: Saturday, June 29, 2002 5:31 AM >To: SAS-L@LISTSERV.UGA.EDU >Subject: populate scl list and list box with text file > >Hi, > >I am trying to populate a list box based on items contained in a text >file. >I have been able to open the text file, read the values into a new >variable called mydata, and close the file. But I do not know how to >get SCL to create a list based on the values in the text file. > >init: > boxl1.title = 'Selection'; > boxl1.items = mydata; >return; > >boxl1: > * allocate filename ; > rc=filename('elec','C:\My Documents\ced.txt'); > * open the file ; > fid=fopen('elec'); > * if open then read the items; > if (fid>0) then do while (fread(fid)=0); > rc=fget(fid,mydata,50); > end; > * close file ; > rc=fclose(fid); >return; > >I get no data in the list box and the following in the log when I run >the frame: >NOTE: Compiling TESTLIST.FRAME (CC.CC.TESTLIST.SCL). >WARNING: [Line 13] Converting numeric variable mydata to character >WARNING: [Line 16] Variable rc is defined but not used >NOTE: Code generated for TESTLIST.FRAME. Code size=1554. >ERROR: Invalid list identifier. >ERROR: Invocation of set CAM for the items attribute failed. >Parameters passed to method _SETATTRIBUTEVALUE: > 1 (Character Literal) = 'items' > 2 mydata = . >Program returning prematurely at line 3 >AF Program: CC.CC.TESTLIST.FRAME > >Any help appreciated, > >Doug > >

_________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx


Back to: Top of message | Previous page | Main SAS-L page