QBasic Forum BASIC Discussion Board

[QB FAQ] [QB Archives, Links and Downloads] [Subforums and Chat Room] [Search]

Run QBasic Code on Modern Systems:  QB64   Post Code or Ask for Help:  Post Code   Homework Policy



Homework help please

by (no login)

I need help with a Basic Sales program.
$10,000= base salary
%10= commission
$500 extra pay if gross sales are over $80,000
Compute and output the amounts earned by each of these salespeople:

employees Gross sales
Knox $90,000
Turbin $70,000
Phillips $20,000
Rob $95,000
Wally $40,000
I need to print a paystub that shows: employee names, gross sales, commission, and gross pay for each employee.
Must use: trip codes,loops,read/data,formulas, conditions
Print and underline headings and center theoutput horizontally on the page, columns must be centered beneath each heading

Posted on Apr 27, 2012, 2:11 PM

Respond to this message   

Return to Index


You might want to read this post

by Docfxit (Login Docfxit)
R

Posted on Apr 27, 2012, 2:14 PM

Respond to this message   

Return to Index


Homework help please

by Bee (no login)

CLS
Read Names$,SALES
Do While Names$ <> "xxx"
Comm=SALES * .10
if SALES =>80000 then Bonus = 500 else Bonus=0
Salary =Comm + Bonus + 10000
GT= Gross + SALES
Print Names$,SALES,Comm,Bonus,Salary
Read Names$,Salary
Loop
Print,,,"Employee name,SALES,Comm,GT"
Print,,,"------------,-------,------,----"
Data "Heather",90000,"Sam",70000,"Dan",20000,"Robert",95000,"Lew",40000
End
Everytime I try to RUn the program, it tells me that my C++ compilation failed

Posted on Apr 28, 2012, 11:49 AM

Respond to this message   

Return to Index


You must be using an older version of QB64.

by (Login MCalkins)
Moderator

The current version, 0.954, runs the program, but it has an "Out of DATA" error on line 9.

Please upgrade:
http://www.qb64.net/forum/index.php?topic=6007.0

There are problems with your program, but I'll address them later this evening unless someone beats me to it.

Regards,
Michael

Posted on Apr 28, 2012, 4:52 PM

Respond to this message   

Return to Index


Re: You must be using an older version of QB64.

by Bee (no login)

My professor gave his students this program. He wants us to use it

Posted on Apr 28, 2012, 7:25 PM

Respond to this message   

Return to Index


What version are you using?

by (Login MCalkins)
Moderator

Go to the "Help" menu, and click "About". If you don't have a "Help" menu, it should be under the "Options" menu. If it's anything less than 0.954, I'd suggest advising your professor to let you upgrade. If he doesn't let you, I'd be curious to hear the reason...

Regards,
Michael

Posted on Apr 28, 2012, 8:25 PM

Respond to this message   

Return to Index


Display corrected

by Solitaire (Login Solitaire1)
S

I rearranged some of your statements so that it will display properly. You had the headings wrong -- each of the titles and underlines should be enclosed separately within quotation marks, with commas in-between. That should be done before starting the DO loop. You do not need the READ statement before starting the loop.

I believe you meant to read the Sales, not the Salary, so I made that change in the READ statement. Also, you don't have any data with "xxx" so I changed it to the last name - "Lew" Remember, your data needs to match the number of items in the READ statement or you will get an "Out of Data" error.


CLS
PRINT "Employee name", "SALES", "Comm", "Bonus", "Salary"
PRINT "-------------", "-----", "----", "-----", "------"
DO WHILE Names$ <> "Lew"
READ Names$, Sales
Comm = Sales * .1
IF Sales >= 80000 THEN Bonus = 500 ELSE Bonus = 0
Salary = Comm + Bonus + 10000
GT = Gross + Sales
PRINT Names$, Sales, Comm, Bonus, Salary
LOOP
DATA "Heather",90000,"Sam",70000,"Dan",20000,"Robert",95000,"Lew",40000
END

Posted on Apr 28, 2012, 6:37 PM

Respond to this message   

Return to Index


"xxx"

by Bee (no login)

my professor wanted me to use a trip-code, so that was the only reason why I used it.

Posted on Apr 28, 2012, 7:27 PM

Respond to this message   

Return to Index


terminal marker (trip code)

by Solitaire (Login Solitaire1)
S

If you use it, then you must also add a dummy number value (like 0) or you will get an error, since you are reading data in pairs. You also need to place the code in an IF block to print the results, otherwise it will print the dummy values.

IF Names$ <> "xxx" THEN PRINT Names$, etc.

Posted on Apr 28, 2012, 8:41 PM

Respond to this message   

Return to Index


Have a look...

by (Login MCalkins)
Moderator

CONST basePay = 10000
CONST factorCommission = .1
CONST bonusPay = 500
CONST bonusTrip = 80000

DIM sales AS LONG
DIM names AS STRING
DIM comm AS LONG
DIM salary AS LONG

CLS
PRINT "Employee name", "SALES", "Comm", "Pay"
PRINT "-------------", "-----", "----", "---"
DO
 READ names
 IF "xxx" = names THEN EXIT DO
 READ sales
 comm = sales * factorCommission
 salary = comm + basePay
 IF sales > bonusTrip THEN salary = salary + bonusPay
 PRINT names, sales, comm, salary
LOOP
END

DATA "Heather",90000,"Sam",70000,"Dan",20000,"Robert",95000,"Lew",40000,"xxx"


-----

I've added "xxx".

There were several ways of dealing with it. You could, as you had it originally, READ the values once before entering the loop, test at the beginning of the loop, and then read again at the end of the loop. Or, you could do something like what Solitaire suggested. As you can see, I've gone for a third option, of not putting the condition on the loop at all, but putting it inside the loop. Further, I don't have to put a , 0 after "xxx" on the DATA line, because I'm reading sales after the test.

What was GT for?

Also, the assignment didn't ask you to print the Bonus separately. By moving the IF so that it is after the initial assignment of Salary, you can just add to Salary, and get rid of the the Bonus variable. Actually, if you wanted to get rid of the IF altogether, you could change:

salary = comm + basePay
IF sales > bonusTrip THEN salary = salary + bonusPay

to:

salary = comm + basePay + (bonusPay AND sales > bonusTrip)

which relies on the fact that AND is a bitwise operator, and the relational operators (which have higher precedence than the bitwise operators) return -1 (all bits 1) for true.

Either way, notice that it should be > instead of >=, as your assignment said "if gross sales are over $80,000".

As you can see, I've replaced the literal constants in the program logic with symbolic constants. If your professor wouldn't like that, you can change them back.

I'm disappointed that your professor is not teaching you to DIM your variables... :-( When you move on to C++, you will have to explicitly define your variables, and I would consider it good practice even in BASIC, although BASIC doesn't require it.

The DATA statement is not executable, so it can be after the END.

As Solitaire pointed out, your second READ statement was reading into Salary when it should have been reading into Sales, but I've taken it out anyway.

Your assignment says "center theoutput horizontally on the page, columns must be centered beneath each heading". I don't think any of the code posted so far does that. I'm not sure exactly what needs to be done.

I think it would involve taking the width of the screen/page, which is 80 columns, dividing it by the number of output columns, 4, + 1, so 5. That's 16. So, you might center the name around column 16, the sales around column 32, the commission around column 48, and the pay around column 64.

To center the name around column 16 might involve something like:

locate , 16-len(names)\2
print names;

For a number, you might use LTRIM$(STR$()) on it, and you might want a temporary string:

dim t as string

...

t = ltrim$(str$(sales))
locate , 32 - len(t)\2
print t;

Regards,
Michael

Posted on Apr 28, 2012, 9:15 PM

Respond to this message   

Return to Index


centered text... (spoiler - contains code - try writing it yourself before opening.)

by (Login MCalkins)
Moderator

Aside from everything related to text centering, I also changed the trip value to "", so I can now just test for a length of zero.

Regards,
Michael

-----

'don't turn this in as yours, but you might use it as an example.

CONST basePay = 10000
CONST factorCommission = .1
CONST bonusPay = 500
CONST bonusTrip = 80000

CONST scrColumns = 80
CONST outColumns = 4

CONST hyphen = &H2D

CONST nameColumn& = 1 * scrColumns / (outColumns + 1)
CONST salesColumn& = 2 * scrColumns / (outColumns + 1)
CONST commColumn& = 3 * scrColumns / (outColumns + 1)
CONST payColumn& = 4 * scrColumns / (outColumns + 1)
'I'm using the & to force them to LONG. Since I can't use \, they would
'otherwise be floating point.

DIM sales AS LONG
DIM names AS STRING
DIM comm AS LONG
DIM salary AS LONG
DIM t AS STRING 'temporary string

CLS

t = "Employee name"
LOCATE 1, nameColumn - LEN(t) \ 2
PRINT t;
LOCATE 2, nameColumn - LEN(t) \ 2
PRINT STRING$(LEN(t), hyphen);

t = "Sales"
LOCATE 1, salesColumn - LEN(t) \ 2
PRINT t;
LOCATE 2, salesColumn - LEN(t) \ 2
PRINT STRING$(LEN(t), hyphen);

t = "Comm"
LOCATE 1, commColumn - LEN(t) \ 2
PRINT t;
LOCATE 2, commColumn - LEN(t) \ 2
PRINT STRING$(LEN(t), hyphen);

t = "Pay"
LOCATE 1, payColumn - LEN(t) \ 2
PRINT t;
LOCATE 2, payColumn - LEN(t) \ 2
PRINT STRING$(LEN(t), hyphen)
'last print doesn't use a semicolon

DO
 READ names
 IF 0 = LEN(names) THEN EXIT DO
 READ sales
 comm = sales * factorCommission
 salary = comm + basePay + (bonusPay AND sales > bonusTrip)

 display nameColumn, names
 display salesColumn, LTRIM$(STR$(sales))
 display commColumn, LTRIM$(STR$(comm))
 display payColumn, LTRIM$(STR$(salary))
 PRINT ' to move the cursor to the next line
LOOP
END

DATA "Heather",90000,"Sam",70000,"Dan",20000,"Robert",95000,"Lew",40000,""

SUB display (column AS LONG, txt AS STRING)
LOCATE , column - LEN(txt) \ 2
PRINT txt;
END SUB

Posted on Apr 28, 2012, 10:12 PM

Respond to this message   

Return to Index


Can't get LastErrorLine to print to the screen

by Docfxit (Login Docfxit)
R

Could someone please help me get LastErrorLine to print to the screen.



[code]
CONST portNum = 1
DIM ErrorCode AS INTEGER
DEFINT A-Z ' all ints unless otherwise specified

ON ERROR GOTO ErrorHandler

'Debugline next three lines
var1$ = "B4 OpenWsPort - portNum = "
var2 = portNum
ERROR 155

ErrorHandler:
ErrorCode = ERR

SELECT CASE ERR
CASE 155: LastErrorLine = ERL
CASE ELSE: PRINT "Error code "; ErrorCode; " on line "; _ERRORLINE
END Select

IF ERR = 155 THEN 'Debug
'** Print line and variable to screen
COLOR 11, 0: LOCATE Ix, 1: PRINT LastErrorLine; "var1"; " = "; var1$; var2 ' for debugging only
Ix = Ix + 1
END IF

RESUME NEXT
[\code]

Posted on Apr 27, 2012, 12:53 PM

Respond to this message   

Return to Index


Re: Can't get LastErrorLine to print to the screen

by (Login Docfxit)
R

Hi have discovered when I replace ERL with _ERRORLINE

It works.

ERL doesn't work.

Thanks,

Docfxit

Posted on Apr 27, 2012, 3:37 PM

Respond to this message   

Return to Index


More homework !

by (no login)

I want to "tamper" (?) this sort of line (CSV), for 4 characters in each cell, without any separation. All leading zeros should be replaced by spaces, if any...

CSV :

99;5,44;5,95;38,00;8,31;0,70;0,28;0,36;11,37;1,28;28,31

Since formating here doesn't deal with space, i can't post the result..

example:

0099 is the firts "cell", replacing 0 with " "

DIM Cell AS STRING * 4

i just wondering if there is a classic way for doing that. It seems to me i have read about this here before here.


L

Posted on Apr 26, 2012, 1:17 AM

Respond to this message   

Return to Index


*Of course i do it myself :)

by (no login)

*

Posted on Apr 26, 2012, 1:49 AM

Respond to this message   

Return to Index


* t$=str$(n): t$=space$(4-len(t$))+t$

by (Login MCalkins)
Moderator

Posted on Apr 26, 2012, 2:13 AM

Respond to this message   

Return to Index


Thanks, correct word was "padded"

by (no login)

http://www.dbf2002.com/dbf-file-format.html

Field name with a maximum of 10 characters. If less than 10, it is padded with null characters (0x00).

L

Posted on Apr 26, 2012, 2:42 AM

Respond to this message   

Return to Index


* t$=string$(10-len(t$), 0)+t$

by (Login MCalkins)
Moderator

Posted on Apr 26, 2012, 2:50 AM

Respond to this message   

Return to Index


*VAL() only returns integer part of string ?

by (no login)

*

Posted on Apr 26, 2012, 4:41 AM

Respond to this message   

Return to Index


no...

by (Login MCalkins)
Moderator

Example:

PRINT VAL("2.54")

I'm a bit confused. Where are you getting VAL()?

If you want only the integer part, you could use CINT(), CLNG(), INT(), or FIX(), whichever suits your needs.

Regards,
Michael

Posted on Apr 26, 2012, 6:01 AM

Respond to this message   

Return to Index


Val(0)

by (no login)

I used :


VAL(5,45)

Output was 5, so maybe the comma is the culprit...

L

Posted on Apr 26, 2012, 8:18 AM

Respond to this message   

Return to Index


Homework help

by (no login)

I need a program that tells me how many numbers are negative and how many are positive and zero.
have to use read and date statements
must incorporate loops, reads, tripcodes, etc.
i cant change the order of the data elements
use 21 as trip code
the output should be centered on page and values centered under headings


DATA 10, 2,0,-6.5,72,60,1,61,4,-80,-14,90,89,100,-42,17,55,48,21.

Thanks.

Posted on Apr 25, 2012, 6:20 PM

Respond to this message   

Return to Index


Did you read the Homework Policy?

by Solitaire (Login Solitaire1)
S

If you need help, post your code and point out which part of it is giving you trouble.

No one here will do your homework for you.

Posted on Apr 25, 2012, 8:13 PM

Respond to this message   

Return to Index


Homework help

by (no login)

This is what I have and the message is "compilation failed"

I know this is very basic but it is only part of all subjects what I took
Thanks



REM P = Positive
REM N = Negative
REM Z = Zero
REM Number = A number in the list

CLS
P = 0
N = 0
Z = 0

READ Number
DO WHILE < > 21
IF Number > 0 then P=P+1
IF Number < 0 then N=N+1
IF Number = 0 then Z=Z+1
READ Number
PRINT "Positive"; "Negative"; "Zero"
LOOP
DATA 10,2,0,-6,5,72,60,1,61,4,-80,-14,90,89,100,-42,17,55,48,21.
END

Posted on Apr 26, 2012, 3:54 PM

Respond to this message   

Return to Index


Corrected code:

by Solitaire (Login Solitaire1)
S

First mistake: You omitted the variable name with the DO WHILE condition. It should be:
DO WHILE Number <> 21

You should not have READ Number more than once, only inside the DO loop.

Print the results AFTER the end of the LOOP:

PRINT "Positive"; P
PRINT "Negative"; N
PRINT "Zero"; Z

Posted on Apr 26, 2012, 4:24 PM

Respond to this message   

Return to Index


centering the text

by (Login MCalkins)
Moderator

on a line could be done with something like:

locate , 40 - len(t$) \ 2
print t$

Regards,
Michael

Posted on Apr 26, 2012, 8:12 PM

Respond to this message   

Return to Index


I'll gladly fail your homework for you

by Jonathan (no login)

I'll so drop the F-bomb all over your report card but I'll just write it off as practice.

Posted on May 7, 2012, 1:57 PM

Respond to this message   

Return to Index


fooled again

by (no login)

By line breaks.

All lines seemed Ok in Vim, but the line breaks were 0A. Usually it should be 0D 0A. So for a single LINE INPUT statement, all content was processed, as in a unwanted loop !

I just need to format a CSV for a factorial analysis program...

L

Posted on Apr 24, 2012, 11:35 AM

Respond to this message   

Return to Index


Should have used Emacs

by Anonymus of Hungary (no login)

C-x <RET> f dos <RET>

To set line break style to CR-LF.

Make changes.

C-x C-s
to save

Posted on Apr 24, 2012, 7:01 PM

Respond to this message   

Return to Index


.emacs

by (no login)

Thanks, i had a nice setup before with emacs, also because someone here posted a valuable color-syntax highlighting file for Qbasic in emacs (qb64-mode.el).

Vim has some flaws, when it comes to displaying big lines for example.

Posted on Apr 25, 2012, 7:53 AM

Respond to this message   

Return to Index


*works great :)

by (no login)

*

Posted on Apr 25, 2012, 8:45 AM

Respond to this message   

Return to Index


Pi

by (no login)

Hi all,

I get a paremeter type mismatch, why ?

DIM PI AS LONG
DIM A AS LONG
DIM B AS LONG
DIM C AS LONG

DECLARE SUB P (PI, A, B, C, count, n)


' intitialisation

CLS
n = 0
PI = 0: A = 1: B = SQR(1 / 2): C = 1 / 4

count = 5 ' max = 10

' Call P, 1 time

CALL P(PI, A, B, C, count, n)
PRINT PI

END

'SUB //////////////////////

SUB P (PI, A, B, C, count, n)


' n = n + 1
IF n >= count THEN EXIT SUB

PI = ((A + B) ^ 2) / (4 * C)

CALL P(PI, (A + B) / 2, SQR(A * B), C - 2 * (((A - B) / 2) ^ 2), count, n + 1)

END SUB






Posted on Apr 19, 2012, 3:04 PM

Respond to this message   

Return to Index


Re: Pi

by (Login MCalkins)
Moderator

Because you are passing LONGs by reference to a SUB that wants SINGLEs.

Try something more like this:

Regards,
Michael


DECLARE SUB P (PI AS DOUBLE, A AS DOUBLE, B AS DOUBLE, C AS DOUBLE, count AS LONG, n AS LONG)
DIM PI AS DOUBLE
DIM A AS DOUBLE
DIM B AS DOUBLE
DIM C AS DOUBLE
DIM count AS LONG
DIM n AS LONG


' intitialisation

CLS
n = 0
PI = 0#: A = 1#: B = SQR(1# / 2#): C = 1# / 4#

count = 5 ' max = 10

' Call P, 1 time

CALL P(PI, A, B, C, count, n)
PRINT PI

END

'SUB //////////////////////

SUB P (PI AS DOUBLE, A AS DOUBLE, B AS DOUBLE, C AS DOUBLE, count AS LONG, n AS LONG)


' n = n + 1
IF n >= count THEN EXIT SUB

PI = ((A + B) ^ 2#) / (4# * C)

CALL P(PI, (A + B) / 2#, SQR(A * B), C - 2# * (((A - B) / 2#) ^ 2#), count, n + 1)

END SUB

Posted on Apr 19, 2012, 3:27 PM

Respond to this message   

Return to Index


SIngle

by (no login)

Yes, i knew that yesterday before sleeping.. i wanted to use Single and typed Long.

Anyway the result is not Pi ,it's 3,4. i have to check the equation.

But it's working almost !

Thanks, L

Posted on Apr 20, 2012, 1:28 AM

Respond to this message   

Return to Index


Re: SIngle

by (Login MCalkins)
Moderator

The recursive function eats stack space in a hurry. count and n probably should both have been INTEGERs. And, obviously, using SINGLEs instead of DOUBLEs would let you get more function calls before running out of stack.

Couldn't you rewrite it to use a loop instead of a recursive function? That way, you wouldn't be so constrained by the stack.

Regards,
Michael

Posted on Apr 20, 2012, 2:27 AM

Respond to this message   

Return to Index


?

by (no login)

You can't be serious : I swore loyalty for ever to recursion , and before i rewrite this golden hieroglyphs to silly loops (which i hate), i rather do sebukko. Loops are the evil, see Dante's inferno : Only loops, 9 exactly. Loops are stoopid, recursion is smart.

I wrote to my father to check the algorithm against compromission.

L

Posted on Apr 20, 2012, 3:20 AM

Respond to this message   

Return to Index


fixed !

by (no login)

I managed to read my own handwrting :

CALL P(PI, (A + B) / 2#, SQR(A * B), C - 2# ^ n * (((A - B) / 2#) ^ 2#), count, n + 1)

Now it works !


Posted on Apr 20, 2012, 3:44 AM

Respond to this message   

Return to Index


* count limit is 24 due to stack space limit, however this is ok

by (no login)

*

Posted on Apr 20, 2012, 3:51 AM

Respond to this message   

Return to Index


Re: ?

by (Login MCalkins)
Moderator

Yes, I am serious.

I guess if you want to be prejudiced against a perfectly good programming construct, I guess that's your business. However, I am quite sure that using a loop is vastly superior to using a recursive function in this instance.

Given the fact that pi is found to near the precision limit of a DOUBLE within about 5 iterations, it is probably unnecessary to really exceed that.

However, here is the program using a loop. It should be vastly more efficient in both space and time:

count = 200 is silly, but it demonstrates the lack of stack constraint.

Regards,
Michael

DIM PI AS DOUBLE
DIM A AS DOUBLE
DIM B AS DOUBLE
DIM C AS DOUBLE
DIM oA AS DOUBLE
DIM count AS LONG
DIM n AS LONG

CLS
n = 0
PI = 0#: A = 1#: B = SQR(1# / 2#): C = 1# / 4#

count = 200

DO UNTIL n >= count
PI = ((A + B) ^ 2#) / (4# * C)
C = C - 2# ^ n * (((A - B) / 2#) ^ 2#)
oA = A
A = (A + B) / 2#
B = SQR(oA * B)
n = n + 1
LOOP
PRINT PI

END

Posted on Apr 20, 2012, 12:21 PM

Respond to this message   

Return to Index


re: re: single

by (Login MCalkins)
Moderator

Those parameters are passed by reference, therefore each parameter takes the size of a pointer (probably a far pointer) on the stack, regardless of the size of the value...

Regards,
Michael

Posted on Apr 20, 2012, 12:07 PM

Respond to this message   

Return to Index


The printer topic

by (Login stealth98)

Dear Forum members

Like most of us use QBasic for many years and don't want to lose or reprogram applications because newer operatingsystems don't support the good old QBasic anymore.

As many of you I've found this website because I own and support a Qbasic 4.5 application which I want to update so it's compatible with Windows Vista and newer Windows versions.

The application I have uses "Open LPTn" for 3 printers, and the shell solution isn't a real option since the application also handles errors with regards to printing failures.

Last year I've started to recode my application with Freebasic but this is very intensive because the syntaxes aren't fully compatible with QBasic. Today I've found QB64 and initially I was very happy because potentially I thought that I was able to recompile my code easily. However I got dissappointed because QB64 has very poor support for printing while most QBasic application of the past are written to use one or more LPT printers. I've searched the forum, but didn't find any sound solution for printing. Freebasic supports both LPTn and Operating system printers natively which is great.

I've decided to draft this topic because I would like to know whether or not it's realistic that support for printing (OS printers only will be fine) will be available soon within QB64, or recoding applications in Freebasic is the only real option.

Best regards
QB addict

Posted on Apr 5, 2012, 1:33 AM

Respond to this message   

Return to Index


printer issues

by (no login)

I'm using qbasic running with windows xp. Every thing is ok except I can't print the program listing. The second issue is I'm trying to use the INP statement to read the lpt1 printer port. It does not work. I use the printer port address 888,634 etc that were used by the older IBM pc's. When I used Basica every thing worked fine.

Any Ideas?
Leon Schrecengost

Posted on Apr 10, 2012, 6:19 PM

Respond to this message   

Return to Index


What kind of code are you using?

by (Login burger2227)
R

QB64 may not support LPTn unless the parallel printer is set up on a network. LPRINT should work on USB or LPT printers.

There are also ways to manipulate a printer port using INP and OUT with a DLL Library:

http://qb64.net/wiki/index.php?title=Port_Access_Libraries

Posted on Apr 11, 2012, 8:43 AM

Respond to this message   

Return to Index


printer issues

by (no login)

I'm not running QB64 just QB

Posted on Apr 12, 2012, 1:55 PM

Respond to this message   

Return to Index


Post some example of your code being used

by (Login burger2227)
R

XP blocked port access in some situations. You may need Port Talk to work with the LPT port so I need to see what you are trying to do.

Posted on Apr 12, 2012, 6:40 PM

Respond to this message   

Return to Index


printer issues

by Leon Schrecengost (no login)

This is a short program to monitor input ports on LPT1 and LPT2 i HAVE 2 printer cards.

10 CLS
11 IF INKEY$ IS "E" THEN 110
20 LOCATE 4,10 : PRINT INP(632)
30 LOCATE 6,10 : PRINT INP(633)
40 LOCATE 8,10 : PRINT INP(634)
50 LOCATE 10,10 : PRINT INP(888)
60 LOCATE 12,10 : PRINT INP(889)
70 LOCATE 14,10 : PRINT INP(890)
80 LOCATE 16,10 : PRINT INP(956)
90 LOCATE 18,10: PRINT INP(957)
100 LOCATE 20,10 : PRINT INP(958)
105 GOTO 11
110 END

Posted on Apr 13, 2012, 6:33 AM

Respond to this message   

Return to Index


You'll need PortTalk to monitor them on an XP

by (Login burger2227)
R

Read the instructions to install it and register it with NTVDM. Virtual DOS blocks port access. Newer machines don't have DOS so you would need to add DOSBOX or FREEDOS.

PortTalk requires you to run an EXE program when you assign the port base address to read. Once it is enabled, it can read the other addresses on that register like 0x378(hex must be used to access) can also read 889 and 890. This will work until the next reboot.

QB64 can use INPOUT32.DLL to read with INP32 and OUT32. I gave the link above.

Posted on Apr 13, 2012, 1:27 PM

Respond to this message   

Return to Index


printer issues

by Leon Schrecengost (no login)

Thanks for the info. How do I get porttalk? Is it a download. Is there a way to embed it in the program so it will be there when you rebot? I'm 72 and not a computer genius. Thanks for your patients.

Posted on Apr 13, 2012, 2:09 PM

Respond to this message   

Return to Index


PortTalk

by (Login burger2227)
R

http://dl.dropbox.com/u/8440706/porttalk22.zip

Read the Readme.txt file. You must click on the REG file to install it to registry while administrator on Windows XP.

Use command line with 0x--- for one or multiple port addresses. What I do is make a batch file and run it from that. You can compile your program and use that EXE file when you run the command line.

Once you set ports to access they will stay readable until next boot.

Again, QB64 can do all of this on any newer machine using INPOUT32.DLL

Posted on Apr 14, 2012, 5:33 AM

Respond to this message   

Return to Index


printer issues

by (no login)

Thanks for all the info. Just wanted you and any others trying to do the same thing. I downloaded a program called userport. It allows xp to communicate with the parallel ports. Works like a charm and much eaiser to use than porttalk.

Leon

Posted on Apr 22, 2012, 9:34 AM

Respond to this message   

Return to Index


Yeah that works, but no command line

by (Login burger2227)
R

I had to move the SYS file to the System32\drivers folder first and then run it from it's window. Who wants that every time?

Well, QB64 can use Inpout32.DLL so I seldom use virtual DOS anymore. My XP days are numbered.

Posted on Apr 22, 2012, 2:06 PM

Respond to this message   

Return to Index


printer issues

by (no login)

Is there a way to print from the qbasic pgm to a printer connected via USB port? Lprint does not work. I would like to be able to print the contents of an array.Using windows xp and userport
Leon

Posted on May 10, 2012, 7:26 AM

Respond to this message   

Return to Index


Sharing Variables

by (no login)

I am writing a program and it has to wait for some things to finish before it can move onto the next set of functions, and it would be more efficient if it could do both functions at the same time. I don't think this is possible in QB64 so my idea was to make several separate programs that could all run at the same time and communicate variables that would be packaged and distributed by a main "brain" program (with a host: localhost) to the other programs that needed those variables. I was trying to use the This works ok but there are many variables that need to be in all the programs and it gets pretty confusing and I am getting bugs that are very hard to pinpoint and fix. So my question is if there is a way to just make a variable global so that the entire operating system can use it? This would be better than the host-client idea.

Posted on Apr 1, 2012, 11:29 AM

Respond to this message   

Return to Index


Re: Sharing Variables

by (Login MCalkins)
Moderator

>So my question is if there is a way to just make a variable global so that the entire operating system can use it?

Perhaps environment variables, but I would recommend against that route. I'm not sure if they're fast enough anyway.

I take it you've already gotten some IPC (inter process communication) working through IP networking?

I've done IPC in QB64 with WriteProcessMemory, and with anonymous pipes. However, both are rather tricky.

http://www.qb64.net/forum/index.php?topic=5081.0

Anytime you are dealing with two threads accessing the same memory, you have to think about synchronization issues. I've researched it a bit, but I'm afraid I still don't understand all the details.

>I am writing a program and it has to wait for some things to finish before it can move onto the next set of functions, and it would be more efficient if it could do both functions at the same time.

Multiple threads within the same process would be ideal for this. Processes share the same virtual address space, so threads within them can access variables without resorting to stuff like WriteProcessMemory. However, you still need to be concerned with synchronization to shared memory.

pmarathe also was interested in multithreading in QB64. I think this is an issue that Galleon will need to address eventually. The main question is whether the QB64 runtime library (mostly contained in libqbx.cpp) is threadsafe and reentrant. It's possible that there may be issues in the code output by the compiler also, but I would think any such issues should be resolvable without too much difficulty. The runtime library might be a bit tougher. Access to the window (any screen output/user input) would be one area where I would suspect problems.

I believe that turning the QB64 runtime library into a threadsafe, reentrant DLL would be a major step in improving QB64.

Certainly multithreading is possible in C++ using the Win32 API. I believe that C++11 adds some support for it to the standard library (at a low level: threads and locks, and at a higher level: asynchronous tasks), which might make it easier in the future for QB64 to support threading in a cross platform way.

I've kind of got a load of projects at the moment that I'm behind on, but this sounds like fun. I might spend the next hour or two seeing if I can do _any_ multithreading in a QB64 program, just as a fun exercise.

Regards,
Michael

Posted on Apr 1, 2012, 11:59 AM

Respond to this message   

Return to Index


Re: Sharing Variables

by (no login)

Yes, I was using a TCP/TP connection to transfer the variables. Only one program would need to write a certain variable, the rest would just read it, so I don't think that synchronization would be an issue. What would you recommend, should I just be very careful to make sure all the variables are being distributed correctly or should I look into WriteProcessMemory or something?

Also, I was looking at your icon embedding page http://qb64.net/wiki/index.php?title=Embedding_Icons_in_EXE but something just isn't working... I tried it manually and also using Ted Weissgerber's code at the bottom, but both times it created the o and rc files and compiled the program, it just isnt embedding the icon in the exe :/ Also when it creates the cpp file when I compile QB64 code, where does it store it? I would like to look at them :)

Posted on Apr 1, 2012, 12:24 PM

Respond to this message   

Return to Index


Re: Sharing Variables

by (Login MCalkins)
Moderator

I played around a bit with creating a 2nd thread of QB64 execution:

http://www.qb64.net/forum/index.php?topic=5787.0

Note that the program crashes with access violations. I believe that this is because the PRINT statement is probably not re-entrant.

>Only one program would need to write a certain variable, the rest would just read it, so I don't think that synchronization would be an issue.

Maybe.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684122%28v=vs.85%29.aspx

----- quote
Simple reads and writes to properly-aligned 32-bit variables are atomic operations. In other words, you will not end up with only one portion of the variable updated; all bits are updated in an atomic fashion. However, access is not guaranteed to be synchronized. If two threads are reading and writing from the same variable, you cannot determine if one thread will perform its read operation before the other performs its write operation.

Simple reads and writes to properly aligned 64-bit variables are atomic on 64-bit Windows. Reads and writes to 64-bit values are not guaranteed to be atomic on 32-bit Windows. Reads and writes to variables of other sizes are not guaranteed to be atomic on any platform.
----- end quote

>What would you recommend, should I just be very careful to make sure all the variables are being distributed correctly or should I look into WriteProcessMemory or something?

I don't know. I think threads are the proper solution, but QB64 isn't mature yet in that regard.

>but both times it created the o and rc files and compiled the program, it just isnt embedding the icon in the exe

When you look at the folder in Windows Explorer, does the icon show up as the .EXE's icon? Note that it won't show up as the application icon while the program is running, because that is an icon that the QB64 program loads manually, and is not a resource in the .EXE file.

>Also when it creates the cpp file when I compile QB64 code, where does it store it? I would like to look at them :)

First of all, note that QB64 can create numbered qbx.cpp files and temp subfolders. I think that this is related to whether you have multiple copies of QB64 open at the same time. If you only have one copy, it seems to not use the numbers.

the main file is:

internal\c\qbx.cpp

it #includes various .txt files from your internal\temp subfolder, the most interesting of which will probably be:

internal\temp\main.txt

There are also other files, like:

internal\temp\maindata.txt

and numbered data.txt files for your SUBs and FUNCTIONs.

The object file created by compiling qbx.cpp is statically linked to a precompiled libqbx.o, the source code of which is:

internal\c\libqbx.cpp

Regards,
Michael

Posted on Apr 1, 2012, 3:14 PM

Respond to this message   

Return to Index


Re: Sharing Variables

by (no login)

Multiple thread execution seems to be what I need but since we don't have that now I think I will stick to the TCP/IP. Are these variables effected by synchronization in the same way? And if so is there a way to time the programs one to loop at 1/16th, 3/16th, 5/16th etc and the other to loop at 2/16th, 4/16th etc? How slow are the rewrites when you PRINT a variable to a connection?

And yes, I know to use _ICON to get the program icon, but the exe icon in Windows Explorer is still the white box with the blue on the top. It doesn't even compile an exe when i use the congealed code at the bottom of the page. And when I do your code step by step I get an exe but only with the default icon :/ Any ideas? I am probably just entering something wrong. I enter a and it makes aA.rc and aA.o and then it gives me a list and I choose the newest one based on the time column. Then it asks me for the "most recent program EXE file" does that mean the name now of the program that i compiled last, or untitled, or what? I have tried many things and always after that it just closes without an error or anything. In the code there is this line [IF _FILEEXISTS(exefile$ + ".EXE") THEN PRINT "EXE file already exists! Use another name!"] right after the input so I am guessing it wants a new name to name the exe it is going to compile? That part is kind of confusing.

Posted on Apr 2, 2012, 7:02 PM

Respond to this message   

Return to Index


About the icon...

by (Login MCalkins)
Moderator

My instructions were specific to the minigolf example on QB64 0.942. I think that the best thing to do would be to make a copy of "recompile.bat", and edit the g.exe command line there.

Here is a demo:

http://www.youtube.com/watch?v=CMUrF2qQNe0

>Are these variables effected by synchronization in the same way? And if so is there a way to time the programs one to loop at 1/16th, 3/16th, 5/16th etc and the other to loop at 2/16th, 4/16th etc? How slow are the rewrites when you PRINT a variable to a connection?

I'm not experienced with IP network programming. The synchronization issues that I was talking about apply to more than one thread actually accessing the same memory (not just communicating through sockets or pipes).

If they are accessing the same memory, the operations need to be atomic. For example, you wouldn't want one thread reading a variable halfway through the other thread writing it. Also, from what I've read, both the compiler and the microprocessor can change the order of reads and writes relative to each other. For example:

a = 0
b = 0

doesn't necessarily mean that a will be written before b. So, if the order matters, you'd want to make sure it is enforced with some kind of memory fence. The Interlocked functions should take care of both issues if used properly. Again, this only applies, as far as I know, to multiple threads actually accessing the same memory.

Regards,
Michael

Posted on Apr 5, 2012, 5:07 AM

Respond to this message   

Return to Index


Thank You!

by (no login)

Thanks! Your video was very informative and it helped me a lot to understand it. I think I figured out the TCP/IP networking for now. Thanks so much for your help Michael, great as always :)

Posted on Apr 5, 2012, 12:25 PM

Respond to this message   

Return to Index


* yw.

by (Login MCalkins)
Moderator

Posted on Apr 5, 2012, 11:03 PM

Respond to this message   

Return to Index


Michael - I watched your video...

by (Login qb432l)
Mod

Most interesting, and once again I realized how little I know about computers. I didn't understand half of what you said, but I enjoyed watching someone so knowledgable going through the process.

Thanks!
-Bob

Posted on Apr 5, 2012, 3:20 PM

Respond to this message   

Return to Index


* :-)

by (Login MCalkins)
Moderator

Posted on Apr 5, 2012, 11:03 PM

Respond to this message   

Return to Index


*What are the two things your program needs to do at once?

by G (no login)

Posted on Apr 2, 2012, 12:15 AM

Respond to this message   

Return to Index


Well

by (no login)

Right now when it is saying something [hr = dABSOLUTEppdp(peekp(peekp(pVoice) + ISpVoice_Speak), pVoice, _OFFSET(ut), 0, 0)] it cant receive new input (it is stored in the buffer) until it is done saying the string. Also there is no way to cancel it by calling another command like stop or something because it doesn't get the command until it is done anyways and at that point it doesn't matter. So I made a listening program, a command executing program, room for a hearing program (for when Michael gets to it), and a processing brain program to relay between the other 3 so there only needs to be one host. It is kind of unnecessary but it sounded like a cool thing to do XD

Posted on Apr 2, 2012, 7:11 PM

Respond to this message   

Return to Index


* If I recall correctly, the speech API had built in support for asynchronous operations.

by (Login MCalkins)
Moderator

Posted on Apr 2, 2012, 9:51 PM

Respond to this message   

Return to Index


*How do you use it?

by (no login)

Posted on Apr 3, 2012, 2:54 AM

Respond to this message   

Return to Index


*(URL)

by (Login MCalkins)
Moderator

http://www.qb64.net/forum/index.php?topic=5613.msg59703#msg59703

Posted on Apr 3, 2012, 3:39 AM

Respond to this message   

Return to Index


It's called multithreading

by (no login)

Something similar is possible in Qbasic.

1) You have a main program loop that calls alternatively all routines separately, who return after work done, and update a variable.

2) In the main loop, you track changes in all variables and feed them into the routines only if they have changed. imho.

Posted on Apr 3, 2012, 1:11 AM

Respond to this message   

Return to Index


LIBWWW!

by Ben (no login)

never forget!

Posted on Mar 26, 2012, 12:16 AM

Respond to this message   

Return to Index


Unusual effect of _DELAY function...

by (no login)

Source Code :

SCREEN _NEWIMAGE(640, 480, 32)
_FONT _LOADFONT("C:\WINDOWS\Fonts\Lucon.ttf", 21)
CALL adddots("Testing", 3, 255, 255, 255, "Tested!")
_DELAY 2
PRINT "YES"

SUB cwg (temp$, r, g, b)
COLOR _RGB(r, g, b)
FOR x = 1 TO LEN(temp$)
PRINT RIGHT$(LEFT$(temp$, x), 1);
_DELAY .05
NEXT x
PRINT
END SUB

SUB adddots (temp$, numofdots, r, b, g, toPrint$)
cx = CSRLIN
cy = POS(0)
CALL cwg(temp$, r, b, g)
PRINT
FOR y = 1 TO 10
FOR x = 0 TO numofdots
LOCATE cx, cy
PRINT temp$ + STRING$(x, ".") + SPACE$(numofdots - x);
_DELAY .2
_DISPLAY
NEXT x
NEXT y
LOCATE cx, cy
PRINT toPrint$ + SPACE$(LEN(temp$) + numofdots - LEN(toPrint$))
END SUB



In the above program, the delay 2 seems to be taking place between inside the function, between "Testing" and "Tested!". I want the program to delay AFTER "Tested!" is displayed(Between "Tested!" and "YES"). how would i do that?

Posted on Mar 25, 2012, 3:57 PM

Respond to this message   

Return to Index


That's a head scratcher, pmarathe...

by (Login qb432l)
Mod

I even put a _DELAY 5 inside the sub after printing "Tested" and before exiting. "Tested" still printed at the same time as "YES" following the 7-second delay.

-Bob

Posted on Mar 25, 2012, 7:22 PM

Respond to this message   

Return to Index


Here

by (no login)

IT has nothing to do with the _DELAY function. You forgot to switch it back to _AUTODISPLAY after calling _DISPLAY in the adddots SUB. It ran through the whole rest of the program without PRINTing anything. The reason it printed when it reached the end was because END probably has some sort of _DISPLAY attribute to it to make sure it PRINTs "Press any key to continue." You could either call _DISPLAY after printing things, or call _AUTODISPLAY somewhere after _DISPLAY in the adddots SUB.


SCREEN _NEWIMAGE(640, 480, 32)
_FONT _LOADFONT("C:\WINDOWS\Fonts\Lucon.ttf", 21)
CALL adddots("Testing", 3, 255, 255, 255, "Tested!")
_DISPLAY
_DELAY 2
PRINT "YES"
_DISPLAY
SLEEP
SYSTEM

SUB adddots (temp$, numofdots, r, b, g, toPrint$)
cx = CSRLIN
cy = POS(0)
CALL cwg(temp$, r, b, g)
PRINT
FOR y = 1 TO 10
FOR x = 0 TO numofdots
LOCATE cx, cy
PRINT temp$ + STRING$(x, ".") + SPACE$(numofdots - x);
_DELAY .2
_DISPLAY
NEXT x
NEXT y
LOCATE cx, cy
PRINT toPrint$ + SPACE$(LEN(temp$) + numofdots - LEN(toPrint$))
END SUB

SUB cwg (temp$, r, g, b)
COLOR _RGB(r, g, b)
FOR x = 1 TO LEN(temp$)
PRINT RIGHT$(LEFT$(temp$, x), 1);
_DELAY .05
NEXT x
PRINT
END SUB


or


SCREEN _NEWIMAGE(640, 480, 32)
_FONT _LOADFONT("C:\WINDOWS\Fonts\Lucon.ttf", 21)
CALL adddots("Testing", 3, 255, 255, 255, "Tested!")
_DELAY 2
PRINT "YES"
SLEEP
SYSTEM

SUB adddots (temp$, numofdots, r, b, g, toPrint$)
cx = CSRLIN
cy = POS(0)
CALL cwg(temp$, r, b, g)
PRINT
FOR y = 1 TO 10
FOR x = 0 TO numofdots
LOCATE cx, cy
PRINT temp$ + STRING$(x, ".") + SPACE$(numofdots - x);
_DELAY .2
_DISPLAY
NEXT x
NEXT y
_AUTODISPLAY
LOCATE cx, cy
PRINT toPrint$ + SPACE$(LEN(temp$) + numofdots - LEN(toPrint$))
END SUB

SUB cwg (temp$, r, g, b)
COLOR _RGB(r, g, b)
FOR x = 1 TO LEN(temp$)
PRINT RIGHT$(LEFT$(temp$, x), 1);
_DELAY .05
NEXT x
PRINT
END SUB

Posted on Mar 25, 2012, 9:18 PM

Respond to this message   

Return to Index


Re: Here

by (no login)

Oh.. ok. Thanks.

Posted on Mar 26, 2012, 3:32 PM

Respond to this message   

Return to Index


Is anybody having problems using Photobucket?

by (Login burger2227)
R

It keeps saying "Invalid file" when I try to upload.

Posted on Mar 25, 2012, 1:10 PM

Respond to this message   

Return to Index


*Just uploaded a picture to test -- no problem. (??)

by (Login qb432l)
Mod

*

Posted on Mar 25, 2012, 7:12 PM

Respond to this message   

Return to Index


I get an error:

by (Login burger2227)
R

This webpage is not available
The connection to s301.photobucket.com was interrupted.
Here are some suggestions:
Reload this webpage later.....
Check your Internet connection. Restart any router, modem, or other network devices you may be using.
Add Google Chrome as a permitted program in your firewall's or antivirus software's settings. If it is already a permitted program, try deleting it from the list of permitted programs and adding it again.
If you use a proxy server, check your proxy settings or contact your network administrator to make sure the proxy server is working. If you don't believe you should be using a proxy server, adjust your proxy settings: Go to the wrench menu > Options > Under the Hood > Change proxy settings... > LAN Settings and deselect the "Use a proxy server for your LAN" checkbox.
Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.

I can go to their web site to upload, but not here.

Posted on Mar 26, 2012, 1:04 AM

Respond to this message   

Return to Index


*Wow, Clipster, you sure do have your problems with websites. Maybe it's time for IE?

by (Login qb432l)
Mod

Posted on Mar 26, 2012, 1:27 AM

Respond to this message   

Return to Index


Monitor

by (no login)

Hi,

What sort of monitor do you use ? My IIyama 1900x1080 takes 2-3 secs to switch to Qbasic resolutions... previously, with CRT monitor it was much faster. I think i settle up to DosBox for this reason, but there, no more open by just clicking. Or voiding full screen mode...

L

Posted on Mar 23, 2012, 5:53 AM

Respond to this message   

Return to Index


Re: Monitor

by (no login)

Personally, I use an EMachines flat panel at 1440x900, usually running my code from within DosBox.

Posted on Mar 23, 2012, 6:23 PM

Respond to this message   

Return to Index


How are these things done!? (Windows)

by (no login)

-How do you make it seem like the keyboard is being pressed for things outside the program, like ctrl-c or alt-f4?
-How do you obtain a list of programs names that have windows open?
-How do you obtain a list of all the programs installed on the system?
-How do you get the variable of the name of the program of the window you are currently on?
-How do you switch between windows? Like switch to any of the windows, not just Alt-Tab. I guess changing the variable from the question above this one.
-How do you get the address ('C:\Documents and Settings\etc') of the thing or things you have highlighted in a Windows Explorer window?

I don't know how hard these questions are so sorry if I am asking too much.

Posted on Mar 22, 2012, 6:11 PM

Respond to this message   

Return to Index


In QBASIC or QB64?

by G (no login)

-How do you make it seem like the keyboard is being pressed for things outside the program, like ctrl-c or alt-f4?
_SCREENPRINT

-How do you obtain a list of programs names that have windows open?
DECLARE LIBRARY
...

-How do you obtain a list of all the programs installed on the system?
No idea!

-How do you get the variable of the name of the program of the window you are currently on?
DECLARE LIBRARY
...

-How do you switch between windows? Like switch to any of the windows, not just Alt-Tab. I guess changing the variable from the question above this one.
DECLARE LIBRARY
...

-How do you get the address ('C:\Documents and Settings\etc') of the thing or things you have highlighted in a Windows Explorer window?
No idea!

More details on request.

Posted on Mar 22, 2012, 9:30 PM

Respond to this message   

Return to Index


Thanks for the response

by (no login)

It is in QB64. I tried _SCREENPRINT and it works for some things but not others. I have a program that is running in my tray that is activated by pressing Alt + -/_ and Alt + =/+. I want to be able to activate it from a program but _SCREENPRINT (CHR$(0) + CHR$(130)) and _SCREENPRINT (CHR$(0) + CHR$(131)) doesn't register with it. It works fine when I actually type it or when i change it to something simpler like "a". Any ideas? As for the DECLARE LIBRARYs, do you know what library i would need or what function? And to find the local address of something you have highlighted in Windows Explorer, I am sure there is a way. What about when you drag something from a folder into a program and it recognizes it and does things, iTunes for example, it would need to know what and where you are dragging it from. Perhaps someone else knows. And as for the list of installed programs, that is not very important, I can think of another way of doing that. Thank you for the response :)

Posted on Mar 23, 2012, 8:45 AM

Respond to this message   

Return to Index


Re: Thanks for the response

by (Login MCalkins)
Moderator

I think a lot of what you asked about can be done with the Win32 API. You might browse through the MSDN library to see which functions seem appropriate.

This thread contains a brief API tutorial:

http://www.qb64.net/forum/index.php?topic=4527.0

In my answers, I'm going to be a bit vague, partly because I completely lack experience with many of the things you asked about. Partly because there are too many questions for me to focus on any one in detail at the moment.

-How do you make it seem like the keyboard is being pressed for things outside the program, like ctrl-c or alt-f4?
>I want to be able to activate it from a program but _SCREENPRINT (CHR$(0) + CHR$(130)) and _SCREENPRINT (CHR$(0) + CHR$(131)) doesn't register with it. It works fine when I actually type it or when i change it to something simpler like "a". Any ideas?

There might be some other way, besides trying to simulate a keystroke. There might be some message that you can send to the program to tell it to activate.

http://msdn.microsoft.com/en-us/library/ms632590%28v=vs.85%29.aspx

-How do you obtain a list of programs names that have windows open?

Browse this:

http://msdn.microsoft.com/en-us/library/ms632595%28v=vs.85%29.aspx

EnumWindows, GetWindowModuleFileName, and GetWindowText look potentially helpful. However, anything that involves needing a callback function will require some C++ code.

-How do you obtain a list of all the programs installed on the system?

I would think the information is in the registry. Where in the registry would be the proper place to look, I don't know. Here is an example of accessing the registry:

http://www.qb64.net/forum/index.php?topic=4721.0

-How do you get the variable of the name of the program of the window you are currently on?

Do you mean your own program, or the foreground window?

Do you mean the title or the executable file name?

For your own program:

The title would be tricky, because I think you would need an HWND first, but the usual way in QB64 of getting your own HWND involves setting your title. :-P

If you mean the file name: GetModuleFilename. There should already be examples in the wiki and on the qb64 forums.

To find the active window: GetForegroundWindow, then probably either GetWindowModuleFileName and/or GetWindowText. Here is an example of GetForegroundWindow to find if your program has focus:

http://www.qb64.net/forum/index.php?topic=5568.0

-How do you switch between windows? Like switch to any of the windows, not just Alt-Tab. I guess changing the variable from the question above this one.

Check out SetForegroundWindow.

-How do you get the address ('C:\Documents and Settings\etc') of the thing or things you have highlighted in a Windows Explorer window?

If there is such a thing, I would suspect that it's in the Shell API.

>What about when you drag something from a folder into a program and it recognizes it and does things, iTunes for example, it would need to know what and where you are dragging it from.

That might be either the Shell API or something to do with Window Messages... :-P

I take it you mean while your program is already open. Otherwise, it's a command line parameter.

Regards,
Michael

Posted on Mar 23, 2012, 3:21 PM

Respond to this message   

Return to Index


Re(2): Thanks for the response

by (no login)

I looked through the MSDN functions and found some useful ones, a question about MSDN first though: when you distribute your program do you have to include the MSDN libraries with your program? If so which and where?

These are the functions that I found immediately useful:

http://msdn.microsoft.com/en-us/library/ms633495(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms633517(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms633520(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms633505(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms633504(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms633553(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms633539(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms632669(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms632678(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms632682(v=vs.85).aspx

Their use is in c though :/ i am not nearly fluent. And how would you incorporate c code in with your QB64 code? How do you exchange variables? From what I could gather EnumThreadWindows gets the handles for the different windows that most of the other functions call for. How do I call this function and then save the data it returns in an array?

As for the sending of hotkeys without actually hitting the keys on the keyboard; it seems to work perfectly fine when I am not using 2byte characters, is there a specific way to send (CHR$(0) + CHR$(130)) to _SCREENPRINT? When I try to print it normally it only prints the e' and a^ characters which is right, I'm guessing some data is just being lost along the way?

Finding a list of all the programs installed is not very important right now so I will just push it back to some other time :P procrastination.

To get the variable of the name of the program of the window you are currently on I meant the foreground window, the functions are promising.

As for getting the local address of something highlighted in Windows Explorer, I figured there would be a simpler answer because it is used in so many programs out there. I will look into Shell API. I did mean while the program is already open, the goal was to be able to click on something and say 'copy this' or 'copy this to drive d' or 'delete this' but it would need to know where the target is.

By the way Michael, how is the Speech Recognition API coming along if you are working on it? I don't want to impose if you are not, I am sure you have many things you are busy with. Right now the DLA isn't very functionally significant because you have to type to him all your commands. Once speech is enabled I will release a version and collect the logs from people so I can add more functions to it based on demand. I think it has promise :) The name of the DLA is JARVIS by the way, Just Another Rather Very Intelligent System, based of JARVIS Just A Rather Very Intelligent System, Tony Stark's computer butler from Iron Man XD

Posted on Mar 24, 2012, 6:35 PM

Respond to this message   

Return to Index


Re: Re(2): Thanks for the response

by (Login MCalkins)
Moderator

I didn't realize you were the same person as on the other forum. :-)

I'll try to give you some answers soon. For now, briefly:

>when you distribute your program do you have to include the MSDN libraries with your program

Mostly those are the .DLLs already in everyone's Windows\System32 folder. The MSDN article will usually tell you which DLL and what minimum version of Windows.

>Their use is in c though :/ i am not nearly fluent. And how would you incorporate c code in with your QB64 code?

MSDN is giving the function prototypes in C/C++. Those would need to be translated to appropriate lines in DECLARE DYNAMIC LIBRARY blocks. I gave you a link to a forum thread that had a brief tutorial on that. It is somewhat intimidating until you get the hang of it. A bit of low level experience from Assembly or C is helpful, but shouldn't be necessary.

For a few things, you might need custom C/C++ code. For example: if Windows needs to call a function in your program (a "callback" function). Also, the message handling for a window would probably take C/C++ code.

>how is the Speech Recognition API coming along if you are working on it?

I haven't started yet. :-/ I'll try to get to it next week.

Regards,
Michael

Posted on Mar 24, 2012, 11:27 PM

Respond to this message   

Return to Index


Re(4): Thanks for the response

by (no login)

Oh, ya thats me. Sorry, I guess there isn't any correlation between the two profiles XD

I will try to catch up on my C and I have a friend who can help me with minor translations and such, but in all honesty I will probably be back here in not too long :P

If everyone already has the libraries on their system then what was the 2.2GB download? Just the documentation? O-O

I have a request for a C translation that is a bit too much for me to take on right off the bat, but I obtained the code for getting the local address or addresses from Windows Explorer thanks to the AutoIt forums. It doesn't mean much to me, but I was led to believe that this is what I was looking for:

It is deciding to not show some of the code so here is a link to it:http://dl.dropbox.com/u/30616191/code.txt

And as for the Speech Recognition API, just do it whenever you get around to it, don't make me a priority.

Thanks for all the help you have been providing Michael, without it I would be floundering with this project, I appreciate it :)

Posted on Mar 25, 2012, 10:12 AM

Respond to this message   

Return to Index


Problem with Shell running batch file

by (no login)

EDIT - Problem solved!
I just had to rename mediainfo.exe to mediainf.exe

(glg posted the above to an otherwise duplicate post on Mar 21, 2012, 3:46 PM. --- mc)
****************************************************************************************************

I am trying to use mediainfo.exe along with mediainfo.dll in QBASIC

I am having a problem running the Sell command

I have a batch file -> mymedia.bat:

mediainfo.exe --Inform=file://template.txt video.mp4 >> new2.txt

template.txt:
General;%CompleteName%\r\n
Video;%Width%\r\n%Height%\r\n%FrameRate%\r\n%FrameCount%\r\n

If I just run the batch file from a dos prompt - it works as it should

If I run the Shell command then type in mediainfo.exe --Inform=file://template.txt video.mp4 >> new2.txt - it works

If I run the Shell command then type mymedia.bat - it works

But when I try to run the batch file from the Shell:
m$ = "mymedia.bat"
SHELL m$

the output is:

C:\QBASIC>mediainfo.exe --Inform=file://template.txt video.mp4 >> new2.txt

Bad command or file name

I have no problem running a batch file for ffmpeg.exe or gm.exe [graphicsmagick}

I have in my QBasic folder
MediaInfo.dll version 0.7.24.0
MediaInfo.exe [MediaInfo Command Line Interface] version 0.7.24.0
template.txt
mymedia.bat

Any help would be appreciated

Posted on Mar 21, 2012, 3:32 PM

Respond to this message   

Return to Index


Re: Problem with Shell running batch file

by (no login)

Hi, glg

It seems what you may have going on is an incompatibility between the traditional DOS 8.3 filenames and the new Windows long filenames. The reason it works when you type it directly into the shell is that Windows and its DOS shell can interpret the LFNs into the old 8.3 standard before running the program you want, therefore the program "MediaInfo" works fine even though it is more than eight characters long. When doing this through QBASIC, it seems that the compiler does its own processing of the command string, talking directly to the system via interrupts or something of the sort and therefore bypasses the decoding that gets done when you do it manually via Windows or the shell menu option. Try renaming MediaInfo.exe (which QBASIC sees as something like mediai~1.exe) to something which will conform to the 8.3 standard (e.g. minfo.exe) and update your bath file accordingly. Hopefully this will fix the issue.

Mercury

Posted on Mar 21, 2012, 10:16 PM

Respond to this message   

Return to Index


Dictionary Problem

by Zack (no login)

I was looking to add define, synonym, antonym, etc functions to my program. I was looking for a library and database combo thing that I could use but I couldn't find any. Even a txt document with the words and then definitions would work. The first would be cooler though :P Anyways, my point is that it is a lot harder than I thought it would be to find something like that, does anyone know where I can find one?

Posted on Mar 20, 2012, 7:09 PM

Respond to this message   

Return to Index


Type ?

by (no login)

Qbasic is aimed for databases, so there should be no problem. Build a suitable Type for your wishes...

Posted on Mar 21, 2012, 1:47 AM

Respond to this message   

Return to Index


Re: Dictionary Problem

by (no login)

Hi, Zack

From what I gather, I think this would be the closest thing I've found to what you're looking for. It even has separate lists to narrow down which "flavor" of language you wish to use.

http://sourceforge.net/projects/wordlist/files/Ispell-EnWL/3.1.20/ispell-enwl-3.1.20.zip/download

Mercury

Posted on Mar 21, 2012, 10:09 PM

Respond to this message   

Return to Index


Re: Re: Dictionary Problem

by (no login)

That is a very good list of words, it would be useful for a spell checker or something. I found a couple lists like that but what I was having trouble was one that had definitions, synonyms, part of speech, etc. Be it in some kind of database format or in separate corresponding text documents, like a dictionary.

An alternative would be asking say dictionary.com every time for those variables. But how do you know what to ask when you are looking for specific data? At one point someone gave me this:

Request$ = "GET " + tmchostipfile$ + " HTTP/1.1" + CR$ + "Host: dl.dropbox.com" + CR$ + CR$
PUT #webclient, , Request$
_DELAY 1
GET #webclient, , Response$

to retrieve the data in a text document on dropbox. It worked for its purpose. I guess what I am asking is how do you know what to PUT the host to GET the response you are looking for?

Posted on Mar 22, 2012, 2:53 PM

Respond to this message   

Return to Index


Re: Re: Dictionary Problem

by (no login)

Oh, my mistake. Alas, I cannot seem to find anything like that either. If you do fine something like this, please let me know! :)

Posted on Mar 22, 2012, 5:21 PM

Respond to this message   

Return to Index


*Will do

by (no login)

Posted on Mar 22, 2012, 6:11 PM

Respond to this message   

Return to Index

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement