English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Blitz Basic (https://eab.abime.net/forumdisplay.php?f=126)
-   -   [WB1.3] Call as Default tool (https://eab.abime.net/showthread.php?t=106881)

LessNick 07 May 2021 11:46

[WB1.3] Call as Default tool
 
1 Attachment(s)
Hello.

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

http://eab.abime.net/attachment.php?...1&d=1620379715

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.

Daedalus 07 May 2021 16:18

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.

thomas 07 May 2021 18:43

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.

LessNick 08 May 2021 11:24

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?

Daedalus 08 May 2021 20:49

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.

redblade 09 May 2021 00:51

Nice App. I like the iconify icon, did you hardcode the distance from the right hand side?

LessNick 09 May 2021 09:46

Quote:

Originally Posted by Daedalus (Post 1482345)
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 :bowdown

LessNick 09 May 2021 09:59

Quote:

Originally Posted by redblade (Post 1482386)
Nice App.

Thanks.

Quote:

Originally Posted by redblade (Post 1482386)
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 (Post 1482386)
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.

Daedalus 09 May 2021 23:47

Quote:

Originally Posted by LessNick (Post 1482428)
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 :bowdown
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.

LessNick 10 May 2021 11:17

1 Attachment(s)
Quote:

Originally Posted by Daedalus (Post 1482607)
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:

http://eab.abime.net/attachment.php?...1&d=1620637691

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? :shocked

Daedalus 10 May 2021 14:27

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.


All times are GMT +2. The time now is 16:30.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.07057 seconds with 11 queries