QBasic and QB64 Discussion Board

[QB Forum Archives (1999-2009)/ ] [QB FAQ] [QB Links and Downloads] [Subforums and Chat Room] [Search]

QB64.Net Homepage   QB/QB64 Keywords   QB Graphics Forum   Homework Policy


conditional statements

by (no login)

I shall be grateful if anyone of you could help me understanding the While...Wend commaand and how to write a program using this command. One more thing...is there any link to solved examples in Qbasic programs...at school level.

Thanks a lot in advance

Posted on Mar 9, 2012, 5:30 AM

Respond to this message   

Return to Index


Re: conditional statements

by (Login MCalkins)
Moderator

For help with specific commands, there are 2 good sources of information. If you are using qbasic 1.1, you can press SHIFT+F1 for help, or put the cursor on the keyword and press F1. There is also the QB64 wiki:

http://www.qb64.net/wiki/index.php?title=WHILE...WEND

It works like this:

WHILE condition
 ' do whatever you need to do inside the loop
WEND

The WHILE marks the start of the loop, the WEND (which stands for WHILE END) marks the end of the loop.

condition controls whether the code inside the loop executes or not. condition is a numeric expression. If condition can be evaluated as 0, it is considered false, and the interior of the loop will not be executed. If condition can be evaluated as anything other than 0, the interior of the loop will be executed. As the condition appears at the start of the loop, it is checked before each iteration of the loop.

Example:

DIM i AS INTEGER
CLS
i = -1
WHILE i
 INPUT "Enter 0 for false, any integer other than 0 for true: ", i
WEND
END

It will loop as long as you enter a non-zero number. Notice that it is necessary to set i to a non-zero value before entering the loop, as the condition is checked before each iteration.

Another example:

DIM i AS INTEGER
CLS
i = 0
WHILE i < 6
 PRINT "inside the loop"; i
 i = i + 1
WEND
PRINT "outside the loop"; i
END

i < 6 is a numeric expression. The qbasic equality/inequality/relational operators, such as =, <>, <, >, <=, and >= all return 0 for false and -1 for true. Therefore, if i is 5, the expression i < 6 evaluates to -1 for true. But when i is 6, the expression i < 6 will return 0 for false. The loop will print the numbers 0 to 5 inside the loop, and 6 outside the loop.

Remember that you can use any numeric expression for the condition. For example, the LEN() function returns a number, so:

DIM t AS STRING
CLS
t = "a"
WHILE LEN(t)
 PRINT "t is not empty, that is, it has a non-zero length."
 LINE INPUT "New t: ", t
WEND
PRINT "t must be empty"
END

-----

QBASIC also has other looping constructions, such as DO...LOOP and FOR...NEXT

DO...LOOP is like WHILE...WEND, but more versatile, it gives you either WHILE or UNTIL, and lets you put the condition either at the beginning of the loop, or at the end of the loop.

DO WHILE condition
 'contents
LOOP

is basically the same as WHILE...WEND. However, you can also do:

DO UNTIL condition
 'contents
LOOP

DO
 'contents
LOOP WHILE condition

DO
 'contents
LOOP UNTIL condition

In the latter two cases, the condition is checked at the end of the loop, not the beginning. That means the loop will always be entered, the contents will execute at least once.

There is also the EXIT DO statement which lets you jump out of a DO...LOOP block midway through it. QB64 also has EXIT WHILE, but Qbasic 1.1 doesn't.

-----

As for solutions to homework assignments, you can probably find a lot by searching these forums. However, it would probably be better to come up with your own.

Welcome to the forum.

Regards,
Michael



    
This message has been edited by MCalkins on Mar 9, 2012 12:46 PM
This message has been edited by MCalkins on Mar 9, 2012 12:44 PM

Posted on Mar 9, 2012, 12:39 PM

Respond to this message   

Return to Index


Re: conditional statements

by (no login)

Thanks Michael. I am using Qb64..

Posted on Mar 9, 2012, 9:22 PM

Respond to this message   

Return to Index


*yw

by (Login MCalkins)
Moderator

Posted on Mar 10, 2012, 12:48 PM

Respond to this message   

Return to Index


help with line input

by (no login)

how can i execute commands while waiting for input from a line input statement? for example, if i want to check whether a button is being pressed but there is a line input statement, how can i check for the button press before anything has been inputted?

my code is like this :

line input "Command :";com$
'check for button press
'this needs to happen even if nothing has been inputted yet

If i click the button, it should execute an action. In my program, however, it waits until the user has inputted text and then executes the action which corresponds to the button

Posted on Mar 8, 2012, 2:28 PM

Respond to this message   

Return to Index


Re: help with line input

by (Login MCalkins)
Moderator

You probably out to write your own line input alternative using INKEY$ in a loop.

DIM t AS STRING, k AS STRING

t = ""
DO

 'check for button press here.

 k = INKEY$
 SELECT CASE k
 CASE CHR$(&HD) 'enter
  EXIT DO
 CASE CHR$(8) 'backspace
  IF LEN(t) THEN
   t = LEFT$(t, LEN(t) - 1)
   PRINT k; 'not ideal
  END IF
 CASE ELSE
  t = t + k
  PRINT k;
 END SELECT
LOOP
PRINT

Obviously that's rather crude, but it can be improved upon.

Regards,
Michael

Posted on Mar 8, 2012, 2:55 PM

Respond to this message   

Return to Index


Re: help with line input

by (no login)

Is there any way that i can still use line input? Also, isn't it possible to execute more than one step at the same time with a multi-core processor? If so, how can i do that in QB64?

Posted on Mar 8, 2012, 5:19 PM

Respond to this message   

Return to Index


Re: help with line input

by (Login MCalkins)
Moderator

Yes, with multiple threads.

I don't know whether you can do this using vanilla QB64. Galleon could tell you.

You could certainly do it with Win32 API calls, and maybe a little bit of C++ code.

I might have a look at it later.

Whether both threads could be running QB64 code, or whether only one could be QB64 code and the other would have to be C++ code, I think would depend on whether the QB64 library is "thread safe". Even if the library is thread safe, I still think you would need at least a little C++ code to find function addresses.

QB64 programs do currently use multiple threads. However, as far as I know, only one thread is actually running your code. Drawing the window is done by one of the other threads. (One of the reasons, probably, is that threads that create windows are restricted in their use of some of the Wait functions. I don't understand all the implications of that, though.) I don't know how QB64 handles event trapping like ON TIMER. That might rely on multi-threading...

Regards,
Michael

Posted on Mar 8, 2012, 6:23 PM

Respond to this message   

Return to Index


Re: help with line input

by (no login)

> Is there any way that i can still use line input?

No. LINE INPUT works in one way and one way only. It gets a line of text from the user, and only relinquishes control of the processor after the user hits Enter. It unfortunately doesn't feature any kind of parameters to control its behavior so that it will allow other things to go on processing while it does its job. One possible way would be to hook the timer tick interrupt so that whatever background processing you need done is completed during the interrupt cycle, however this is not only tricky but it too may fail, as LINE INPUT might stop certain interrupts from occurring while it executes.

>Also, isn't it possible to execute more than one step at the same time with a multi-core processor?

This IS possible, but not for QBASIC. As DOS wasn't designed as a threaded OS, any parallel threading that occurs will be happening within your actual CPU. This is below your program's level of awareness, as well as that of DOS, and will therefore be invisible to your code. If you're running QBASIC and/or your program under some flavor of Windows then it will be handling the multi-threading, but alas this would still be transparent to your code.

Posted on Mar 8, 2012, 6:55 PM

Respond to this message   

Return to Index


LINE INPUT will not work

by (Login burger2227)
R

INPUT will wait until you hit enter to use ON KEY prompts or other events. Use an INKEY$ loop like this:

Align 12, 23, "Turn Number and Cap Locks OFF!"
KEY 15, CHR$(4) + CHR$(35)
ON KEY(15) GOSUB Help
KEY(15) ON
ent$ = ""
Align 11, 18, CHR$(219)
DO: SLEEP: K$ = INKEY$
IF K$ CHR$(13) THEN ent$ = ent$ + K$
Align 11, 18, ent$ + CHR$(219)
LOOP UNTIL K$ = CHR$(13)
Align 14, 18, SPACE$(60)
Align 14, 18, ent$
KEY(15) OFF
END

Help:
COLOR 11: LOCATE 15, 40: PRINT "Help assistance requested:"
COLOR 13: LOCATE 16, 40: PRINT "Press a key to continue!"
DO: LOOP UNTIL INKEY$ ""
COLOR 11: LOCATE 15, 40: PRINT SPACE$(26)
LOCATE 16, 40: PRINT SPACE$(26)
RETURN

SUB Align (Tclr, Trow, txt$) 'centers text on screen
Tcol = 41 - (LEN(txt$) \ 2)
COLOR Tclr: LOCATE Trow, Tcol: PRINT txt$;
END SUB

The program allows you to enter text or hit Ctrl + H to get help in the middle of the entry. The Help is just a demo of its usage.


Posted on Mar 9, 2012, 6:15 PM

Respond to this message   

Return to Index


Re: LINE INPUT will not work

by (no login)

Is there an ON _MOUSEBUTTON(1)?

Posted on Mar 10, 2012, 11:34 AM

Respond to this message   

Return to Index


Same as Line Input, but in a DO / LOOP

by Pete (no login)

CLS
numofspaces% = 40
LOCATE 10, 30, 1, 7, 7
startpos% = POS(1)
endpos% = startpos% + numofspaces%
DO
DO
b$ = INKEY$
IF b$ <> "" THEN EXIT DO
LOOP
xx% = CSRLIN: yy% = POS(1)

SELECT CASE b$
CASE CHR$(0) + "K"
mov% = -1: GOSUB action
CASE CHR$(0) + "M"
mov% = 1: GOSUB action
CASE CHR$(0) + "S"
GOSUB wash: GOSUB delete
CASE CHR$(0) + "R"
IF ins% = 0 THEN ins% = -1 ELSE ins% = 0
IF ins% = 0 THEN LOCATE , , 1, 7, 7 ELSE LOCATE , , 1, 7, 30
CASE CHR$(0) + "O"
IF word$ <> "" THEN LOCATE xx%, startpos% + LEN(word$)
CASE CHR$(0) + "G"
LOCATE xx%, startpos%
CASE CHR$(8)
IF yy% > startpos% THEN
LOCATE , POS(1) - 1
yy% = POS(1)
GOSUB wash: GOSUB delete
END IF
CASE CHR$(13)
CLS : LOCATE , , 0: PRINT word$; : SLEEP 2: END
REM Enter your routine here.
CASE CHR$(27)
COLOR 7, 0: SYSTEM
CASE CHR$(32) TO CHR$(126)
key$ = b$: GOSUB action
END SELECT
mov% = 0: key$ = ""
LOOP

action:
IF POS(1) + mov% >= startpos% AND POS(1) + mov% < endpos% THEN
DO
IF key$ <> "" THEN
SELECT CASE ins%
CASE 0
IF LEN(word$) + LEN(key$) > endpos% - startpos% THEN EXIT DO
word$ = MID$(word$, 1, POS(1) - startpos%) + key$ + MID$(word$, POS(1) - startpos% + 1)
CASE -1
word$ = MID$(word$, 1, POS(1) - startpos%) + key$ + MID$(word$, POS(1) - startpos% + 2)
END SELECT
END IF
IF POS(1) - startpos% >= LEN(word$) - LEN(key$) AND key$ <> "" OR key$ = "" OR ins% = -1 THEN
IF key$ = "" AND mov% = 1 THEN IF POS(1) - startpos% = LEN(word$) THEN EXIT DO
LOCATE , POS(1) + mov%: PRINT key$;
ELSE
LOCATE xx%, startpos%: PRINT MID$(word$, 1, yy% - startpos%); key$; : yy2% = POS(1): PRINT MID$(word$, yy% - startpos% + 2); : LOCATE xx%, yy2%
END IF
EXIT DO
LOOP
END IF
RETURN

wash:
IF POS(1) >= startpos% AND word$ <> "" THEN
LOCATE xx%, startpos% + LEN(word$) - 1
PRINT " ";
LOCATE xx%, yy%
END IF
RETURN

delete:
IF POS(1) - startpos% = 0 THEN
word$ = MID$(word$, 2)
ELSE
word$ = MID$(word$, 1, POS(1) - startpos%) + MID$(word$, POS(1) - startpos% + 2)
END IF
PRINT MID$(word$, yy% - startpos% + 1); : LOCATE xx%, yy%
RETURN

Posted on Mar 9, 2012, 12:27 AM

Respond to this message   

Return to Index


Re: Same as Line Input, but in a DO / LOOP

by (no login)

I tried this :
PRINT "Command : ";
cxx = CSRLIN
cxy = POS(0)
DO
DO WHILE _MOUSEINPUT
mousex = _MOUSEX
mousey = _MOUSEY
click = _MOUSEBUTTON(1) * -1
LOOP
LOCATE cxx, cxy
ky$ = INKEY$
IF ky$ <> "" THEN
SELECT CASE ky$
CASE CHR$(8)
com$ = RTRIM$(LEFT$(com$, LEN(com$) - 1))
CASE CHR$(13)
EXIT DO
CASE ELSE
com$ = com$ + ky$
END SELECT
END IF
PRINT com$; SPACE$(1)
IF mousex > (1920 - 160) AND mousey < 105 and click = 1THEN
IF mousey >= 0 AND mousey <= 21 AND THEN com$ = "repeat"
IF mousey >= (21 * 1) AND mousey <= (21 * 2) THEN com$ = "end"
IF mousey >= (21 * 2) AND mousey <= (21 * 3) THEN com$ = "start timer"
IF mousey >= (21 * 3) AND mousey <= (21 * 4) THEN com$ = "clear"
IF mousey >= (21 * 4) AND mousey <= (21 * 5) THEN com$ = "help"
EXIT DO
END IF
LOOP
'com$ is then parsed in the actual program and actions are taken


But when i run it, it executes the same action 10 times or so. In the main program, i clear com$ after every iteration of the main loop...

Why is this happening?

Posted on Mar 9, 2012, 8:22 AM

Respond to this message   

Return to Index


Re: Same as Line Input, but in a DO / LOOP

by (no login)

I can post the whole program if required. It is lengthy though

Posted on Mar 9, 2012, 8:23 AM

Respond to this message   

Return to Index


Correction

by (no login)

It only causes problems when the last one (help button) is clicked....the other ones work well

Posted on Mar 9, 2012, 8:28 AM

Respond to this message   

Return to Index


*Marly has posted in an old thread asking for homework help.(URLs)

by (Login MCalkins)
Moderator

http://www.network54.com/Forum/648955/thread/1331235462/Here%27s+a+start

in old thread:

http://www.network54.com/Forum/648955/thread/1303424791/Project+Help+Needed+-+Desperate



    
This message has been edited by MCalkins on Mar 8, 2012 12:19 PM

Posted on Mar 8, 2012, 12:18 PM

Respond to this message   

Return to Index


wow. 14 guests in this forum and 30 in big programs

by (Login MCalkins)
Moderator

as of a minute or two ago.

I wonder how many were distinct people and how many were bots or proxys/spoofed IPs...

Or is someone practicing for a distributed denial of service attack against us?



    
This message has been edited by MCalkins on Mar 7, 2012 9:07 PM

Posted on Mar 7, 2012, 9:06 PM

Respond to this message   

Return to Index


* Probably Gopus...

by (Login burger2227)
R

Posted on Mar 8, 2012, 9:13 AM

Respond to this message   

Return to Index


Or Clippy trying to defame me...

by gopus (no login)

There appears to be too many people on the forum who know me enough to believe Clippy's lies.

Posted on Mar 17, 2012, 7:16 AM

Respond to this message   

Return to Index


Hey all...

by (Login gopus)

Don't worry. I am back. I know some of you have been worried because of the lack of leadership. I am here to help everyone out and make this forum a thriving community again. Please send your suggestions to my website. Bye all!

Posted on Mar 6, 2012, 5:25 PM

Respond to this message   

Return to Index


*It's hard to know who is better really Zip or Gopus... sigh!

by Galleon (no login)

Posted on Mar 7, 2012, 11:13 AM

Respond to this message   

Return to Index


* I'll take the quack over both of them thanks...

by (Login burger2227)
R

Posted on Mar 7, 2012, 11:46 AM

Respond to this message   

Return to Index


*as far as I know, Gopus has never hijacked the forum, nor has been as rude.

by (Login MCalkins)
Moderator

Posted on Mar 7, 2012, 12:13 PM

Respond to this message   

Return to Index


At least someone has some sense of history...

by gopus (no login)

This forum is a network54.com forum, and this place has visitors, because of me...

Posted on Mar 17, 2012, 7:18 AM

Respond to this message   

Return to Index


Handling Numbers

by Bill Spencer (no login)

I am creating a sub routine to calculate an answer. The numbers involved in the calculation are to 6 places of decimal but I want the final total to show only 2 places of decimal. How do I indicate in the routine that I want accuracy during the calculation but want the final print out to show only 2 places of decimal?

Posted on Mar 4, 2012, 5:46 AM

Respond to this message   

Return to Index


Re: Handling Numbers

by (Login MCalkins)
Moderator

The easiest way might be to use PRINT USING:

PRINT USING "#.##"; 123.4567

However, you might find a better way. Perhaps by manually rounding it, or truncating the string returned by STR$().

Keep in mind that numbers are stored in binary, so the actual precision is based on binary places, not decimal places.

Regards,
Michael

Posted on Mar 4, 2012, 6:09 AM

Respond to this message   

Return to Index


The leading % indicates the value is over the number of places

by (Login burger2227)
R

The template should have more than or the same # whole number places as the numerical values used.

The number of places after the decimal point indicates the accuracy you want.

PRINT USING "###.##"; 123.4567

You can add commas like this using a comma before the decimal point:

PRINT USING "######,.##"; 1123.4567

Posted on Mar 4, 2012, 7:41 AM

Respond to this message   

Return to Index


Another way

by David (no login)

X=INT(X*100+.5)/100

But to print it out use Michael's method PRINT USING.

Posted on Mar 4, 2012, 11:08 AM

Respond to this message   

Return to Index


Advice on some problems I am having

by (no login)

hi all

I have a few problems I am stuck on

1. Does ANYONE know if it is possible to simulate pcopy on screen 11 (as I am still getting flickering etc on the screen)


2. Does anyone know how i get the cash drawer status from a IBM 4614 PoS terminal (I have the manuals etc this is the link to the manual on the IBM website (ftp://ftp.software.ibm.com/software/retail/pubs/hw/4614/bio4mst.pdf)

I hope someone can help I have the project zipped up so if someone wants to see the current code then they would be more then welcome to see it

Andy

Posted on Mar 3, 2012, 12:11 PM

Respond to this message   

Return to Index


Re: Advice on some problems I am having

by (Login MCalkins)
Moderator

For simulating a PCOPY, are GET and PUT acceptable? If not, try QB64. However, I don't know if that would solve your flickering problem. For QBASIC 1.1, I've seen people use WAIT to deal with flickering, but I never learned the details.

For your other question, I'm sorry, but I'm not in the mood to read through a whole manual at the moment. Glancing at it, it looks like you write chr$(5) to the COM port, and read back the status byte. IF statusbyte AND &H80 THEN drawerisclosed ELSE drawerisopen. I'm not sure what the significance of the check byte is. I'm guessing the status has to be acknowledged, I would guess with a chr$(6), but I might be wrong.

Regards,
Michael



    
This message has been edited by MCalkins on Mar 6, 2012 9:11 PM
This message has been edited by MCalkins on Mar 6, 2012 6:41 PM

Posted on Mar 6, 2012, 6:41 PM

Respond to this message   

Return to Index


Advice on some problems I am having

by (no login)

I have read that QB64 does not do DOS apps

I am only using screen 11 beacuse it is 640x480

if I use screen 9 (that does have paging) can I make that go to 640x480?

Thanks
Andy

Posted on Mar 7, 2012, 10:42 PM

Respond to this message   

Return to Index


Re: Advice on some problems I am having

by (Login MCalkins)
Moderator

>if I use screen 9 (that does have paging) can I make that go to 640x480?

No.

GET/PUT should be almost as good as PCOPY. The advantage of multiple pages is that you can switch them with SCREEN. That tells the graphics card to start using a different area of memory. PCOPY and GET/PUT copy memory (which takes time), whereas SCREEN just switches to a different part of memory. At least that's how I think it to be.

Regards,
Michael

Posted on Mar 7, 2012, 10:54 PM

Respond to this message   

Return to Index


Send 17 to the device and it will send back the drawer status

by (Login burger2227)
R

Send the escape code 27 and then 17(&H11 or 11h as in the manual). That should send you a value back that is 128 or more if the drawer is closed. If it is open 128 will not be in the value. CHR$(17) is Ctrl + Q.

IF value AND 64 THEN PRINT "Drawer is closed!" ELSE PRINT "Drawer open!"

AND can be used to tell you which bits are on:
Bit 0 on = 1; bit 1 on = 2; bit 2 on = 4; bit 3 on = 8; bit 4 on = 16; bit 5 on = 32; bit 6 on = 64; bit 7 on = 128.

If a bit is off it adds nothing to the value.

If bit 1 and 7 are both on the value is 128 + 2 = 130

Quote:
After transmission of the ESC command, the printer outputs an XON (DC1 by control code; 11h by
hexadecimal data) to the system. When the application program receives the XON signal, it can transmit
data to the printer. If the data text is not sent from the application program, the printer logic outputs an
XON signal at 3 second intervals until the printer receives data.
The printer starts sending XOFF (DC3, 13h) when the empty space in the buffer reduces below 256 bytes.
When the application receives the XOFF signal, it halts output of data. However, the printer logic can
continue receiving data until the buffer becomes completely full.



    
This message has been edited by burger2227 on Mar 6, 2012 8:42 PM

Posted on Mar 6, 2012, 8:40 PM

Respond to this message   

Return to Index


Cash Drawer status

by (no login)

Hi,

Thanks for the replay does it matter that I am controlling the comport by Mode?

I do the following before the app loads (in the autoexec.bat)

Mode COM3:9600,n,8,1 'This sets the comport for the printer
c:\PoS\pos.exe



This app is running in 100% MS DOS

Posted on Mar 7, 2012, 10:41 PM

Respond to this message   

Return to Index


Re: Advice on some problems I am having

by (no login)

Hi, Andy

Just wondering; have you tried using port &H3DA to wait for the vertical retrace interval? This port will have bit 3 set (e.g. return the value "8") if the 'VBlank' has completed and it's safe to draw. I've used this in some old routines and it does make a noticeable difference. If you do use this method and you need your program to run fast, (I assume you won't need a high rate of speed for a POS application, but this is just FYI :]) don't do this:

DO WHILE NOT done 'this is your main event loop
'program logic goes here...
WAIT &H3DA, 8
'graphics drawing code goes here...
LOOP

...since it will halt your entire program while it WAITs. Instead, you can do something like this:

DO WHILE NOT done 'this is your main event loop
'program logic goes here, including preparing all variables and data pertinent to the frame about to be drawn...
INP &H3DA, x
IF x = 8 THEN
'code to do the drawing goes here
END IF
LOOP

This way, the rest of the program can continue to execute while you continue to wait for the VBlank to be ready.

Mercury

Posted on Mar 7, 2012, 5:20 PM

Respond to this message   

Return to Index


Enable formatted text box mystery solved

by Solitaire (Login Solitaire1)
S

A while back I had attempted to post some code that didn't display correctly. I was told to uncheck the "Enable formatted text" box. But that box did not appear on my screen.

Now my automatic loggon time expired at Network54.com, so I logged back in and edited my account. There was an option to check the beta box using a WYSIWYG editor. The box was checked so I unchecked it. Came back to see if it made any difference. It did! I now have an "Enable formatted text" box!

Let's see if it works. Testing:

If myvar > 5 Or myvar
It works! Hooray!

There's another beta box in the Network54 account page that's checked but I don't know what it does or doesn't do.



    
This message has been edited by Solitaire1 on Mar 1, 2012 7:55 PM

Posted on Mar 1, 2012, 7:50 PM

Respond to this message   

Return to Index


*Glad to hear it -- I might check out the other account options myself.

by (Login qb432l)
R

*

Posted on Mar 1, 2012, 10:06 PM

Respond to this message   

Return to Index


* N54 did that to me once too! I had to reset it also.

by (Login burger2227)
R

Posted on Mar 2, 2012, 2:28 AM

Respond to this message   

Return to Index


* :-)

by (Login MCalkins)
Moderator

Posted on Mar 2, 2012, 6:46 AM

Respond to this message   

Return to Index


Strange -- Now the < sign doesn't show up again

by Solitaire (Login Solitaire1)
S

It was ok on my desktop computer last night. But when I checked my laptop just now, the less than sign is missing and there is no "Enable formatted text" box either.

I logged on again with my laptop and saw that the WYSIWYG box is still unchecked. I also unchecked the other box.

Came back to the forum and now I see the "Enable formatted text" box again.

Testing again this time:

If num > 6 or num

===================================
It looks ok on my laptop (I'm logged on) but I have to check the desktop again, and will edit this post with the results. Stay tuned.

===================================

Back on my desktop: The less than sign does NOT show up. After logging on, it STILL doesn't show.

How does it look to you? I'm trying again:

If num > 6 or num

===================================

Still on my desktop. Now it's showing. But it's very flaky and undependable.

===================================

Saved and opened file again for edit. It disappeared again.

This is entirely unacceptable.



    
This message has been edited by Solitaire1 on Mar 2, 2012 9:55 AM
This message has been edited by Solitaire1 on Mar 2, 2012 9:55 AM
This message has been edited by Solitaire1 on Mar 2, 2012 9:52 AM
This message has been edited by Solitaire1 on Mar 2, 2012 9:23 AM
This message has been edited by Solitaire1 on Mar 2, 2012 9:22 AM
This message has been edited by Solitaire1 on Mar 2, 2012 9:11 AM

Posted on Mar 2, 2012, 9:10 AM

Respond to this message   

Return to Index


I agree it's unacceptable - will run a test of my own...

by (Login qb432l)
R

If a < b and c > a THEN

The signs did not show up in the preview window, but showed up in the post itself.

Same thing happened with editing the message.

Oh, dear.
-Bob



    
This message has been edited by qb432l on Mar 2, 2012 1:53 PM
This message has been edited by qb432l on Mar 2, 2012 1:53 PM
This message has been edited by qb432l on Mar 2, 2012 1:52 PM

Posted on Mar 2, 2012, 1:51 PM

Respond to this message   

Return to Index


new QBASIC-compatible compiler

by (no login)

Greetings, all!

Hopefully I won't be perceived as stepping on any toes asking this here, as I notice QB64 has a considerable following, however...

I'm working on making a cross-compiler which will provide full (or at least near-full) QBASIC compatibility, add some new keywords and functions, and also allow intermixing of assembly instructions directly in the source without any kind of special formatting or referencing. The language itself will essentially be the majority of QBASIC's keywords, plus a few enhancements from the DOS Visual BASIC, some statements from PowerBASIC and all the assembly commands appropriate for the processor you've told the compiler is your target platform. I guess the finished product will be somewhat like a PowerBASIC-on-steroids of sorts, but hopefully a little bit better and without the exorbitant price tag. So my question to all of you would be, what additional features and abilities did you always wish QBASIC had? Also, to the authors of QB64, I would ask if you would mind me adopting some of your keywords for some functions I may find useful?

Thank you all in advance!
Mercury

Posted on Feb 29, 2012, 4:43 PM

Respond to this message   

Return to Index


How is it gonna work on 64 bit machines?

by (Login burger2227)
R

That is the main question most would ask. DOS is dead!

Posted on Feb 29, 2012, 5:26 PM

Respond to this message   

Return to Index


Re: How is it gonna work on 64 bit machines?

by (no login)

My answer would be that it won't.

...at least not when developed to the current design goal. But since it's already structured to be a cross-compiler which supports x86 and 68K instruction sets, it's completely feasible to modify it to handle the x64 architecture as well.

And so far as DOS being dead? I believe the "DOS Ain't Dead" forum (www.bttr-software.de/forum/) would disagree lol

Posted on Feb 29, 2012, 10:13 PM

Respond to this message   

Return to Index


Re: DOS is dead!

by (Login rpgfan3233)

No, it isn't. Haven't you never heard about FreeDOS? There's even a GUI that works with a number of DOS incarnations (not just MS-DOS and FreeDOS) called OpenGEM.



    
This message has been edited by rpgfan3233 on Mar 1, 2012 4:12 PM

Posted on Mar 1, 2012, 4:12 PM

Respond to this message   

Return to Index


Re: DOS is dead!

by (no login)

Glad you pointed that out! There's also a pretty nice GUI called Seal (or OZone... I don't recall what the most recent moniker is for the project) and many others. Not to plug my own GUI here, but I'm working on one of those as well, and this new BASIC compiler will ultimately tie into it so far as development goes.

Posted on Mar 2, 2012, 6:01 PM

Respond to this message   

Return to Index


You aren't the first, but you may be the last...

by (Login burger2227)
R

I have been here for enough years to see hundreds of new Basic programming languages and GUIs started so what good would one more be in the big picture.

Have fun...

Posted on Mar 2, 2012, 6:22 PM

Respond to this message   

Return to Index


Hi Mercury

by Galleon (no login)

'I would ask if you would mind me adopting some of your keywords for some functions I may find useful?'
That's fine.

Good luck with your project. I hope you know the can of worms you are about to embark on...

Posted on Mar 1, 2012, 4:44 AM

Respond to this message   

Return to Index


Re: Hi Mercury

by (no login)

Hi, Galleon! Thank you very much, that's good to hear :) I figure why complicate things by having two separate versions of BASIC that both do the same function, but with two different keywords? lol

Posted on Mar 2, 2012, 3:05 AM

Respond to this message   

Return to Index


How about trying to code a QB64 interpreter, instead?

by Pete (no login)

If you have 3 to 5 years to kill, why not see if instead of re-inventing the wheel, you can provide a hubcap for a working one? That's right, as much a s I loooooooooove Q64, I'd love it even more if an interpreter, another gargantuan project, gets coded someday.

Anyway, something I just wanted to throw out there, if you are interested.

Pete

Posted on Mar 1, 2012, 4:54 PM

Respond to this message   

Return to Index


why do you need a QB64 interpreter?

by Ben (no login)

no one uses interpreters. I remember you mentioned your 500mb 'business' programs that take hours to compile. probably a bunch of hardcoded data and spaghetti code.

but i think modern times they split up their programs into modules and only compile those that were modified and link them together. Im sure there's even tools to automate a lot of that and make for fast efficient programming.

Posted on Mar 1, 2012, 7:04 PM

Respond to this message   

Return to Index


Really?

by annon (no login)

The Internet: uses Javascript (interpreted)
Reddit.com: written in Common Lisp (has an interpreter) and later ported to Python (interpreted language)
Emacs: Written in C and Common Lisp

All these programs: http://en.wikipedia.org/wiki/List_of_Python_software
NASA: uses Python
==
MIT: uses Scheme
Rice University: uses Scheme
University of Texas at Austin: uses Scheme and Python

Posted on Mar 1, 2012, 7:25 PM

Respond to this message   

Return to Index


Interpreters are good for testing

by (Login rpgfan3233)

Interpreters have their uses, most notably testing code without waiting for a program to recompile. It simply executes statements as it reaches them. They really are quite useful at times, especially when things take forever to compile.

Posted on Mar 1, 2012, 7:27 PM

Respond to this message   

Return to Index


Re: How about trying to code a QB64 interpreter, instead?

by (no login)

Interesting idea... but I'm afraid I also don't really see the need for an interpreter. Perhaps there's something I'm missing, but wouldn't it be just as good to compile the code and run it? What advantages would the interpreter have over a compiler?

Posted on Mar 2, 2012, 3:09 AM

Respond to this message   

Return to Index


Re: How about trying to code a QB64 interpreter, instead?

by (Login MCalkins)
Moderator

The QBASIC 1.1 interpreter is extremely handy for debugging.

The main advantage of an interpreter over a source debugger is that the interpreter will let you make some changes to the program while it is running.

A debugger has the advantage of letting you see how your compiled program is actually running.

I wouldn't mind seeing a QB64 interpreter, but actually, a lot of the new QB64 functionality I either don't use, or rarely use. Mainly, I use the new data types, and DECLARE LIBRARY. I occasionally use _DELAY and _LIMIT. I will start using _CONTROLCHR and '$CONSOLE. Most of the other features, I haven't used yet. When I get around to it, I need to try QB64's PLAY statement's multiple note support. I tried it when it first came out, in one of the demos, but my computer was too slow for it at the time.

My point is that there is only a subset of QB64, and even QBASIC, functionality that I actually use. There are probably a few dozen QBASIC keywords that I never use.

Regards,
Michael

Posted on Mar 2, 2012, 5:36 PM

Respond to this message   

Return to Index


Re: How about trying to code a QB64 interpreter, instead?

by (no login)

Okay, I see your point. I believe what I call a debugger, you call an interpreter lol Indeed, being able to modify the program while running would be extremely helpful for debugging and testing. I believe QBASIC can generate a .map file, but off the top of my head I don't recall if it includes enough information to make the following possible, but couldn't one feed the map file, along with the source code file and the compiled finished program into a debugger to achieve the same function? If not, then the value of an interpreter would be tremendous enough to make me want to make one of those too :)

Posted on Mar 2, 2012, 6:09 PM

Respond to this message   

Return to Index


Re: How about trying to code a QB64 interpreter, instead?

by (Login MCalkins)
Moderator

>I believe QBASIC can generate a .map file, but off the top of my head I don't recall if it includes enough information to make the following possible, but couldn't one feed the map file, along with the source code file and the compiled finished program into a debugger to achieve the same function?

QBASIC 1.1 is basically just an interpreter. For QB4.5, I'm not sure.

For QB64, it uses MinGW's g++ and ld. The C++ code that QB64 generates can be recompiled with the proper switches for MinGW to generate DWARF debugging information, including C++ line numbers. gdb can then use that information to do C++ source debugging on the executable. (WinDbg and OpenWatcom's debugger don't seem to understand DWARF.) The problem is that QB64 programs use multiple threads. There seems to be one main thread that handles the actual program logic. However, one or more of the other threads is responsible for painting QB64's graphical window. Ideally, you would want to be able to suspend the thread that runs your code, while allowing the other threads to run, so the window gets updated and repainted. The other trick is to match up the QB64 line numbers to the C++ line numbers. I am slowly writing a debugger that does both (suspending the right thread, and matching up QB64 line numbers). I hope to resume work on it in the next week or two.

A debugger would let you view and set variables (except maybe variable length strings or dynamic arrays). However, the QBASIC interpreter actually lets you modify the QBASIC code while its running (up to a point). I guess some debuggers (DOS Debug, for example) would let you modify a program in assembly language, but it would be a bit of a trick to modify a compiled program in BASIC language while it's running... :-P. Even Immediate window like functionality might be a bit tricky. You could probably perform Immediate window style function calls by writing the parameters onto the program's stack, adjusting ESP and EIP, and single stepping (break points on QB64 source lines, not necessarily single stepping each machine instruction) the thread until EBP is back to its initial value. (If you do it that way, it might be best to do it when stopped on an actual source line, not somewhere between lines.)

I think several people on the QB64 forums have talked about QB64 interpreters. I'm thinking there might be an existing project, but I haven't read up on it yet.

Anyway, I wish you success in your project.

Regards,
Michael

Posted on Mar 2, 2012, 6:52 PM

Respond to this message   

Return to Index


Re: How about trying to code a QB64 interpreter, instead?

by (Login MCalkins)
Moderator

>(break points on QB64 source lines, not necessarily single stepping each machine instruction) the thread until EBP is back to its initial value. (If you do it that way, it might be best to do it when stopped on an actual source line, not somewhere between lines.)

Duh! Just put a breakpoint on the return address. :-P

Posted on Mar 2, 2012, 8:02 PM

Respond to this message   

Return to Index


_SNDRAW is pretty cool

by Ben (no login)

for me the best thing about qb64, i recommend trying make your own music and instruments and stuff

Posted on Mar 2, 2012, 8:21 PM

Respond to this message   

Return to Index


Re: new QBASIC-compatible compiler

by (Login MCalkins)
Moderator

I had meant to post this earlier, but my wireless signal strength was too weak, and I ran out of time...

>allow intermixing of assembly instructions directly in the source without any kind of special formatting or referencing.

an interesting idea, but Assembly has lots of instructions, which would become reserved keywords. Would you have 2 different syntaxes, one for BASIC and one for Assembly? I think C style inline assembly would be more practical. Something like:

DIM VOLATILE n AS LONG
n = 0
ASM
inc dword [n]
END ASM
PRINT d

Are you going to handle the Assembly yourself, or pass it on to some external assembler? For x86, I'd recommend nasm.

Are you going to let the programmer use the section directive, things like db and resb, and Assembly labels? Something like:

DECLARE IMPORT
FUNCTION DLLIMPORT CDECL printf&(format%&, ...)
END DECLARE

printf(consttext)
END

section .rdata
consttext:
db "Hello, world!",0xa,0x0

How are you going to handle underscore prefixes?

>what additional features and abilities did you always wish QBASIC had?

One of QBASIC's biggest faults is lack of unsigned math. QB4.5's compiled programs lack integer overflow checking by default, I believe, so unsigned addition or subtraction could be done. QB64 provides unsigned types, and also seems to lack integer overflow checking.

It wouldn't hurt to have bit shifts and rotations.

As you'll be merging Assembly into BASIC, you'll have both of those covered anyway.

There are a number of things I would change about BASIC, but in doing so, QBASIC compatibility goes out the window. For example, LOCATE should start at 0,0. File offset for GET and PUT should start at 0. But ideally, those would be part of a library, not built into the language.

QBASIC has a lot of complexity and odd behavior. The project would be significantly easier without the QBASIC compatibility requirement. Also, adopting the C style practice of a small simple language with extra functionality provided by libraries would simplify the project and probably produce a cleaner language.

Perhaps when creating multidimensional arrays, you could specify ROWMAJ or COLMAJ?

Are you going to have some sort of preprocessor?

What exact platforms are you planning on targeting? What are you going to do for a standard library?

-----

About a year ago, I made a rough draft of a new language. It would have had a roughly BASIC-like syntax, but would been very different from QBASIC.

For example, data types would have been BYTE, WORD, DWORD, etc... Data types would not have been signed or unsigned, the math operators themselves would have been. For example: u\ for unsigned integer division, and s>= for signed greater than or equal.

There would have been no implicit casts. Instead there would have been various built in functions to truncate, sign extend, or zero extend various types. For example: ZXBW() would zero extend a BYTE to a WORD. Strings would not have been built in, but would have been handled by a library.

I never posted that work... I haven't messed with it in almost a year. I can post it if anyone wants to see it, but it's not perfect. I started a compiler for it, but didn't get very far. Since then, I've become more comfortable with procedural C/C++. I think it might be more practical to promote C/C++ than to invent and promote a new language. There are things I like about my language in contrast to C/C++, but C/C++ would definitely beat mine on compactness. C and C++ are also standardized, with large code and user bases. C++ especially would have a safety advantage. They are the kings of systems programming languages, so any professional or serious programmer would need to know them. My language would probably be an amateurish distraction to anyone wanting to work on serious projects. That having been said, I'd like to write a working compiler for it someday. I had wanted to do it all myself, but I might have to try to find some public domain parser, or something, as text parsing is not what I enjoy.

Regards,
Michael



    
This message has been edited by MCalkins on Mar 2, 2012 5:24 PM

Posted on Mar 2, 2012, 4:57 PM

Respond to this message   

Return to Index


Re: new QBASIC-compatible compiler

by (no login)

Michael... wow. Many thanks for your input! So far as mixing BASIC and assembly into NextBASIC, I was thinking of just combining them as if they were one language:

'got a 1-up
INC playerLives
PRINT playerLives

I was thinking of having my own assembler built into the compiler, however I am starting to wonder as to the feasibility of this since the finished compiler will no doubt be huge. I'll probably end up just using secondary assemblers as QBASIC does, allowing the user to configure what actual programs to use. I would most likely include NASM with the compiler (if permitted) and make my own 68K assembler to include.

At this point, I see no reason not to allow the section directives. However, I see I'm going to have to study the intricacies of x86 assembly since I have to admit I'm not completely sure I know what a section directive is... or the significance of underscore prefixes, for that matter! :O

I agree! Unsigned math (a'la PowerBASIC) will already be included, along with bit shifts, rotations, and the ability to set, clear and test individual bits... I've sorely missed that in several of my own programs. And a more robust error and bounds checking system wouldn't hurt at all.

Your ideas about changing the origin of GET and PUT can already be changed with the OPTION BINARY BASE statement... unless I'm getting PowerBASIC confused with QBASIC again :| Regardless, that will be included as well, and I am thinking per your suggestion I could add capacity to change the origin of LOCATE with OPTION BASE as well, maybe something like:

OPTION LOCATE BASE 0

or

OPTION LOCATE BASE 1 'this would be the default

I'm not sure I completely understand the implications of the ROWMAJ and COLMAJ statements, could you expound on this a bit?

I'm not planning to use any kind of preprocessor at this time, but I haven't ruled it out entirely, as the demands of the project dictate.

The compact language/use libraries method will be kinda what I'm going with. Basically, I'll have one big library with all the conceivable support routines inside, which the compiler will automatically pull from as needed, but will be smart enough to only include the routines from that library that get used so that no dead code ends up in the finished program.

The target platforms to date are Intel x86, Motorola 68K and a format which can execute directly on the GUI I'm also working on. My goal for the 68K platform is to have the compiled and assembled app be able to run on the EASy68K emulator.

I like your language ideas, especially your unique view on typecasting! I tried making a BASIC-like language many many years ago myself, but it seems you came to the same conclusion I did: it's probably better to focus on an already widespread and well known language as opposed to creating a new one. However, if you ever do decide to embark on your own compiler journey, don't hesitate to let me know! The NextBASIC compiler will include some rudimentary text parsing routines, which you may find useful.

At this point, I'm just beginning this project, so it will be a while before any noticeable progress is made. I do, however, have a working optimizing expression evaluator which can turn something like (8 * 3) + timerCount ^ 2 + ((4 * points) * 100) AND 5 into a handful of assembly lines with all the operations done in the correct order. After the optimizing kicks in, the resulting assembly code can not only solve the equation, but it can do so using only about three registers.

Again, Michael, thank you. You've given me much to think about!
Mercury

Posted on Mar 2, 2012, 6:56 PM

Respond to this message   

Return to Index


Re: new QBASIC-compatible compiler

by (Login MCalkins)
Moderator

Yeah, I like contemplating these things even if I can't actually do them.

section directives tell the assembler to put the following output in a particular section (such as .text for code, .data for read/write data, .rdata for read only data, .bss for uninitialized (zeroed, in the case of win32) data, etc.), optionally with alignment specified.

The current Nasm documentation is a good info source on that.

C compilers on x86 add underscore prefixes to variable and function names. So for example, a variable named n is actually _n in the assembly code. Likewise, the function printf is actually _printf. Also, __stdcall, that is, WINAPI, functions might be additionally decorated, so that WriteConsoleA, for example, might be _WriteConsoleA@20, as it takes 20 bytes worth of parameters on the stack. (Unlike __cdecl functions, __stdcall functions clear the stack themselves. So WriteConsoleA will always be passed, and will always clear 20 bytes (on Win32).) (Note, however, that the DLLs export undecorated function names.) C++ compilers have their own name decoration, I believe for function overloading purposes. A C++ compiler can omit that, and just use plain C decoration by using extern(C) or something like that. For example, I think QB64's int QBMAIN(void *) becomes _Z6QBMAINPv.

I meant row major or column major, referring to the order in which multidimensional arrays are laid out. C uses row major, and QBASIC uses column major.

http://en.wikipedia.org/wiki/Row-major_order

>The target platforms to date are Intel x86, Motorola 68K and a format which can execute directly on the GUI I'm also working on.

On x86, what specifically? 16 bit? 32? 64? DOS, Windows, OS/2, Linux, FreeBSD?

>I do, however, have a working optimizing expression evaluator which can turn something like (8 * 3) + timerCount ^ 2 + ((4 * points) * 100) AND 5 into a handful of assembly lines with all the operations done in the correct order. After the optimizing kicks in, the resulting assembly code can not only solve the equation, but it can do so using only about three registers.

Cool. :-)

Regards,
Michael

P.S. one other thing to think about would be alignment within TYPE structures. For example:

TYPE t
a AS STRING * 1
b AS LONG
END TYPE

Would there be 3 bytes of padding between a and b? Would there be an option to specify?



    
This message has been edited by MCalkins on Mar 2, 2012 7:52 PM

Posted on Mar 2, 2012, 7:49 PM

Respond to this message   

Return to Index


Re: new QBASIC-compatible compiler

by (no login)

> section directives tell the assembler to
put the following output in a particular
section (such as .text for code, .data for
read/write data, .rdata for read only
data, .bss for uninitialized (zeroed, in the
case of win32) data, etc.), optionally with
alignment specified.

Oh. Nice : )


>I meant row major or column major,
referring to the order in which
multidimensional arrays are laid out. C
uses row major, and QBASIC uses column
major.

Ok, so you're referring to how the data is laid out in memory? Sure, there could be an option for that. Maybe another OPTION statement:

OPTION ARRAY ROW MAJOR

or

OPTION ARRAY COLUMN MAJOR


> On x86, what specifically? 16 bit? 32? 64? DOS, Windows, OS/2, Linux, FreeBSD?

When I was planning to build an x86 assembler into the compiler, I was aiming for an x86 DOS .COM file target, mainly because it would be easiest to make at first since it's basically a raw code image. If I go to NASM as you suggest (which is lookimg more likely) then the target could be anything NASM can assemble for.



>Cool. :-)

Thanks! When I finished that code and sat back and watch it pass every test I threw at it... I was beaming :-)
lol


>one other thing to think about would be alignment within TYPE structures.

I agree! In fact, I wouldn't be opposed to enabling this for every variable:

videoBuffer = 0xC000 ALIGN DWORD

or

TYPE t
a AS STRING * 1 ALIGN INTEGER 'this would make one byte of padding between the variables, assuming a two-byte INTEGER size
b AS LONG
END TYPE

Once again, thank you for giving me new and interesting things to think about! That's just what I need for this project.

Posted on Mar 3, 2012, 1:33 AM

Respond to this message   

Return to Index


Help Qbasic

by (no login)

Hello to all. I need a help with QBasic programming, related to the query and retrieval of a value in a file. Dat. The value in this file with a. Dat (a single numerical value) will be used to count (every time you run the program the file will be consulted and will be updated too (added with 1)). After turning off the pc and reconnects it again the last value will be stored normally. Do you have any idea how can I do this?

Tks,

Paulonobuo

Posted on Feb 27, 2012, 3:12 AM

Respond to this message   

Return to Index


A simple sequential file will do it...

by (Login qb432l)
R

OPEN "File.DAT" FOR APPEND AS #1
CLOSE #1

'These first lines will create a file if none exists, but will not alter
'the file if it exists. Without it, you would get an error the first time
'the program is run. Then:

OPEN "File.DAT" FOR INPUT AS #1
IF NOT EOF(1) THEN INPUT #1, NumRuns
CLOSE #1

'If the program has already been run, NumRuns will represents the number
'of times the program was run. If the program hasn't been run yet, the
'value of NumRuns will be 0. Incidentally, "IF NOT EOF(1)" prevents another
'possible file error if no value has been stored yet in the file.

NumRuns = NumRuns + 1
PRINT NumRuns

'The value of the variable NumRuns increases by 1 each time the program is
'run.

OPEN "File.DAT" FOR OUTPUT AS #1
WRITE #1, NumRuns
CLOSE #1

'Now the file "File.DAT" contains a variable which reflects the number of
'times the program has been run. Copy these lines of code and run the program
'over and over. You'll notice that each time it runs, the value of NumRuns
'will be printed. Notice that it increases by 1 each time. Turn off your computer
'and then when it reboots, run the program again. You'll notice that the previous
'value was saved until the next time the program was run.

'-Bob



    
This message has been edited by qb432l on Feb 27, 2012 10:30 AM

Posted on Feb 27, 2012, 10:22 AM

Respond to this message   

Return to Index


Help Qbasic

by (no login)

Hello Bob, thanks for responding. I'll be performing the tests as an example that you sent. Any other questions post again.

Thank you,

Paul Nobuo.
From Brazil

Posted on Feb 28, 2012, 2:52 AM

Respond to this message   

Return to Index


Re: A simple sequential file will do it...

by (no login)

Hello Bob! I need to send some information to be printed on a printer on LPT2 output. I used the SHELL command "TYPE file.dat> LPT2", but a message file not found. I made a change in the way too (SHELL "TYPE c: \ QBASIC2 \ file.dat> LPT2"), causing the same error. Could you help me with this problem?

Thank you,

Paul Nobuo
Brazil

Posted on Feb 28, 2012, 10:58 AM

Respond to this message   

Return to Index


*Sorry Paulo, can't help you there. Maybe someone else in the forum knows.

by (Login qb432l)
R

*

Posted on Feb 28, 2012, 12:54 PM

Respond to this message   

Return to Index


You can use SHELL with Notepad to print text files.

by (Login burger2227)
R

Notepad will use the default printer in Windows.

SHELL "start /min notepad /p " + filename$

Where filename$ is a string like:

filename$ = "TestFile.txt"

/p is used to print the file using Notepad

QB64 can also do that with LPRINT directly.

Posted on Feb 28, 2012, 1:18 PM

Respond to this message   

Return to Index


You can use SHELL with Notepad to print text files

by (no login)

Hi Clippy, okay? For my case, I used the command SHELL "copy filename.txt lpt2". Only one detail was occurring an error message, I did change the file name (renaming with fewer characters) and resolved. Now I have a problem, how do I change some variables in the file being printed by the SHELL command?

Thank you,

Paulo.

Posted on Mar 1, 2012, 8:11 AM

Respond to this message   

Return to Index


Help Qbasic printing file

by (no login)

Hello! I'm needing to use the print feature in the output lpt2. This output is connected to a model printer Zebra (TLP2844). The file I am using to print was built in the printer language (EPL). Could you tell me how can I send this information to label file, for example today's date. The test I conducted with the SHELL command "copy arquivo.dat lpt2" does not let me change the variables in this file.

Thanks,

Paulo
Brasil

Posted on Mar 5, 2012, 2:59 AM

Respond to this message   

Return to Index


Is that all that is in the file?

by (Login burger2227)
R

You can open the file several ways, but to PRINT text you can either re-write the file information or append information to it:

OPEN "filename.txt" FOR OUTPUT AS #1 'creates new empty file only

OPEN "filename.txt" FOR APPEND AS #1 'add information

Opens a file and clears any previous data. Then use PRINT #1 to write new text or use WRITE #1 to put data in as comma separated string data:

PRINT #1, DATE$; TIME$ 'date and time are QB string functions

WRITE #1, DATE$, TIME$

CLOSE #1 closes a file after output.

These values can be read using OPEN file$ FOR INPUT AS #1 with LINE INPUT #1 for text values or INPUT #1, day$, hour$ with comma separated values.

Posted on Mar 5, 2012, 6:16 AM

Respond to this message   

Return to Index


Open Sequential File and Display One Line At a Time

by (no login)

I've coded to open a sequential file. What I want to do is display to the screen one line at a time from that sequential file. My code does that okay, BUT it won't display entire lines, only about half.

For example, if the first line in the sequential file is "Now is the time for all good men to come to the aid of God and their country," I get "Now is the time for all good men to."

Any work-around code would be appreciated.

Posted on Feb 24, 2012, 9:55 AM

Respond to this message   

Return to Index


EDIT PREVIOUS MESSAGE

by (no login)

Here's my code to open/display the sequential file:

CLS
OPEN "AAA.TXT" FOR INPUT AS #1
INPUT #1, A$
PRINT A$

Here's the first line of the text file I want to open/display:

R1 - HKLM\Software\Microsoft\Internet Explorer\Main,Default_Page_URL = http://go.microsoft.com/fwlink/?LinkId=69157

Here's all that is actually displayed:

R1 - HKLM\Software\Microsoft\Internet Explorer\Main

Posted on Feb 24, 2012, 10:10 AM

Respond to this message   

Return to Index


How was "AAA.TXT" created?

by (no login)

Hi Pat, How did you create AAA.TXT file?
To get a real, non-biased look at this file,
position onto the command line and type:
TYPE AAA.TXT | MORE

This will show you what actually will be read by your program with a default buffer size of 512 bytes.

Regards..... Moneo

Posted on Feb 24, 2012, 10:38 AM

Respond to this message   

Return to Index


Try LINE INPUT

by lawgin (no login)

INPUT #1,A$ reads only up to the comma. LINE INPUT #1,A$ will input the entire line.

Posted on Feb 24, 2012, 10:54 AM

Respond to this message   

Return to Index


Right, use LINE INPUT

by (no login)

Good thinking, Lawgin.
+
Regarding INPUT #1, the manual says:
" The first character encountered after a comma that is not a space, carriage return, or line feed is assumed to be the start of a new item."

Pat's sample line has a comma, and applying this rule, the INPUT #1 will cause a line break.

Regards..... Moneo

Posted on Feb 24, 2012, 12:00 PM

Respond to this message   

Return to Index


* NOT if the line of text has a CRLF line break

by (Login burger2227)
R

Posted on Feb 24, 2012, 12:33 PM

Respond to this message   

Return to Index


That Did It..!

by Pat (no login)

Way to go! LINE INPUT did the trick. Much obliged to you and the others who responded to my question.

Posted on Feb 24, 2012, 7:59 PM

Respond to this message   

Return to Index


Today is Ash Wednesday. Can you calculate it?

by (no login)

Hi friends. I've been gone for a few years, but now I'm back.

For the years 1583 to 9999, calculate Ash Wednesday. Obviously, you need first to calculate the date of Easter Sunday, for which you can use any algorithm by the following men: Knuth, Oudin, Butcher, Zeller, or Gauss.

I suggest using Knuth's algorithm although it's a bit longer than the others, because it's clearer. It also has a minor bug beginning and after the year 9906, which he explains in the text following the code. I implemented the explanation and the entire algorithm then works 100%.

Have fun.

Regards..... Moneo

Posted on Feb 22, 2012, 5:12 PM

Respond to this message   

Return to Index


AW, come on, Easter is hard enough!

by (Login burger2227)
R

Besides my forehead is rented out right now!

It is 46 days before Easter Saturday, I believe.



    
This message has been edited by burger2227 on Feb 23, 2012 1:02 AM

Posted on Feb 23, 2012, 12:56 AM

Respond to this message   

Return to Index


Ash Wednesday

by Moneo (no login)

Actually, the date of Ash Wednesday is 46 days before Easter Sunday;
i.e., EASTERSUNDAY-46.

This subtract of 46 from a date is not so easily done in a program as it is with pencil and paper. (See my post called "Date Information Utility" in "proud of" section.)

Regards..... Moneo

Posted on Feb 23, 2012, 10:11 AM

Respond to this message   

Return to Index


* That's OK. I'm wore out from Fat Tuesday by then...

by (Login burger2227)
R

Posted on Feb 23, 2012, 10:19 AM

Respond to this message   

Return to Index


Does Easter - 46 truly end up on a Wednesday?

by (no login)

It occurs to me that after subtracting 46 days from the date of Easter Sunday, the program should double-check to see if the resultant date is indeed for a Wednesday. I neglected to do this check, and it now worries me.

Regards..... Moneo

Posted on Feb 24, 2012, 10:45 AM

Respond to this message   

Return to Index


I think it would have to

by lawgin (no login)

Easter is always a Sunday and every 7 days back is another Sunday. 42 days back is Sunday minus 4 more is Wednesday. Leap years have no effect on this.

Posted on Feb 24, 2012, 11:53 AM

Respond to this message   

Return to Index


* It still worries me.

by (no login)

Posted on Feb 24, 2012, 12:04 PM

Respond to this message   

Return to Index


* Correct. Leap years don't effect the day of the week, just the date (like this year)

by ChronoKitsune (no login)

Posted on Feb 24, 2012, 12:32 PM

Respond to this message   

Return to Index


Leap year DOES effect Ash Wednesday calculation

by (Login emoneo)

Ash Wednesday is Easter Sunday minus 46 days.

If you do this calculation by hand on your calendar by counting backwards from Easter Sunday, and this is a leap year, you will automatically compensate for the leap year.

However, to program this minus 46 days on a leap year, is another matter.
Your code MUST be aware that it is leap year. (See Lawgin's sample code on February 19, 2012.)

Sorry for the delay in responding.

Regards..... Moneo

Posted on May 23, 2012, 6:51 PM

Respond to this message   

Return to Index


Trouble posting code

by lawgin (no login)

I wanted to post my response, Moneo, but the network54 editor mangled my code. It seems to have something to do with a minus sign following a less than symbol.

Yes, I just tried it here and everything after the minus sign on the same line disappears.


<-test message

Posted on Feb 23, 2012, 10:38 AM

Respond to this message   

Return to Index


*Now it's back--doesn't show in the preview!

by lawgin (no login)

Posted on Feb 23, 2012, 10:40 AM

Respond to this message   

Return to Index


Yes, Moneo, I remember

by lawgin (no login)

I dug up my response to the Easter Challenge a few years ago. The program is kind of muddled and it's Greek to me now, but I think I used one of the algorithms you mentioned (maybe Gauss). I just tacked on the end a calculation for Ash Wednesday.


CLS
DO
INPUT "Enter year"; y
y = INT(y)
LOOP WHILE y < 1583 OR y > 9999
y1 = y \ 100
k = 4 + y1 - y1 \ 4
m = 11 + k - (8 * y1 + 13) \ 25
r1 = y MOD 4: r2 = y MOD 7: r3 = y MOD 19
r4 = (19 * r3 + m) MOD 30
r5 = (k + 2 * r1 + 4 * r2 + 6 * r4) MOD 7
IF (r4 = 28) AND (r5 = 6) THEN
SELECT CASE m
CASE IS = 2, 5, 10, 13, 16, 21, 24, 29, 32, 43, 46, 51, 54
east$ = "April 18"
END SELECT
END IF
IF (r4 = 29) AND (r5 = 6) THEN east$ = "April 19"
IF r4 + r5 < 10 THEN east$ = "March" + STR$(r4 + r5 + 22)
IF east$ = "" THEN east$ = "April" + STR$(r4 + r5 - 9)
PRINT "Easter: "; east$

'this part was added for Ash Wednesday

'determine if leap year
isleap = (y MOD 4 = 0) + (y MOD 400 = 0) - (y MOD 100 = 0)

'subtract 46 from Easter's date
offset = VAL(RIGHT$(east$, 2)) - 46
mth$ = LEFT$(east$, 3)

'adjust date and month for Ash Wednesday
IF offset < -30 THEN
ash$ = "February" + STR$(offset + 59 - isleap)
ELSE IF offset < -20 AND mth$ = "Apr" THEN ash$ = "March" + STR$(offset + 31)
END IF
IF offset < -14 AND mth$ = "Mar" THEN ash$ = "February" + STR$(offset + 28 - isleap)
PRINT "Ash Wednesday: "; ash$
END

Posted on Feb 24, 2012, 10:59 AM

Respond to this message   

Return to Index


* Subtract one for Fat Tuesday!

by (Login burger2227)
R

Posted on Feb 24, 2012, 11:03 AM

Respond to this message   

Return to Index


* Your calculation of Ash Wed. is Greek to me.

by (no login)

Posted on Feb 24, 2012, 12:07 PM

Respond to this message   

Return to Index


It's not that bad

by lawgin (no login)

Suppose it's Feb 3 and you want to go 5 days back. That moves you into January. 5-3 = -2 plus 31 days in Jan = 29th.

Posted on Feb 24, 2012, 12:13 PM

Respond to this message   

Return to Index


Has anyone done this before?

by Zack (no login)

Hi, I was just wondering if anyone has made an open-source email program, I am only really interested in the send and receive functions because I wouldn't even know where to start. If there are none then could I have some advice of like the dynamics of an email PING or something? Also I wanted to find a visualizer program for like a music program. I could probably make a mediocre one but I know there are people who are really good with graphics. Anyway, all help is appreciated. Cheers :)

Posted on Feb 20, 2012, 12:35 PM

Respond to this message   

Return to Index


QB64 can do emails

by (Login burger2227)
R



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

The only problem might be with the Email service provider. They may block them as automated spam.

Posted on Feb 20, 2012, 3:06 PM

Respond to this message   

Return to Index


Re: QB64 can do emails

by Pete (no login)

Those *** **** low life ******* at Cox Communications block them. Get an Aussie ISP, they'll let anything pass through.

Pete

- Cox, you're _ _ _ _ _ _ in the digital age. (I'd like an "F" Pat.)

Posted on Feb 21, 2012, 9:39 PM

Respond to this message   

Return to Index


Re: Has anyone done this before?

by (Login MCalkins)
Moderator

>Also I wanted to find a visualizer program for like a music program.

When I first read that, I thought you were talking about sheet music. So I went and dug up this link:

http://www.network54.com/Forum/13959/thread/1122680045/

I wrote it many years ago, and haven't messed with it at all recently. It could probably use major improvements.

Then, when I came back and reread that part of your post, I realized you probably meant something like the cute graphics windows media player comes up with if it hasn't been disabled.

I have it disabled on mine, but I guess it displayed anyway, when I went to full screen one time on Windows media player. I was listening to a Tool song, but because I didn't think there would be any "visualization" from WMP, I thought it was a music video, and was thinking Tool had done a very cool video with all the geometric patterns and such. Then, of course, I realized what happened...

You might try using fractals or something. Artelius, aka Ildûrest, had some cool programs that did things like that.

Regards,
Michael



    
This message has been edited by MCalkins on Feb 22, 2012 12:06 AM

Posted on Feb 22, 2012, 12:05 AM

Respond to this message   

Return to Index


* Thanks, you guys are great, as always :)

by Zack (no login)

Posted on Feb 24, 2012, 12:46 PM

Respond to this message   

Return to Index


Python can do this

by (no login)

# -*- coding: iso-8859-1 -*-

# http://www.python.org/doc/
# Open port 995

import poplib , string , re , os

# POP3_SSL (le port par défaut est 995)

C = poplib.POP3_SSL('pop.gmail.com',995)
C.user('username')
C.pass_('password')

# STAT is retreived and stored in RESULTAT
# RESULTAT looks like (if the box is empty) "(0, 0)"

RESULTAT = str(C.stat())

# Deconnection :

C.quit()

print RESULTAT

====================================

This will check if you have mail.

Posted on Feb 26, 2012, 1:36 AM

Respond to this message   

Return to Index


* The anatomy of a win32 Hello World program. (url)

by (Login MCalkins)
Moderator

http://www.network54.com/Forum/632471/message/1329702969/

Posted on Feb 19, 2012, 8:41 PM

Respond to this message   

Return to Index


Probblem Getting QB64 To Start

by (no login)

I downloaded the Linux version of QB64, version 0.942, and built it by running setup.sh. The build went smoothly and, at the end, started QB64 running. It started up nicely, I ran a few test programs on it, with good results, then closed it down. When I attempted to restart the program a few minutes later, it opened a blank window with the message:

UNEXEPECTED INTERNAL COMPILER ERROR
Caused by(or after):
LINE 0:

What makes this puzzling is that I started the program with the command line
./qb64

exactly the same command as is in the last line of setup.sh. There it runs, externally it doesn't.
Is anyone else having this problem, and, if so, any insights into how to solve it? TIA

A.



Posted on Feb 19, 2012, 6:05 PM

Respond to this message   

Return to Index


Noted.

by Galleon (no login)

I don't have any solution for you atm. Try deleting everything inside your internal/temp folder and starting QB64 again.

Posted on Feb 20, 2012, 5:04 AM

Respond to this message   

Return to Index


Fixed the Problem

by (no login)

Thanks for your reply. Turns out the problem was a matter of setting the right permissions on the executable and the QB64 subdirectories. I hadn't realized that the "Internals" sub-dir was so critical to QB64 running, so once I got the permissions straight there, it started cleanly every time. It was an "interesting" learning experience :-)

Posted on Feb 20, 2012, 7:13 AM

Respond to this message   

Return to Index