Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / openDialog works but what next, where dose the file name go, how do I get it?

Author
Message
Slaid
18
Years of Service
User Offline
Joined: 7th Nov 2005
Location: Vallsjobo, Sweden
Posted: 7th Apr 2006 22:10
Hello,

I'm making a simple viewer for my .dbo files, so I can look att my game objects and see how they look with there textures.(The program zooms in and out and spinns them around so I can look att them from every angle.)

I added a button that opens a dialog ruta so I can choose which file to show. When I click on the file I want how do I get its name into the (load object "Objects\plane.dbo" , 1) command. I want to replace plane.dbo with the name of the file.

This is the code I use to open the dialog box.
if eventSource()=btnLoadList
file$=openDialog("Load a file","dbo Files (*.dbo)|*.dbo")
endif

I would think the file name should be saved to some sort of varible but how?
Thanks for any help

May the sun shine on the soles of your feet.
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 7th Apr 2006 22:47 Edited at: 7th Apr 2006 22:48


not even having used it, but if it works like VB then file$ holds the name of the file you selected while in openDialog, the function returns the name of the file you selected, just use load object file$,1 or whatever.



Dr Frankenstiens mum told him to make some new friends, not knowing where this was going to lead.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 8th Apr 2006 03:27
yep

check for "" before opening the file tho, the user may have cancelled* which returns "" (empty string) You'll crash you app if file$=""


(*depending on what dialog this is, my plugin has a .NET OpenFileDialog which allows Cancel and returns "")

Slaid
18
Years of Service
User Offline
Joined: 7th Nov 2005
Location: Vallsjobo, Sweden
Posted: 8th Apr 2006 10:43
Hej,

Since I was trying to adapt from an example, there was a piece of code that was makeing file$ equal to 0. I took that out and now the code works.( I used a lot of print file$ before I found the mistake.) Your replies got me on the right track, thanks.

Here's the code that works.

rem first loop to get the dbo file to show object.
do
getevent
if eventType()=MOUSE_CLICK
if eventSource()= Gadget1
file$=openDialog("Load List","dbo Files (*.dbo)|*.dbo")
endif
exit
endif

loop

load object file$, 1
PositionObjectPro(1,0,0,5)

May the sun shine on the soles of your feet.

Login to post a reply

Server time is: 2024-09-24 19:26:59
Your offset time is: 2024-09-24 19:26:59