Problem with link selection$()

new BookmarkLockedFalling
donnybowers
Junior Member
**

donnybowers Avatar

My website was created in the mid 2000s. Unfortunately I lost the code somehow.
Posts: 70Male

Post by donnybowers on Jul 1, 2021 0:00:43 GMT -5

I can't for the life of me figure out why I keep getting this error in my [open] routine. I always get the following error message:


Runtime Error in program 'Files': fileName$ = #opn selection$()
Unrecognized command for #opn: selection$()



width=640
slash$="\" : level=1

dim thisDir$(1)

root$=DefaultDir$+slash$+"public"

thisDir$(1)=root$

cssclass "select", "{width:";str$(int(width*.89));"px; font-size:32px;}"

gosub [getFiles]



[start]

listbox #filer, fils$(),5

print

link #opn, "Open", [open]

print

wait



[open]' I CAN'T SEE ANYTHING WRONG WITH THIS CODE:
fileName$ = #opn selection$()
print fileName$
wait

end



[getFiles]

this$=thisDir$(level)+"\*.*"

html "<b>Look in: ";thisDir$(level);"</b>"

files #dir, this$

dim fils$(#dir rowcount())

dim d$(#dir rowcount())

dim f$(#dir rowcount())



numFiles = 0 : numDirs=0



while #dir hasAnswer()

#dir nextFile$()



if #dir isdir() then

numDirs = numDirs + 1

d$(numDirs) = "["+#dir name$()+"]"

else

if f$(numFiles+1)<>"Thumbs.db" then

numFiles = numFiles+1

f$(numFiles) = #dir name$()

end if

end if

wend



for i=1 to numDirs

fils$(i)=d$(i)

print fils$(i)

next i



x=numDirs

for i = 1 to numFiles

x=x+1

fils$(x)=f$(i)

next i

dim d$(0)

dim f$(0)

[return]








Last Edit: Jul 1, 2021 0:04:16 GMT -5 by donnybowers
Any code I share on this forum is released to the public domain and may be used freely any way you like unless for some reason I specifically indicate otherwise in the post.
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

Last Edit: Jul 1, 2021 1:17:12 GMT -5 by StefanPendl
[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
donnybowers
Junior Member
**

donnybowers Avatar

My website was created in the mid 2000s. Unfortunately I lost the code somehow.
Posts: 70Male

Post by donnybowers on Jul 1, 2021 8:15:15 GMT -5

StefanPendl Avatar
A link does not have any methods.
Since you want to get the selected file name, you need to use the handle of the list box:
fileName$ = #filer selection$()

Thank you Stefan. My mind must be getting really old. I can't believe I didn't notice that I was trying to get the link to give me the listbox data (slaps self in head).
Any code I share on this forum is released to the public domain and may be used freely any way you like unless for some reason I specifically indicate otherwise in the post.