Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Opening a file argument?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2008, 12:50 AM
Junior Member
 
Join Date: Nov 2007
Posts: 10
Unhappy Opening a file argument?

How do you get a file name argument when a file is chosen from within a file manager?

I can make it so I tap on a file and my program launches, but I want it to load the file I tapped on as well, which I can't work out how to code. I figure its probably an argument option or something, but I can't work it out. What do I have to do?
Reply With Quote
  #2 (permalink)  
Old 03-10-2008, 09:33 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,175
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Look in Help->Main Help->Basics->Command Line Arguments, it tells you there.
Reply With Quote
  #3 (permalink)  
Old 03-10-2008, 01:25 PM
Junior Member
 
Join Date: Nov 2007
Posts: 10
Default

Afraid I don't really understand the help on it, I assume the program will be launched with the file name as an argument but I can't see how I capture that to use. Might fiddle with the code shown in help, but I could do with some more pointers...

(Also I apologise, but I seem to have posted this in 'Code Samples and Tips', rather then the more suitable 'questions/help needed' forum. Can someone move it? I've no idea why I put it here.... *feels silly*)
Reply With Quote
  #4 (permalink)  
Old 03-10-2008, 01:28 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,563
Default

Do you mean that you want to associate a specific file extension with your application?
Reply With Quote
  #5 (permalink)  
Old 03-10-2008, 02:12 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,175
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by Hennell View Post
I assume the program will be launched with the file name as an argument but I can't see how I capture that to use.
Code:
...
NumberOfArguments = ArrayLen(args())
FirstArgument = args(0)
SecondArgument = args(1)
...
Reply With Quote
  #6 (permalink)  
Old 03-10-2008, 06:48 PM
Junior Member
 
Join Date: Nov 2007
Posts: 10
Lightbulb

Ah, thanks agraham, the help file, your last comment and some trial and error seem to have got it all working now. Suddenly it all seems quite obvious.

my code for anyone else with the problem is:

Code:
(In app start)
If ArrayLen(Args()) = 1 Then 'Will catch if a single argument is given. (Like a file name)
	file = args(0)
	If SubString(file,StrLength(file) - 3, 3) <> "jgf" Then 'Checks the file extension to see if its the right type. 
		Msgbox(File & " is not a valid file","Error")
		Return
	End If
	opendialog1.File = file
	LoadFile
Which seems to work fine.

EDIT: First version only worked when given an argument to check. . New code checks if the argument is there...

Last edited by Hennell : 03-11-2008 at 09:58 AM. Reason: code bug :) + add comment.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSV file generates strange start in file sunnyboyj Questions & Help Needed 9 12-21-2007 08:38 PM
b4ppc crashes on opening serialport (cfserialclass.dll) sloopa Questions & Help Needed 1 06-12-2007 08:26 AM


All times are GMT. The time now is 10:05 AM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0