|344 forum posts|
I am using TurboBasic programming language (similar to QBasic) for my workshop CAD activities and as part of the system have a master utilities program linking to a number of standard workshop CAM routines using the QBasic "Chain" command. All works well when Chain is to a fully defined filespec e.g. SLOT.BAS but I would like to be able to incorporate a wild-card "? " in the filespec to indicate file issue status e.g. SLOT?.BAS. but the combination is not being recognised by the CHAIN command. I would be interested to know if there is an answer to this problem.
5089 forum posts
I would think you would need to move the SLOT? bit to a variable string
a$="slot" and then mess with that variable
So you need your file handling command to be capable of opening variables so -
open file a$ needs to work
And then you need to be able to mess with that string, concatenate I believe they call it
where b$ is the variables bit added on
sounds like fun. ugh
Edited By Ady1 on 27/04/2022 11:36:56
|344 forum posts|
Yes, that is what I have been doing, concatenating the wildcard symbol to the stem of the program name to create the filespec but for some reason, the chain command is not recognising the result. Have also tried using the "*" as an alternative wildcard but without success
|Peter Cook 6||27/04/2022 13:09:44|
|275 forum posts|
I don't think you can use a wildcard that way in any case. Chain effectively "opens" the file specified, then transfers control to it. If the filename has a wildcard in it, then Chain doesn't know which of the possible matches (Slot1, Slot2, etc.) in the directory to select.
There is no wildcard that I know of that matches the highest/ latest filename. I think to do what you want, you will need to keep the version data in a separate file (e.g. Slotver.txt ) open that, extract the latest version number and concatenate that version data to the filename before doing the Chain.
The alternative ( and it's a long time since I wrote Basic) might be to read the relevant directory, use string handling to find the highest/most recent version of the file and extract that filename to your variable for the chain command. But I think that involves invoking a batch file to output the directory listing to a text file and working on that.
PS An alternative would be to always use Slot.exe as the latest version and use Slot-1.exe, Slot-2.exe to provide versioning. That way if you open Slot.exe each time you always get the latest version - but it's a faf.
Edited By Peter Cook 6 on 27/04/2022 13:21:18
5089 forum posts
That sounds like the best system to me, read the dir listing to a file handling routine
while dir A >0
open file 1
close file 1
loops until the end of the directory
That's a lot of work methinks, but would be great once it was up and running
One caveat may be- can your basic/windows system tolerate a multiple high speed cycle of accessing and editing files
Edited By Ady1 on 27/04/2022 14:14:46
|Nick Clarke 3||27/04/2022 16:09:33|
1423 forum posts
I suspect that it is not going to be possible as the wildcard is a dos wildcard that will match up with a number of files - but QBasic interprets it by its individual filespec and it can't find a file whose name is SLOT?.BAS only SLOT1.BAS, SLOT2.BAS etc. as ? is a forbidden character in file names.
|583 forum posts|
I don't really know Windows being a Linux guy, but googling "windows expand wildcards" lead me to this page https://docs.microsoft.com/en-us/cpp/c-language/expanding-wildcard-arguments?view=msvc-170#:~:text=Wildcard%20argument%20expansion%20is%20Microsoft,expanded%20in%20command%2Dline%20arguments.
You will have to find how to get the compiler linker to use the correct DLL
You could also look at using PowerShell which does support wildcard expansion.
Edited By AdrianR on 27/04/2022 17:18:37
|344 forum posts|
.Many thanks for all the help provided. I have found a way out of the problem by abandoning the idea of using wild card characters as this appears to be a no-no with the Chain command and have resorted to maintaining the file version status in a separate file and concatenating to the filespec as has been suggested. All is now sweetness and light. Thanks once again
8673 forum posts
May be worse than that. TurboBasic is a compiler, making it possible CHAIN is a fixed linkage. If so, the compiler processes the called program beforehand, and the run time code expects to find the same name and binary image when the link is executed.
CHAIN allows the calling and called programs to share COMMON variables. It's a memory management technique, allowing modules to be loaded at run-time only if needed, allowing the programmer to organise programs bigger than the computer can store as an entity. Important on early computers when 640kB was a low ceiling and DOS didn't manage memory well, but unnecessary now computers have gigabytes of memory and operating systems with sophisticated memory management.
If the requirement is to launch a second program, it's possible Greensands' doesn't want CHAIN at all. Try SHELL. TurboBasic's ancient SHELL code might not work on a modern operating system emulating DOS, but if it does SHELL starts a second program with the operating system, and the operating system should understand wildcards.
For lovers of jargon, the technical term for processing wildcards is globbing.
Please login to post a reply.
Want the latest issue of Model Engineer or Model Engineers' Workshop? Use our magazine locator links to find your nearest stockist!
You can contact us by phone, mail or email about the magazines including becoming a contributor, submitting reader's letters or making queries about articles. You can also get in touch about this website, advertising or other general issues.
Click THIS LINK for full contact details.
For subscription issues please see THIS LINK.