KEVIN HEDIN
KEVIN HEDIN

Reputation: 21

'modifying' an exe by working with bas using visbasic or q basic

all!

I'm trying to run programs to control stepper motors. The PC and software and stepper motor controller I have already in place are pretty old and I'm new to almost everything I'm doing here-learning as I go sort of thing. I've 'coded' a bit in Matlab, so I have a very basic level of coding logic, but basically no knowledge of any common syntax. So, I know some about the steppers and the stepper controller, but not much else!

I have a program called "Hoop.exe" that I'm trying to modify to slow down the speed of one of the steppers (I just need to change a 300 to a 200!) when I run the program. There is also an associated (assuming) hoop.bas and a hoop.txt file on the floppy disc. From looking at the txt file, it looks like basic code from examples of basic I've seen. I'm working with visual basic 2.0 and qbasic 1.1 on Windows 98.

So, I tried opening the hoop.bas file first with qbasic and with vb. With qb, I get a 'bad file mode' message. With vb, I get 'invalid file format' and it seems it wants me to open a mak file but I have no 'hoop.mak'. I did this thinking that I could open the bas file with vb or qb, and then edit it, and then save it as an exe, and then run that.

I found a pdf that showed how to incorporate a qb file into the command button of vb, and I tried that. But, I got an "Expected: end of statement" error in the first line! when I tried to save it as an exe.

So, all I really want to do is change my hoop.exe. I would assume that since qb and vb are both on the PC, one of them wrote the bas (maybe not!), so I'm wondering why neither of them can read it.

I've never used vb or qb, but if I have to get into the nitty gritty, it seems like I'd rather use qbasic, since I've never used a graphical interface to code before. But, is either one of those necessary in order to do what I want to do? (I'm going to need to write some programs to control these steppers when all is said and done, but I figured that I should take it one step at a time.)

I tried some form of copying and pasting into qb, but I couldn't immediately figure out how to do that. (Probably because I have no idea how to use qb.)

So, what would be the most efficient way to modify my hoop program?

If the answer is that I just need to learn basic with qb, that's fine, but I'd like to get some sort of indication from people who know what they're talking about before I put that much effort in.

I would really appreciate any pointers because I'm apparently completely clueless on my own!

8/10/2013:

Just in case it's helpful, here are some lines from the Hoop.txt I opened:

10 CLS : CLEAR 1000: P = 512

20 LOCATE , , 1

100 A% = INKEY$: PRINT A$;

105 IF A$ = "*" THEN GOTO 700

110 GOSUB 510: GOSUB 610: GOTO 100

500 REM

510 IF A$ = "" THEN RETURN

etc. This is the beginning of the interface code that allows me to talk to the motor controller

Upvotes: 2

Views: 757

Answers (2)

Icemanind
Icemanind

Reputation: 48726

QuickBASIC and Visual Basic are very different, despite their common name of "BASIC" and despite the fact they were both made by Microsoft. First you need to determine if the .BAS file is QuickBASIC or Visual Basic. A simple quick way (though not the most accurate) is to open the file in Notepad or some other text editor. If keywords such as OPEN or CLOSE or LEN or MID are in uppercase, then it's more likely a QuickBASIC file. If the keywords look more like Open or Close or Len or Mid, then it's more likely a Visual Basic file.

Now keep in mind that there are other versions of BASIC that have been developed, such as Turbo BASIC (Borland's version) or GW-BASIC or BasicA or PowerBASIC and even Color Basic.

Now if you can't figure it out this way, the next thing I'd suggest is downloading a hex editor, such as XVI32 (though there are many other free ones out there). Look through the file (especially towards the end of the file) and there are usually signs that indicate what kind of compiler was used. You might see the words "Microsoft Basic Compiler" or "Borland Turbo Compiler". Usually towards the end of the file, there are string "stubs" put in by the compiler or linker that you can use to determine the compiler.

If all that fails and you are desperate and that "300" number is hard coded in the program and you need to change it, then there is another way to do this. First back up your original exe file. Then use XVI32 or some other hex editor and search for the string "2C01" (300 is 012C in hex and you need to reverse the 01 and 2C since Intel machines are little-endian). Once you find an instance of 2C01, change it to "C800" (200 is 00C8 in hex and the little-endian version would be C800). Save the file, then rerun it. This is a gruesome trial and error way to fix this. If it was changed from 300 to 200, then everything is good! If not, restore from your backup and try again (with another instance of "2C01")!

Upvotes: 2

Claudio
Claudio

Reputation: 2217

Have you considered getting an Arduino or some other low cost and friendly electronics development platform? I think it would be the way to go for you to control stepper motors... take a look:

http://arduino.cc/en/Tutorial/StepperUnipolar

If you google around you'll find tons of you tube videos showing off some arduino controlled stuff.

Modifying your current .exe seems to me a too long and hard path to follow instead of making your own and proper source code for achieving what you want, as you would need to disassemble the executable file and literally "know what you're doing" with all that assembly language to find where to patch the binary with the right value.

Anyway, if you post a picture or a schematic of your old hardware I could try to help you a little more, but I guess that would be better suited to this other stack exchange site: http://electronics.stackexchange.com

Upvotes: 0

Related Questions