amiga.org
     
iconAll times are GMT -6. The time now is 06:05 AM. | Welcome to Forum, please register to access all of our features.

» Amiga.org » Operating System Specific Discussions » Amiga OS » Amiga OS -- Development » Blitz Basic: Reading arguments from the command line

Amiga OS -- Development This particular forum deals with issues regarding development for all versions of AmigaOS.

Reply
 
Thread Tools Display Modes
Old 05-26-2006, 01:01 AM   #1
motorollin
Premium Member
Points: 32,860, Level: 100 Points: 32,860, Level: 100 Points: 32,860, Level: 100
Activity: 54% Activity: 54% Activity: 54%
 
motorollin's Avatar
 
Join Date: Nov 2005
Posts: 8,666
Default Blitz Basic: Reading arguments from the command line

I've scoured the Blitz manual and searched online but I can't find an answer to this... How on earth do I read command line arguments from Blitz?

--
moto
motorollin is offline   Reply With Quote
Old 05-26-2006, 02:30 AM   #2
uncharted
Defender of the Faith
Points: 10,899, Level: 69 Points: 10,899, Level: 69 Points: 10,899, Level: 69
Activity: 4% Activity: 4% Activity: 4%
 
Join Date: Mar 2002
Posts: 1,520
Default Re: Blitz Basic: Reading arguments from the command line

From the manual (about page 129)...

Quote:
- NumPars

The NumPars function allows an executable file to determine how many
parameters were passed to it by either Workbench or the CLI. Parameters
passed from the CLI are typed following the program name and separated by
spaces.

For example. Iet's say you have created an executable program called myprog,
and run it trom the CLI in the following way:

myprog filer Olle2

In this case, NumPars would return the value '2' - 'file I ' and 'file2'
beng the 2 parameters.

Programs run from Workbench are only capable of picking up I parameter
through the use of either the parameter file's 'Default Tool' entry in it's
'.info' file, or by use of multiple selection through the 'Shift' key.

If no parameters are supplied to an executable file, NumPars will return 0.
During program development, the 'CLI Arguement' menu item in the 'COMPILER'
menu allows you to test out CLI parameters.

Par$ (Parameter)

Par$ return a striny equivalent to a parameter passed to an executable file
through either the CLI or Workbench. Please refer to NumPars for more
information on parameter passiny.


FromCLI

Returns TRUE (-1) if your program was run from the CLI, or FALSE (O) if run
from the WorkBench.

ParPath$ (parameter,type)

ParPath$ returns the path that the parameter resides in, 'type' specifies
how you want the path returned:

0 You want only the directory of the parameter returned. 1 You want the
directory along with the parameter name returned.

If you passed the parameter "FRED" to your program from WorkBench, and FRED
resides in the directory "work:mystuff/myprograms" then ParPath$(0,0)
willreturn "work:mystuff/myprograms", but ParPath$(0,1) will return
"work:mystuff/myprograms/FRED".

The way WB handles argument passing of directories is different to that of
files. When a directory is passed as an argument, ArgsLib gets an empty
string for the name, and the directory string holds the path to the passed
directory AND the directory name itself.
Hope this is useful.
uncharted is offline   Reply With Quote
Old 05-26-2006, 12:06 PM   #3
motorollin
Premium Member
Points: 32,860, Level: 100 Points: 32,860, Level: 100 Points: 32,860, Level: 100
Activity: 54% Activity: 54% Activity: 54%
 
motorollin's Avatar
 
Join Date: Nov 2005
Posts: 8,666
Default Re: Blitz Basic: Reading arguments from the command line

Thanks! I didn't think of searching the document for "parameter" :roll: I guess the command I'm looking for is "par$(parameter)". So if I ran the programme like this:

1.>myprog arg1=value

Then the command "str$=par$(arg1)" would set the variable str$ to "value". Right???

Thanks

--
moto
motorollin is offline   Reply With Quote
Old 05-26-2006, 01:00 PM   #4
motorollin
Premium Member
Points: 32,860, Level: 100 Points: 32,860, Level: 100 Points: 32,860, Level: 100
Activity: 54% Activity: 54% Activity: 54%
 
motorollin's Avatar
 
Join Date: Nov 2005
Posts: 8,666
Default Re: Blitz Basic: Reading arguments from the command line

Ok, got it working by using "b$=Par$(1)". Now, is there any way to convert the string variable b$ to a byte variable so I can pass it to the parallel port?

--
moto
motorollin is offline   Reply With Quote
Old 05-26-2006, 01:08 PM   #5
Doobrey
Defender of the Faith
Points: 8,432, Level: 61 Points: 8,432, Level: 61 Points: 8,432, Level: 61
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2002
Posts: 1,876
Default Re: Blitz Basic: Reading arguments from the command line

Try the Val command, it converts a numeric string to an integar.

eg. my_number.b=Val(Par$(1))
__________________
[size=xx-small]On schedule, and suing[/size]
Doobrey is offline   Reply With Quote
Old 05-26-2006, 01:27 PM   #6
motorollin
Premium Member
Points: 32,860, Level: 100 Points: 32,860, Level: 100 Points: 32,860, Level: 100
Activity: 54% Activity: 54% Activity: 54%
 
motorollin's Avatar
 
Join Date: Nov 2005
Posts: 8,666
Default Re: Blitz Basic: Reading arguments from the command line

That works - thanks! :-) I had to add a "%" to the beginning of the string, but then it worked.

When I create an executable from the "Compiler" menu and then run the programme from the shell, it doesn't do anything. The relays don't change. If I run it inside Blitz then it works. Why might this be?

--
moto

--EDIT
Forget that, I think I just had to close the Blitz editor as it was hogging the port. It's all working now :-D :-D :-D Thanks a lot for your help guys!!!
motorollin is offline   Reply With Quote
Reply

Bookmarks

Tags
reading , line , command , blitz , basic , arguments

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitz Basic 2.1 Kevin0001 Amiga Software Issues and Discussion 0 04-27-2008 10:32 AM
Blitz Basic 2.1 Invisix Amiga OS -- Development 4 03-15-2006 07:03 PM
Running Games Command Line nasty General chat about Amiga topics 8 01-06-2006 07:40 AM
Blitz Basic Kinster Amiga Marketplace 1 03-03-2005 03:07 PM
Blitz Basic melott Amiga OS -- Development 7 06-12-2003 08:18 AM