Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) 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: 24
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: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
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: 24
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: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
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: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
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: 24
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) - 33) <> "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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems opening closing forms admben25 Questions (Windows Mobile) 3 11-03-2008 04:08 AM
CSV file generates strange start in file sunnyboyj Questions (Windows Mobile) 9 12-21-2007 08:38 PM
b4ppc crashes on opening serialport (cfserialclass.dll) sloopa Questions (Windows Mobile) 1 06-12-2007 08:26 AM


All times are GMT. The time now is 08:56 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0