English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 07 May 2021, 11:46   #1
LessNick
Amiga

LessNick's Avatar
 
Join Date: May 2021
Location: RB
Posts: 8
Evil grin [WB1.3] Call as Default tool

Hello.

I wrote a small utility in BlitzBasic 2.1 that displays size variants for a selected font.



The utility is called from the font .info file as the default tool. I am getting the filename as an element of the argument list using the Par$(1) command in the code and work with this filename further.

But there is a serious problem. Since the utility is called from another location on the disk (eg Sys:C/), the current path is changed and the filename is not found in this location.

I can hard set the path to the file, for example Sys:Fonts/ and then it works of course.

But this is not correct, because the file(font) can be moved anywhere and everything will stop working.

Actually, the question is how to correctly get the path to the file from which the default tool was called.
Attached Thumbnails
Click image for larger version

Name:	016.png
Views:	158
Size:	18.0 KB
ID:	71824  
LessNick is offline  
Old 07 May 2021, 16:18   #2
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,260
Ordinarily, the function to use is ParPath$(), which gives you the full path corresponding to a given argument. However, the documentation for ParPath$() says that it's OS 2.0+ only, so if you require it to run on OS 1.x, that's not going to work. It's a long time since I coded specifically for 1.3, but from memory, under dos.library from 1.x, this is a little tricky to do because ReadArgs and associated functionality was only added in 2.0.
Daedalus is offline  
Old 07 May 2021, 18:43   #3
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,290
As we are talking about running from Workbench as a default tool, I doubt that ReadArgs has anything to do with it.

Workbench presents its argument to the app as wa_Lock and wa_Name pairs. wa_Lock is a BPTR lock to the directory and wa_Name is the name of the file.

So I assume Par$() in this case only uses the wa_Name part and under OS 2.0+ ParPath$() uses NameFromLock() and AddPart() to combine the directory name and the file name.

However, if there was a means to get access to the wa_Lock part, then you could use CurrentDir() to change the current diectory and then access the file using wa_Name. Then you wouldn't need to care about the directory name. Even better, DOS would assure that you enter exactly the right directory. If you first turn it into a name it could be misleading as there can be multiple volumes with the same name.
thomas is offline  
Old 08 May 2021, 11:24   #4
LessNick
Amiga

LessNick's Avatar
 
Join Date: May 2021
Location: RB
Posts: 8
Thanks for answers. I understand that Blitz Basic running under WorkBench 1.3 has a functional limitations. Since after trying to call ParPath$(), the program just hangs.

Perhaps there are any third party libraries that could help?
LessNick is offline  
Old 08 May 2021, 20:49   #5
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,260
Thanks for the clarification Thomas

Yep, if it uses certain system calls that were only introduced in 2.0, that will limit the use of those commands and functions. The LotanArgs 3rd party library includes alternative functions for getting arguments: WBArgs will return the number of arguments passed, and wArg(x) will return the referenced argument. The documentation doesn't specify a particular OS version so it's worth trying, but it's possible that it will have the same limitations regardless.
Daedalus is offline  
Old 09 May 2021, 00:51   #6
redblade
Zone Friend

redblade's Avatar
 
Join Date: Mar 2004
Location: Middle Earth
Age: 37
Posts: 1,743
Nice App. I like the iconify icon, did you hardcode the distance from the right hand side?
redblade is offline  
Old 09 May 2021, 09:46   #7
LessNick
Amiga

LessNick's Avatar
 
Join Date: May 2021
Location: RB
Posts: 8
Big grin

Quote:
Originally Posted by Daedalus View Post
The LotanArgs 3rd party library includes alternative functions for getting arguments: WBArgs will return the number of arguments passed, and wArg(x) will return the referenced argument.
Thank you so much. Perhaps this will really help solve the problem.
It remains to find the correct library version and figure out how to include to the project.

Could you give a small example, if it's strain to you
LessNick is offline  
Old 09 May 2021, 09:59   #8
LessNick
Amiga

LessNick's Avatar
 
Join Date: May 2021
Location: RB
Posts: 8
Big grin

Quote:
Originally Posted by redblade View Post
Nice App.
Thanks.

Quote:
Originally Posted by redblade View Post
I like the iconify icon
If you are talking about the third button, then this is a resident - Zoom-Daemon. It allows you to maximize the window to full screen.

Quote:
Originally Posted by redblade View Post
I like the iconify icon, did you hardcode the distance from the right hand side?
I use simple default commands:

LoadFont 0 "FontName"
WindowFont 0
NPrint "Example Text"

But I suspect that I will have change to the version for print on bitmap.
LessNick is offline  
Old 09 May 2021, 23:47   #9
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,260
Quote:
Originally Posted by LessNick View Post
Thank you so much. Perhaps this will really help solve the problem.
It remains to find the correct library version and figure out how to include to the project.
If you use the version of Blitz in the Ultimate Blitz Basic CD, it already has the optimum versions of most libraries set up by default, and likewise for AmiBlitz 3. If you're using an older version of Blitz 2.1, check out the Extras floppy - it should still have a version of that library, even if it's not the latest.

Quote:
Could you give a small example, if it's strain to you
Code:
wbmsg.l = wbmessage ; Get pointer to Workbench message
If wbmsg ; Launched from WB
  numargs.l = WBArgs ; Always returns at least 1, since program's path is first argument
  For i.w = 0 To numargs - 1 ; wArg(0) is program's own path
    x.l = Request( "Test", "Parameter " + Str$(i) + ":|" + wArg(i), "Ok")
  Next i
Else
  NPrint "Start from Workbench!"
End If
End
Note, I've only tested it under OS 3.9 so I've no idea if it will work under 1.3.
Daedalus is offline  
Old 10 May 2021, 11:17   #10
LessNick
Amiga

LessNick's Avatar
 
Join Date: May 2021
Location: RB
Posts: 8
Red face

Quote:
Originally Posted by Daedalus View Post
If you use the version of Blitz in the Ultimate Blitz Basic CD
I use "Ultimate Blitz Basic 2.1 (1997)(Acid Software).iso"
Also try to create bootable Floppy with help "BlitzISOtoFloppy"

And anyway i got an error:



Compiler does not know wArg(i) as I understand.

And it is not entirely clear to me whether this is a problem precisely because of WB1.3, or the libraries path are not correct.

Maybe i need to somehow specify the lib path for example using INCLUDE in the project head?
Attached Thumbnails
Click image for larger version

Name:	BB2_001.png
Views:	50
Size:	9.7 KB
ID:	71861  

Last edited by LessNick; 10 May 2021 at 11:26.
LessNick is offline  
Old 10 May 2021, 14:27   #11
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,260
That's because your Blitz installation doesn't include the Lotan DOS library (and the Elmore libraries containing the Request() function). It looks like you're using the default installation - I think the documentation gives details on adding libraries to the setup, but it involves using a tool to add them to the "deflibs" file that contains all the commands Blitz can use. I vaguely remember there also being a way of adding libraries to a folder to add individually, but I can't remember the details... Anyway, check the documentation - the basic installation is intended for floppy-only use (and the BlitzISOToFloppy tool simply recreates the floppies from the files on the CD). As such, it's very minimal and contains only the most basic components.

If you check the Extras drawer, you should find files with updated components, such as a bigger deflibs file that I think will contain the commands you need, a better debugger and so on. Try the bigger deflibs file anyway, see how that goes. Using Include is for including other Blitz source files, not command libraries which are loaded by Blitz when it starts, and can't be loaded by your code.

As an aside, is there a reason you're using OS 1.3? Using OS 2+ allows you to use a much nicer editor, AmigaGuide documentation and so on. Additionally, there's a [http://ubb.plus/]revised version of the Blitz CD ISO[/url] which includes all the latest updates as well as a fixed installer, but you really need OS 2 to get the most from it.
Daedalus is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set default tool? fstltna support.Other 4 19 April 2019 21:31
Default tool for graphic files? fstltna support.Other 5 22 July 2017 23:42
What is the default WB1.3 system font called? Blitter New to Emulation or Amiga scene 9 12 October 2009 09:28
HELP! How to change icon default tool in WB buckrogers New to Emulation or Amiga scene 18 07 March 2005 05:27
The icon(s) have no default tool(s) !!!! THX1138 support.Apps 5 08 March 2003 03:00

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


All times are GMT +2. The time now is 06:10.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.09355 seconds with 15 queries