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



Discussion forums removed at QB64 forum but will stay open here.

by (Login The-Universe)
Admin

I just posted this message for those coming from QB64.net, due to the closure of the Non-QB64 Discuaaion Forum:

http://www.network54.com/Forum/183705/message/1361124471/QB64+users+can+discuss+politics%2C+economy%2C+religion%2C+etc.+here

I'm happy to continue supporting the QB Forum, and maintaining the the traditions and values that give this place a soul of its own.

Ronald Reagan was known as "The Great Communicator" and in that spirit, I want the whole community involved in what goes on at these boards, and have always discussed matters with the community, before making any decisions that affect everyone.

Although nothing is changing at the moment, I want to alert our users that you may be seeing some increased activity in the Cafe. Personally, I like discussing politics and the economy and used the non-QB64 discussion forum for many of those posts. I will be posting soon. For those who are not into politics, I ask that you leave the treads to those who are. Expect to see some heated discussion at times, as is the nature of said topic. For those who like politics, the economy, and education, I look forward to reading your opinions, and replies.

Pete

Posted on Feb 17, 2013, 10:44 AM

Respond to this message   

Return to Index


Kind-a messy format

by Bert22306 (Login Bert22306)

Hey Pete. I don't get why this forum UI automatically fills in your e-mail address, which typically one wouldn't want on the posts, and does not fill in your Name. Seems kind of bass ackwards.

Posted on Feb 25, 2013, 4:29 PM

Respond to this message   

Return to Index


The user name will autofill too

by (Login burger2227)
R

My posts in some of the forums like this one tries to fill in my real name the first time I post after not being here in a while. It is highlighted so pressing C causes autofill to substitute Clippy.

A lot of times the email has not filled in, but that may be a problem with N54. They run this provider in a basement somewhere maybe China...

Posted on Feb 26, 2013, 11:45 PM

Respond to this message   

Return to Index


Kewbie Newbie???

by Solitaire (no login)

A couple of days ago I got an email from Kewbie Newbie entitled, "Re:" with nothing but a link inside to what looks like a promotional item. It was addressed to me and 9 others. I was not about to click on the link. I simply relegated it to my Spam folder and deleted it.

Did it come from the Kewbie Newbie on this forum, was it just a coincidence, or did someone hijack Kewbie's email?


(Note: I posted this message originally on the community subforum but was told that Kewbie only checks the main forum.)

Posted on Feb 15, 2013, 6:14 AM

Respond to this message   

Return to Index


what response are you expecting? "not it wasn't me, my email was hijacked..."

by Ben (no login)

what does that change? remove the email and move on

Posted on Feb 15, 2013, 6:19 PM

Respond to this message   

Return to Index


But it is good to notify him.

by (Login MCalkins)
Moderator

Sometimes, people are not aware that they have malware on their computer, or that some botnet has their email password. Informing them is courteous, so that they can correct the problem.

Regards,
Michael

Posted on Feb 15, 2013, 7:13 PM

Respond to this message   

Return to Index


I don't check my email as often as I should.

by (Login Kewbie)
R

WOW! A list of delivery failure notices sad.gif

Well, I've changed the password, for whatever good that'll do. DRAT!!! I've used that password for so long, I'll never be able to remember the new one. Maybe I should post it here :-D

Well, only time will tell.

Kew

Posted on Feb 16, 2013, 12:40 AM

Respond to this message   

Return to Index


Float arithmetic

by lawgin (no login)

IF .1 + .2 = .3 THEN PRINT "equal" ELSE PRINT "unequal"

Why is the result "equal" in qb64 and "unequal" in qb4.5?

Posted on Feb 8, 2013, 1:19 PM

Respond to this message   

Return to Index


because .1 + .2 actually equals .30000000000000004, not .3

by Ben (no login)

Posted on Feb 8, 2013, 1:33 PM

Respond to this message   

Return to Index


*I get that, but why a different result with qb64?

by lawgin (no login)

Posted on Feb 8, 2013, 3:16 PM

Respond to this message   

Return to Index


Number of byes allocated for the floating point type matters.

by Solitaire (Login Solitaire1)
S

In QB 4.5, the SINGLE type is 7 significant digits; The DOUBLE type is 15 or 16 significant digits. In that case, it still reads the result as being 3 since it cannot read the non-zero digit past the least significant digit, which is still a 0. I'm guessing the floating point type used in QB64 has a greater number of bytes.



    
This message has been edited by Solitaire1 on Feb 8, 2013 3:28 PM
This message has been edited by Solitaire1 on Feb 8, 2013 3:26 PM

Posted on Feb 8, 2013, 3:23 PM

Respond to this message   

Return to Index


This is probably more than anyone cares to know

by lawgin (no login)

I find that if you do a binary expansion of the decimals, the sum comes out correct only at certain points in the expansion.

.1 = .000110011001100110...
.2 = .001100110011001100...
------------------------------------
.3 = .010011001100110011...

I'm guessing that qb64 breaks it off at the "right" point whereas qb does not.

Posted on Feb 9, 2013, 10:21 AM

Respond to this message   

Return to Index


You are on the right track...

by (Login MCalkins)
Moderator

Note that this produces "unequal" in both QBASIC and QB64:

DEFDBL A-Z
a = .1#
b = .2#
c = a + b
d = .3#
IF c = d THEN PRINT "equal" ELSE PRINT "unequal"

whereas this produces "equal" in both QBASIC and QB64:

DEFSNG A-Z
a = .1
b = .2
c = a + b
d = .3
IF c = d THEN PRINT "equal" ELSE PRINT "unequal"

As has been mentioned in the past, the math is done using extended precision, and is rounded to double or single precision when stored in a variable. So, then, when and whether the number gets stored in a variable becomes significant. If the number is never stored in a variable, it stays extended precision.

Perhaps QBASIC and QB64 have some internal difference of whether and how things like:

IF .1 + .2 = .3 THEN PRINT "equal" ELSE PRINT "unequal"
and:
IF .1# + .2# = .3# THEN PRINT "equal" ELSE PRINT "unequal"

use temporary variables.

There is a bug in QB64, in that it treats SINGLE literal constants as if they were DOUBLEs. ( http://www.qb64.net/forum/index.php?topic=10509.0 ). However, I'm guessing that you've found a separate problem.

Clippy started a bug topic for you:
http://www.qb64.net/forum/index.php?topic=10644.0

Regards,
Michael

Posted on Feb 18, 2013, 12:29 AM

Respond to this message   

Return to Index


Yes, it's a bug in qb and qb64

by lawgin (no login)

DEFDBL A-Z
a = .1#
b = .2#
c = a + b
d = .3#
IF c = d THEN PRINT "equal" ELSE PRINT "unequal"
PRINT c
PRINT d

If I run this code in qb or qb64, the printout is:
unequal
.3
.3

Python is also subject to floating point inaccuracies, but if I run the equivalent in Python,I get:
unequal
.30000000000000004
.3
which is at least consistent.

Posted on Feb 18, 2013, 9:57 AM

Respond to this message   

Return to Index


array data saving

by Leon Schrecengost (no login)

Is there anyway to move the data stored in an array to the hard drive or USB device. This would prevent losing the data when the array is full and I restart the pgm.I can sent it to the printer but would like it stored for future manipulation.
Leon

Posted on Feb 7, 2013, 1:56 PM

Respond to this message   

Return to Index


Yes. Just open a file and save the data.

by Solitaire (no login)

Here is an example using an array. Note that it will create a new file every time you run the program, overwriting the previous data. You will need to write two separate programs, one to create a new file for entering data, and another one to open it to read the data. If you want to add to the data without overwriting the file, then open it for APPEND instead of for OUTPUT.


DIM myfile AS STRING, x AS INTEGER
CLS
RANDOMIZE TIMER
DIM myarray(1 TO 25) AS INTEGER
DIM newarray(1 TO 25) AS INTEGER
' Get the full path name of the file to save
INPUT "Enter full path name of file to create: ", myfile
PRINT
' Assign random number values to array for testing.
FOR x = 1 TO 25
    myarray(x) = INT(RND * 900) + 100
NEXT x
' Display the data in the array for testing.
FOR x = 1 TO 25
    PRINT myarray(x);
NEXT x
' Open a new file and save the array values to it.
PRINT : PRINT
PRINT "Array is in memory. Will now save to a file."
' If path is incorrect, will end program
ON ERROR GOTO wrongfile
OPEN myfile FOR OUTPUT AS #1
FOR x = 1 TO 25
    WRITE #1, myarray(x)
NEXT x
CLOSE #1
' Open the file and read the saved data into an array.
' A new array is used just to show that it works,
' since the first array is still in memory.
PRINT : PRINT
PRINT "File was saved and will now open to read the data."
OPEN myfile FOR INPUT AS #1
FOR x = 1 TO 25
    INPUT #1, newarray(x)
NEXT x
CLOSE #1
' Now print out the data from the new array.
PRINT : PRINT
FOR x = 1 TO 25
    PRINT newarray(x);
NEXT x
END

wrongfile:
PRINT : PRINT
PRINT "Incorrect pathname. Start over."
END

Posted on Feb 7, 2013, 5:18 PM

Respond to this message   

Return to Index


BLOAD and BSAVE are generally used for storing arrays

by Ben (no login)

Posted on Feb 8, 2013, 10:30 AM

Respond to this message   

Return to Index


* good point Ben.

by (Login burger2227)
R

Posted on Feb 8, 2013, 1:06 PM

Respond to this message   

Return to Index


In QB64 you can store and read an integer array all at once.

by (no login)

Write it to a BINARY file:

PUT #1, , Array%

Read it back to the same size array:

GET #2, , NewArray%

Posted on Feb 8, 2013, 8:36 AM

Respond to this message   

Return to Index


qb64

by Leon Schrecengost (no login)

Does this only apply to qb64 or will it work with qbasic?
Leon

Posted on Feb 10, 2013, 7:29 AM

Respond to this message   

Return to Index


Qbasic can use BSAVE and BLOAD

by (Login burger2227)
R

They are a little harder to code, but they can save and load integer array data with files.

Posted on Feb 10, 2013, 8:43 PM

Respond to this message   

Return to Index


BSAVE

by Leon Schrecengost (no login)

I wanted to try BSAVE and it wants to know the memory location the data I want to save is located. How do I know the memory address that the array data is stored? Am I making it more difficult than it is?
Leon

Posted on Feb 11, 2013, 12:17 PM

Respond to this message   

Return to Index


How to BSAVE and BLOAD...

by (Login qb432l)
R

The memory location can be determined using the functions VARSEG and VARPTR

VARSEG (VARiable SEGment) returns the segment address of a variable.
VARPTR (VARiable PoinTeR) returns the offset address of a variable.

The segment address is like the street name in memory.
The offset is like the house number on that street.

DEF SEG means DEFine SEGment and sets the segment marker to the
first element of your array.

ByteSize& refers to the number of bytes to be saved. Calculate this
based on the number of elements in the array, multiplied by the
number of bytes in the data type. For example, an integer array uses
two bytes per element, so ByteSize& = NumberOfElements * 2

'To BSAVE:
DEF SEG = VARSEG(Array(0)) 'first element of the array, 0 or 1
BSAVE "FileName.BSV", VARPTR(Array(0)), ByteSize&
DEF SEG 'restores segment marker to its default location

'To BLOAD:
DEF SEG = VARSEG(Array(0))
BLOAD "FileName.BSV", VARPTR(Array(0))
DEF SEG

-Bob

Posted on Feb 11, 2013, 10:47 PM

Respond to this message   

Return to Index


new user to qbasic - random question

by (no login)

I've been trying to learn qbasic on my own, since I was told it will make learning VB much easier. However, while going through these tutorials I have a question about RANDOMIZE TIMER.

(i'm using a schoolfreeware tutorial number 13)

My code is like this
for x = 1 to 10
Randomize timer
print int (rnd*10)+1;
next x

I noticed in the video that I was getting very very similar "random" results compared to the video. Why is this? What is the basis for basic's randomization?

Posted on Feb 2, 2013, 1:14 PM

Respond to this message   

Return to Index


Randomize

by Solitaire (Login Solitaire1)
S

First of all, Randomize Timer needs to be placed only once, above the FOR loop, not inside it, as it doesn't need to be repeated. It will continute to generate new random numbers starting from the seed, which by default is the current value of the system timer.

The random number generator is based on the system timer, which changes every second. This is what makes it unpredictable. The value is a floating point number, and in most cases you will need to get the integer value. The range is obtained by subtracting the lowest from the highest and adding 1.

Here is an example to try:

============================================================================
DIM first AS INTEGER, last AS INTEGER, range AS INTEGER, x AS INTEGER
DIM snum AS STRING, E AS STRING
RANDOMIZE TIMER
CLS
PRINT "Input starting and ending range of 10 random numbers."
PRINT
DO
    INPUT "Enter first number in range:  ", snum$
    first = VAL(snum$)
    INPUT "Enter last number in range:  ", snum$
    last = VAL(snum$)
    range = last - first + 1
    DO
        PRINT
        FOR x = 1 TO 10
           PRINT INT(range * RND) + first; "  ";
        NEXT x
        PRINT : PRINT
        PRINT "Press Enter to repeat with same range of numbers,"
        PRINT "N for new numbers, or Q to quit... "
        E$ = UCASE$(INPUT$(1))
    LOOP UNTIL E$ = "N" OR E$ = "Q"
    CLS
LOOP UNTIL E$ = "Q"
END
=============================================================================

You can elect to change the seed to a fixed number instead of the timer, but it will continue to generate new numbers unless you restart the program with the same seed. This is useful for statistical studies, but for most purposes, you will need to use the timer for unpredictable generation of random numbers.

Posted on Feb 2, 2013, 2:57 PM

Respond to this message   

Return to Index


Solitaire, with all due respect...

by (Login Kewbie)
R

Your statement that "The random number generator is based on the system timer,..." is, at the very least, misleading, and frankly, completely incorrect.

Then you go on to say "...which changes every second. This is what makes it unpredictable". Given that it increments by 1 every second, I'd say that's very predictable.

The only function the TIMER statement (which accesses the system timer) has in generating random numbers is to provide a continually changing seed which it can optionally provide to the RANDOMIZE statement.

The actual random numbers are produced by using "large" prime numbers, in QB's case, the two largest primes that will fit in a 32-bit integer.

I didn't originate this, and don't remember where I got it, so I can't give apropriate credit, but here is an aproximation of how it's done internally by the RND function:

DECLARE FUNCTION RandomNum! ()
FOR ndx = 1 TO 10
PRINT RandomNum
NEXT ndx

FUNCTION RandomNum
STATIC Seed AS DOUBLE
DIM Temp AS DOUBLE

Temp = (16598013# * Seed + 12820163)
Seed = Temp - INT(Temp / 16777216) * 16777216
RandomNum = Seed / 16777216
END FUNCTION

The actual RND function obviously has some way of externally providing a seed. This version will always produce the same results, given that a method of changing the seed is not present.

Kew

BTW, the list of numbers produced is:

.7641413
.3576428
.1068624
.7075312
4.804176E-02
.5364588
.7288614
.6161923
.2480838
.4082566



    
This message has been edited by Kewbie on Feb 6, 2013 9:34 AM
This message has been edited by Kewbie on Feb 6, 2013 9:30 AM

Posted on Feb 6, 2013, 9:24 AM

Respond to this message   

Return to Index


* Noted

by Solitaire (no login)

Posted on Feb 7, 2013, 4:35 PM

Respond to this message   

Return to Index


Re: Solitaire, with all due respect...

by (Login MCalkins)
Moderator

RND is a Linear Congruential Generator.
http://en.wikipedia.org/wiki/Linear_congruential_generator

state = (a * state + c) mod m

where:

m = 16,777,216 (hex: 1000000 )
a = 16,598,013 (hex: fd43fd )
c = 12,820,163 (hex: c39ec3 )

Neither a nor c are prime.
a's factors are: 1, 3, 227, 681, 24373, 73119, 5532671, 16598013
c's factors are: 1, 2293, 5591, 12820163

However:
c and m are relatively prime. (c is odd.)
a-1 is divisible by the only prime factor of m. (a is odd.)
a-1 and m are both multiples of 4.

See:
http://www.network54.com/Forum/178387/message/1328259950/
QB64 allows the code to be simplified:
http://www.qb64.net/forum/index.php?topic=6891.msg70939#msg70939

Regards,
Michael



    
This message has been edited by MCalkins on Feb 18, 2013 1:31 AM

Posted on Feb 18, 2013, 1:31 AM

Respond to this message   

Return to Index


Re: new user to qbasic - random question

by (no login)

I don't know the anser to your question exactly, but look into the RND function. Randomize always gives the same result. I will try to do some research and get a better answer for you in the next couple of days. Try usıng RANDOMIZE by itself in the immediate window and see what happens. You get there by hitting f6. I am a new programmer myself :-)

Good luck,

Benjamin

Posted on Feb 3, 2013, 9:53 PM

Respond to this message   

Return to Index


qbasic download

by rich (no login)

i wanted to know where people on this forum would go to download q basic.
thanks

Posted on Feb 1, 2013, 10:27 AM

Respond to this message   

Return to Index


Re: qbasic download

by (Login MCalkins)
Moderator

ftp://ftp.microsoft.com/Products/Windows/Windows95/CDRomExtras/OtherUtilities/olddos.exe

That contains QBASIC 1.1 (qbasic.exe, qbasic.hlp), as well as other files, including the MS-DOS 6.22 Help files. (help.com, help.hlp).

From:
ftp://ftp.microsoft.com/services/technet/windows/msdos/RESKIT/SUPPDISK/

you can download the 4 sample QBASIC programs: (gorilla.bas, nibbles.bas, money.bas, remline.bas).

If you want QB64:
http://www.qb64.net/forum/index.php?board=2.0

If you want QB64 GL:
http://www.qb64.net/forum/index.php?board=25.0

Regards,
Michael

Posted on Feb 1, 2013, 11:08 AM

Respond to this message   

Return to Index


OR ...

by OPRESION (no login)

http://www.qbasic.phatcode.net/#COMPILERS

Posted on Feb 3, 2013, 8:51 AM

Respond to this message   

Return to Index


I need advice

by (no login)

I need advice on how to become a professional programmer.... what do I do?????

Posted on Feb 1, 2013, 3:27 AM

Respond to this message   

Return to Index


Re: I need advice (4 edits.)

by (Login MCalkins)
Moderator

That's a question that will bring up a bunch of questions.

Let me state up front that I am not a professional programmer. I consider myself to be an advanced amateur. (Others might consider me to be intermediate.). (I have been paid for one or two programs, but I'm not really a professional.)

What are your goals? What kind of programming do you want to do? Web? Smartphone apps? Desktop apps? Games? Operating systems? Something else?

-----

What languages do you know now? What languages would you like to know? What is your current skill level?

If you want to write operating systems or device drivers, you should know C++ and Assembly. You should also be familiar with your hardware.

If you want to write desktop apps, you should probably know C++, although other languages could be used, such as C#, VB, and QB64. If you want to write GUI apps, you should be familiar with GUI programming.

If you want to write games, you should know C++. You should also know 3D graphics programming, such as OpenGL or Direct3D.

If you want to write smartphone apps, the languages would probably be Java for Android (some C++ can be used), and Objective-C (including Objective-C++) for iOS. Other people could give you better info.

If you want to do web programming, scripting languages are more traditional. These could include Python, PHP, and Perl. However, you could use a compiled language like C++ on the server side. JavaScript is very common on the client side. You would know HTML/CSS and/or XHTML. Flash and Java are other things which might be used.

-----

Regardless of language, programming is a way of thinking. Learning it takes time, patience, and effort. There are several styles of programming, including procedural, object oriented, generic, functional, etc... The different styles involve different ways of thinking.

Try it, and keep working to improve. It will take time, but you will gradually get better and better at it.

Intelligence, comprehension, and understanding are important. You will eventually learn to think and reason on programs. It really is a way of thinking, and you will eventually learn it.

-----

You should develop debugging skills. You should learn how to effectively use the debugging tools of your chosen language and platform.

-----

There are skills beyond just actual coding skill which would be useful to a professional programmer. For example, you would eventually need to use some kind of revision control system. Familiarity with a text comparison program would probably be good. (This might be integrated into the revision control software)

If you're going to be a professional, you're probably not going to be on the project all by yourself. You'll probably have to be working with other programmers, perhaps as part of a team. You'll have to cooperate and coordinate with them.

You'll probably find that modular design will be important. One of my only experiences with a team project was the Kriegspiel chess program, led by Mac, and with Pete, Mennonite, and me helping. Mac gave us each parts of the project to work on, and clearly defined interfaces, so that the pieces would fit together properly.

-----

Professional code should be well written. It should be safe, secure, correct, and stable. Also, it should be easily maintainable by you and others in the future.

-----

You should be able to read and understand documentation and specifications. Everything from language and compiler documentation, to platform and library documentation, to the specifications of whatever you are implementing.

-----

You should have some familiarity with the building blocks of programming. I like to emphasize some lower level details like data types (how integers are stored, for example), how arrays are laid out, etc... There will probably be a balance between being obsessed with low level detail, and being blissfully ignorant of it. You want your code to be correct and efficient. The optimizing compiler is your friend. Let it do its job. Try to help it where you can, and try to avoid getting in its way. (Micromanagement isn't good, because it will take too much of your time, and would probably get too machine-specific. That's the compiler's realm. However, total ignorance of efficiency isn't good either. Don't fall for the idea that since computers are so fast now-adays that it doesn't matter anymore.) (Some parts of a program need to be more efficient than others. For example, insides of critical loops that would get executed millions of times need to be efficient, whereas code that just gets executed a few times doesn't matter as much.)

-----

Learning programming doesn't happen overnight. Expect it to take years to become a good programmer. Avail yourself of resources, like this forum and others. Stay optimistic, and have fun. :-)

(That doesn't mean that you have to wait years before getting hired. You can gain on-the-job experience, which will help you become better. You might consider volunteering on an open-source project, to gain experience, if your schedule and financial situation allows.)

-----

Be mindful of the legal issues, such as copyright, licensing, patents, trade secrets, non-disclosure agreements, non-compete contracts, etc...

For example, if you write code for your employer, your employer probably owns the code. But what about code that you write on your leisure time? Does your employer own that also? What if you write similar code both for yourself and your employer? (There have been legal fights on issues like this.)

Regards,
Michael



    
This message has been edited by MCalkins on Feb 1, 2013 8:12 AM
This message has been edited by MCalkins on Feb 1, 2013 8:12 AM
This message has been edited by MCalkins on Feb 1, 2013 8:09 AM
This message has been edited by MCalkins on Feb 1, 2013 8:06 AM

Posted on Feb 1, 2013, 7:55 AM

Respond to this message   

Return to Index


Programming credentials

by Solitaire (no login)

You will probably need to enroll in a course of studies in order to obtain credentials that employers are looking for. Check out colleges or private schools that offer such courses. You will need to pass tests given by software companies (such as Microsoft). There are books available with sample tests. Check out your local bookstores or libraries for these resources.

Posted on Feb 1, 2013, 8:54 AM

Respond to this message   

Return to Index


How?

by (no login)

How can I become a good programmer? What are those steps I need to take?

Posted on Feb 1, 2013, 3:24 AM

Respond to this message   

Return to Index


Displaying Array data

by Leon Schrecengost (no login)

I have an interesting problem. I have several arrays dim as 20,2. When I try to display array z5$(22,1) it causes a problem with the other array displays. I can display other arrays up to (23,2) with no problem. I press "v" to get to the subroutine that in turn calls the subs for all the other arrays. When I press "v" the second time to up date the disply is when the problem happens If you want I can post the pgm.
Leon

Posted on Jan 31, 2013, 8:04 AM

Respond to this message   

Return to Index


Re: Displaying Array data

by Pete (Login The-Universe)
Admin

I would change DIM (22,1) to REDIM (23,2) but if that doesn't work, yes...

We would need to see it, as the description doesn't give us the error code or show us what is changing in the display. Also, please tell us what you are running, QB64, QB, or QuickBASIC.

Thanks,

Pete

Posted on Jan 31, 2013, 8:34 AM

Respond to this message   

Return to Index


problem code

by Leon Schrecengost (no login)

I'm running qbasic
I've forced z4$(1,1) and z4$(1,1) to 00:00:00 and 11:11:11
Press "v" atleast twice to see the problem
Leon

CLS : 'Program name is FURNMONx
flag1 = 0: flag2 = 0: flag3 = 0: flag4 = 0: flag5 = 0: flag6 = 0: flag7 = 0
flag8 = 0: LOCATE 2, 65: PRINT TIME$: LOCATE 1, 65: PRINT DATE$
DIM z$(20, 2)
DIM z1$(20, 2): 'zone 1 is Basement data array all arrays are 20 rows
DIM z2$(20, 2): 'zone 2 is Shop data array 2 col
DIM z3$(20, 2): 'zone 3 is main floor data array
DIM z4$(20, 2): 'zone 4 is Guest apt data array
DIM z5$(20, 2): 'zone 5 is 2nd Flooe data array
DIM z6$(20, 2): 'zone 6 is Hot water data array
start:
t$ = TIME$
i$ = INKEY$
IF i$ = "e" THEN END
z4$(0, 1) = "00:00:00": z4$(0, 2) = "11:11:11"
'z4$(1, 1) = "22:22:22": z4$(1, 2) = "33:33:33"
'z4$(17, 1) = "44:44:44": z4$(17, 2) = "55:55:55"
'IF i$ = "a" THEN in2 = -1
'IF i$ = "b" THEN in2 = 0
LOCATE 2, 51: PRINT "in2=": LOCATE 2, 56: PRINT in2
LOCATE 1, 51: PRINT "in1=": LOCATE 1, 56: PRINT in1
LOCATE 1, 33: PRINT " e to exit pgm"
LOCATE 1, 1: PRINT "press v to view : "
LOCATE 1, 18: PRINT " p to print :"
IF i$ = "v" THEN GOSUB alldata
IF i$ = "p" THEN GOSUB printer
z1$(0, 0) = "Basement": z2$(0, 0) = "Shop": z3$(0, 0) = "main"
z4$(0, 0) = "Guest apt": z5$(0, 0) = "2nd Floor"
z6$(0, 0) = "hot water"
z$(0, 1) = "ON"
z$(0, 2) = "OFF"
z$(0, 0) = "ZONE"
OUT 634, 253: REM Selects zones 1-4'hardware multiplexer
in1 = ((INP(633) AND 8) = 8): in2 = ((INP(633) AND 16) = 16) 'lines 160 to
in3 = ((INP(633) AND 32) = 32): in4 = ((INP(633) AND 64) = 64) '200 test
OUT 634, 2: REM selects zones 5-8 'ea bit
in5 = ((INP(633) AND 8) = 8): in6 = ((INP(633) AND 16) = 16)
in7 = ((INP(633) AND 32) = 32): in8 = ((INP(633) AND 64) = 64)


IF in1 = -1 AND flag1 = 0 THEN 'tests for basement status
z1$(0, 1) = t$: flag1 = 1
ELSEIF in1 = 0 AND flag1 = 1 THEN
z1$(0, 2) = t$: flag1 = 2
ELSEIF in1 = -1 AND flag1 = 2 THEN
z1$(1, 1) = t$: flag1 = 3
ELSEIF in1 = 0 AND flag1 = 3 THEN
z1$(1, 2) = t$: flag1 = 4
ELSEIF in1 = -1 AND flag1 = 4 THEN
z1$(2, 1) = t$: flag1 = 5
ELSEIF in1 = 0 AND flag1 = 5 THEN
z1$(2, 2) = t$: flag1 = 6
END IF


IF in2 = -1 AND flag2 = 0 THEN 'tests for shop status
z2$(0, 1) = t$: flag2 = 1
ELSEIF in2 = 0 AND flag2 = 1 THEN
z2$(0, 2) = t$: flag2 = 2
ELSEIF in2 = -1 AND flag2 = 2 THEN
z2$(1, 1) = t$: flag2 = 3
ELSEIF in2 = 0 AND flag2 = 3 THEN
z2$(1, 2) = t$: flag2 = 4
ELSEIF in2 = -1 AND flag2 = 4 THEN
z2$(2, 1) = t$: flag2 = 5
ELSEIF in2 = 0 AND flag2 = 5 THEN
z2$(2, 2) = t$: flag2 = 6
ELSEIF in2 = -1 AND flag2 = 6 THEN
z2$(3, 1) = t$: flag2 = 7
ELSEIF in2 = 0 AND flag2 = 7 THEN
z2$(3, 2) = t$: flag2 = 8
ELSEIF in2 = -1 AND flag2 = 8 THEN
z2$(4, 1) = t$: flag2 = 9
ELSEIF in2 = 0 AND flag2 = 9 THEN
z2$(4, 2) = t$: flag2 = 10
ELSEIF in2 = -1 AND flag2 = 10 THEN
z2$(5, 1) = t$: flag2 = 11
ELSEIF in2 = 0 AND flag2 = 11 THEN
z2$(5, 2) = t$: flag2 = 12
ELSEIF in2 = -1 AND flag2 = 12 THEN
z2$(6, 1) = t$: flag2 = 13
ELSEIF in2 = 0 AND flag2 = 13 THEN
z2$(6, 2) = t$: flag2 = 14
ELSEIF in2 = -1 AND flag2 = 14 THEN
z2$(7, 1) = t$: flag2 = 15
ELSEIF in2 = 0 AND flag2 = 15 THEN
z2$(7, 2) = t$: flag2 = 16
ELSEIF in2 = -1 AND flag2 = 16 THEN
z2$(8, 1) = t$: flag2 = 17
ELSEIF in2 = 0 AND flag2 = 17 THEN
z2$(8, 2) = t$: flag2 = 18
ELSEIF in2 = -1 AND flag2 = 18 THEN
z2$(9, 1) = t$: flag2 = 19
ELSEIF in2 = 0 AND flag2 = 19 THEN
z2$(9, 2) = t$: flag2 = 20
ELSEIF in2 = -1 AND flag2 = 20 THEN
z2$(10, 1) = t$: flag2 = 21
ELSEIF in2 = 0 AND flag2 = 21 THEN
z2$(10, 2) = t$: flag2 = 22
ELSEIF in2 = -1 AND flag2 = 22 THEN
z2$(11, 1) = t$: flag2 = 23
ELSEIF in2 = 0 AND flag2 = 23 THEN
z2$(11, 2) = t$: flag2 = 24
ELSEIF in2 = -1 AND flag2 = 24 THEN
z2$(12, 1) = t$: flag2 = 25
ELSEIF in2 = 0 AND flag2 = 25 THEN
z2$(12, 2) = t$: flag2 = 26
ELSEIF in2 = -1 AND flag2 = 26 THEN
z2$(13, 1) = t$: flag2 = 27
ELSEIF in2 = 0 AND flag2 = 27 THEN
z2$(13, 2) = t$: flag2 = 28
ELSEIF in2 = -1 AND flag2 = 28 THEN
z2$(14, 1) = t$: flag2 = 29
ELSEIF in2 = 0 AND flag2 = 29 THEN
z2$(14, 2) = t$: flag2 = 30
ELSEIF in2 = -1 AND flag2 = 30 THEN
z2$(15, 1) = t$: flag2 = 31
ELSEIF in2 = 0 AND flag2 = 31 THEN
z2$(15, 2) = t$: flag2 = 32
ELSEIF in2 = -1 AND flag2 = 32 THEN
z2$(16, 1) = t$: flag2 = 33
ELSEIF in2 = 0 AND flag2 = 33 THEN
z2$(16, 2) = t$: flag2 = 34
ELSEIF in2 = -1 AND flag2 = 34 THEN
z2$(17, 1) = t$: flag2 = 35
ELSEIF in2 = 0 AND flag2 = 35 THEN
z2$(17, 2) = t$: flag2 = 36
ELSEIF in2 = -1 AND flag2 = 36 THEN
z2$(18, 1) = t$: flag2 = 37
ELSEIF in2 = 0 AND flag2 = 37 THEN
z2$(18, 2) = t$: flag2 = 38
ELSEIF in2 = -1 AND flag2 = 38 THEN
z2$(19, 1) = t$: flag2 = 39
ELSEIF in2 = 0 AND flag2 = 39 THEN
z2$(19, 2) = t$: flag2 = 40
END IF


IF in3 = -1 AND flag3 = 0 THEN 'tests for main status
z3$(0, 1) = t$: flag3 = 1
ELSEIF in3 = 0 AND flag3 = 1 THEN
z3$(0, 2) = t$: flag3 = 2
END IF

IF in4 = -1 AND flag4 = 0 THEN ' tests for apt status
z4$(0, 1) = t$: flag4 = 1
ELSEIF in4 = 0 AND flag4 = 1 THEN
z4$(0, 2) = t$: flag4 = 2
ELSEIF in4 = -1 AND flag4 = 2 THEN
z4$(1, 1) = t$: flag4 = 3
ELSEIF in4 = 0 AND flag4 = 3 THEN
z4$(1, 2) = t$: flag4 = 4
ELSEIF in4 = -1 AND flag4 = 4 THEN
z4$(2, 1) = t$: flag4 = 5
ELSEIF in4 = 0 AND flag4 = 5 THEN
z4$(2, 2) = t$: flag4 = 6
ELSEIF in4 = -1 AND flag4 = 6 THEN
z4$(3, 1) = t$: flag4 = 7
ELSEIF in4 = 0 AND flag4 = 7 THEN
z4$(3, 2) = t$: flag4 = 8
ELSEIF in4 = -1 AND flag4 = 8 THEN
z4$(4, 1) = t$: flag4 = 9
ELSEIF in4 = 0 AND flag4 = 9 THEN
z4$(4, 2) = t$: flag4 = 10
ELSEIF in4 = -1 AND flag4 = 10 THEN
z4$(5, 1) = t$: flag4 = 11
ELSEIF in4 = 0 AND flag4 = 11 THEN
z4$(5, 2) = t$: flag4 = 12
ELSEIF in4 = -1 AND flag4 = 12 THEN
z4$(6, 1) = t$: flag4 = 13
ELSEIF in4 = 0 AND flag4 = 13 THEN
z4$(6, 2) = t$: flag4 = 14
ELSEIF in4 = -1 AND flag4 = 14 THEN
z4$(7, 1) = t$: flag4 = 15
ELSEIF in4 = 0 AND flag4 = 15 THEN
z4$(7, 2) = t$: flag4 = 16
ELSEIF in4 = -1 AND flag4 = 16 THEN
z4$(8, 1) = t$: flag4 = 17
ELSEIF in4 = 0 AND flag4 = 17 THEN
z4$(8, 2) = t$: flag4 = 18
ELSEIF in4 = -1 AND flag4 = 18 THEN
z4$(9, 1) = t$: flag4 = 19
ELSEIF in4 = 0 AND flag4 = 19 THEN
z4$(9, 2) = t$: flag4 = 20
ELSEIF in4 = -1 AND flag4 = 20 THEN
z4$(10, 1) = t$: flag4 = 21
ELSEIF in4 = 0 AND flag4 = 21 THEN
z4$(10, 2) = t$: flag4 = 22
ELSEIF in4 = -1 AND flag4 = 22 THEN
z4$(11, 1) = t$: flag4 = 23
ELSEIF in4 = 0 AND flag4 = 23 THEN
z4$(11, 2) = t$: flag4 = 24
ELSEIF in4 = -1 AND flag4 = 24 THEN
z4$(12, 1) = t$: flag4 = 25
ELSEIF in4 = 0 AND flag4 = 25 THEN
z4$(12, 2) = t$: flag4 = 26
ELSEIF in4 = -1 AND flag4 = 26 THEN
z4$(13, 1) = t$: flag4 = 27
ELSEIF in4 = 0 AND flag4 = 27 THEN
z4$(13, 2) = t$: flag4 = 28
ELSEIF in4 = -1 AND flag4 = 28 THEN
z4$(14, 1) = t$: flag4 = 29
ELSEIF in4 = 0 AND flag4 = 29 THEN
z4$(14, 2) = t$: flag4 = 30
ELSEIF in4 = -1 AND flag4 = 30 THEN
z4$(15, 1) = t$: flag4 = 31
ELSEIF in4 = 0 AND flag4 = 31 THEN
z4$(15, 2) = t$: flag4 = 32
ELSEIF in4 = -1 AND flag4 = 32 THEN
z4$(16, 1) = "11:11:11": flag4 = 33
ELSEIF in4 = 0 AND flag4 = 33 THEN
z4$(16, 2) = "22:22:22": flag4 = 34
ELSEIF in4 = -1 AND flag4 = 34 THEN
z4$(17, 1) = t$: flag4 = 35
ELSEIF in4 = 0 AND flag4 = 35 THEN
z4$(17, 2) = t$: flag4 = 36
ELSEIF in4 = -1 AND flag4 = 36 THEN
z4$(18, 1) = t$: flag4 = 37
ELSEIF in4 = 0 AND flag4 = 37 THEN
z4$(18, 2) = t$: flag4 = 38
ELSEIF in4 = -1 AND flag4 = 38 THEN
z4$(19, 1) = t$: flag4 = 39
ELSEIF in4 = 0 AND flag4 = 39 THEN
z4$(19, 2) = t$: flag4 = 40

END IF

IF in5 = -1 AND flag5 = 0 THEN 'tests for 2nd floor status
z5$(0, 1) = t$: flag5 = 1
ELSEIF in5 = 0 AND flag5 = 1 THEN
z5$(0, 2) = t$: flag5 = 2
ELSEIF in5 = -1 AND flag5 = 2 THEN
z5$(1, 1) = t$: flag5 = 3
ELSEIF in5 = 0 AND flag5 = 3 THEN
z5$(1, 2) = t$: flag5 = 4
ELSEIF in5 = -1 AND flag5 = 4 THEN
z5$(2, 1) = t$: flag5 = 5
ELSEIF in5 = 0 AND flag5 = 5 THEN
z5$(2, 2) = t$: flag5 = 6
ELSEIF in5 = -1 AND flag5 = 6 THEN
z5$(3, 1) = t$: flag5 = 7
ELSEIF in5 = 0 AND flag5 = 7 THEN
z5$(3, 2) = t$: flag5 = 8
ELSEIF in5 = -1 AND flag5 = 8 THEN
z5$(4, 1) = t$: flag5 = 9
ELSEIF in5 = 0 AND flag5 = 9 THEN
z5$(4, 2) = t$: flag5 = 10
ELSEIF in5 = -1 AND flag5 = 10 THEN
z5$(5, 1) = t$: flag5 = 11
ELSEIF in5 = 0 AND flag5 = 11 THEN
z5$(5, 2) = t$: flag5 = 12
ELSEIF in5 = -1 AND flag5 = 12 THEN
z5$(6, 1) = t$: flag5 = 13
ELSEIF in5 = 0 AND flag5 = 13 THEN
z5$(6, 2) = t$: flag5 = 14
ELSEIF in5 = -1 AND flag5 = 14 THEN
z5$(7, 1) = t$: flag5 = 15
ELSEIF in5 = 0 AND flag5 = 15 THEN
z5$(7, 2) = t$: flag5 = 16
ELSEIF in5 = -1 AND flag5 = 16 THEN
z5$(8, 1) = t$: flag5 = 17
ELSEIF in5 = 0 AND flag5 = 17 THEN
z5$(8, 2) = t$: flag5 = 18
ELSEIF in5 = -1 AND flag5 = 18 THEN
z5$(9, 1) = t$: flag5 = 19
ELSEIF in5 = 0 AND flag5 = 19 THEN
z5$(9, 2) = t$: flag5 = 20
ELSEIF in5 = -1 AND flag5 = 20 THEN
z5$(10, 1) = t$: flag5 = 21
ELSEIF in5 = 0 AND flag5 = 21 THEN
z5$(10, 2) = t$: flag5 = 22
ELSEIF in5 = -1 AND flag5 = 22 THEN
z5$(11, 1) = t$: flag5 = 23
ELSEIF in5 = 0 AND flag5 = 23 THEN
z5$(11, 2) = t$: flag5 = 24
ELSEIF in5 = -1 AND flag5 = 24 THEN
z5$(12, 1) = t$: flag5 = 25
ELSEIF in5 = 0 AND flag5 = 25 THEN
z5$(12, 2) = t$: flag5 = 26
ELSEIF in5 = -1 AND flag5 = 26 THEN
z5$(13, 1) = t$: flag5 = 27
ELSEIF in5 = 0 AND flag5 = 27 THEN
z5$(13, 2) = t$: flag5 = 28
ELSEIF in5 = -1 AND flag5 = 28 THEN
z5$(14, 1) = t$: flag5 = 29
ELSEIF in5 = 0 AND flag5 = 29 THEN
z5$(14, 2) = t$: flag5 = 30
ELSEIF in5 = -1 AND flag5 = 30 THEN
z5$(15, 1) = t$: flag5 = 31
ELSEIF in5 = 0 AND flag5 = 31 THEN
z5$(15, 2) = t$: flag5 = 32
ELSEIF in5 = -1 AND flag5 = 32 THEN
z5$(16, 1) = t$: flag5 = 33
ELSEIF in5 = 0 AND flag5 = 33 THEN
z5$(16, 2) = t$: flag5 = 34
ELSEIF in5 = -1 AND flag5 = 34 THEN
z5$(17, 1) = t$: flag5 = 35
ELSEIF in5 = 0 AND flag5 = 35 THEN
z5$(17, 2) = t$: flag5 = 36
ELSEIF in5 = -1 AND flag5 = 36 THEN
z5$(18, 1) = t$: flag5 = 37
ELSEIF in5 = 0 AND flag5 = 37 THEN
z5$(18, 2) = t$: flag5 = 38
ELSEIF in5 = -1 AND flag5 = 38 THEN
z5$(19, 1) = t$: flag5 = 39
ELSEIF in5 = 0 AND flag5 = 39 THEN
z5$(19, 2) = t$: flag5 = 40
END IF

IF in6 = -1 AND flag6 = 0 THEN 'tests for hot water status
z6$(0, 1) = t$: flag6 = 1
ELSEIF in6 = 0 AND flag6 = 1 THEN
z6$(0, 2) = t$: flag6 = 2
END IF

PRINT z1$(1, 1): PRINT z1$(1, 2)
GOTO start

basementdata:
'LOCATE 4, 10: PRINT z1$(0, 0): 'subroutine 1000 Prints Basement data
'LOCATE 6, 8: PRINT z$(0, 1):
'LOCATE 6, 17: PRINT z$(0, 2):
'LOCATE 8, 5: PRINT z1$(0, 1)
'LOCATE 8, 15: PRINT z1$(0, 2)
'LOCATE 9, 5: PRINT z1$(1, 1)
'LOCATE 9, 15: PRINT z1$(1, 2)
'LOCATE 10, 5: PRINT z1$(2, 1)
'LOCATE 10, 15: PRINT z1$(2, 2)
RETURN

shopdata:
LOCATE 4, 30: PRINT z2$(0, 0) 'subroutine Prints Shop data
LOCATE 6, 28: PRINT z$(0, 1)
LOCATE 6, 37: PRINT z$(0, 2)
LOCATE 8, 25: PRINT z2$(0, 1)
LOCATE 8, 35: PRINT z2$(0, 2)
LOCATE 9, 25: PRINT z2$(1, 1)
LOCATE 9, 35: PRINT z2$(1, 2)
LOCATE 10, 25: PRINT z2$(2, 1)
LOCATE 10, 35: PRINT z2$(2, 2)
LOCATE 11, 25: PRINT z2$(3, 1)
LOCATE 11, 35: PRINT z2$(3, 2)
LOCATE 12, 25: PRINT z2$(4, 1)
LOCATE 12, 35: PRINT z2$(4, 2)
LOCATE 13, 25: PRINT z2$(5, 1)
LOCATE 13, 35: PRINT z2$(5, 2)
LOCATE 14, 25: PRINT z2$(6, 1)
LOCATE 14, 35: PRINT z2$(6, 2)
LOCATE 15, 25: PRINT z2$(7, 1)
LOCATE 15, 35: PRINT z2$(7, 2)
LOCATE 16, 25: PRINT z2$(8, 1)
LOCATE 16, 35: PRINT z2$(8, 2)
LOCATE 17, 25: PRINT z2$(9, 1)
LOCATE 17, 35: PRINT z2$(9, 2)
LOCATE 18, 25: PRINT z2$(10, 1)
LOCATE 18, 35: PRINT z2$(10, 2)
LOCATE 19, 25: PRINT z2$(11, 1)
LOCATE 19, 35: PRINT z2$(11, 2)
LOCATE 20, 25: PRINT z2$(12, 1)
LOCATE 20, 35: PRINT z2$(12, 2)
LOCATE 21, 25: PRINT z2$(13, 1)
LOCATE 21, 35: PRINT z2$(13, 2)
LOCATE 22, 25: PRINT z2$(14, 1)
LOCATE 22, 35: PRINT z2$(14, 2)
LOCATE 23, 25: PRINT z2$(15, 1)
LOCATE 23, 35: PRINT z2$(15, 2)
RETURN

maindata:
'LOCATE 4, 52: PRINT z3$(0, 0)'subroutine prints main data
'LOCATE 6, 48: PRINT z$(0, 1)
'LOCATE 6, 58: PRINT z$(0, 2)
'LOCATE 8, 46: PRINT z3$(0, 1)
'LOCATE 8, 56: PRINT z3$(0, 2)
RETURN

aptdata:
LOCATE 4, 10: PRINT z4$(0, 0)'subroutine prints Guest Apt data
LOCATE 6, 8: PRINT z$(0, 1)
LOCATE 6, 17: PRINT z$(0, 2)
LOCATE 8, 5: PRINT z4$(0, 1)
LOCATE 8, 15: PRINT z4$(0, 2)
LOCATE 9, 5: PRINT z4$(1, 1)
LOCATE 9, 15: PRINT z4$(1, 2)
LOCATE 10, 5: PRINT z4$(2, 1)
LOCATE 10, 15: PRINT z4$(2, 2)
LOCATE 11, 5: PRINT z4$(3, 1)
LOCATE 11, 15: PRINT z4$(3, 2)
LOCATE 12, 5: PRINT z4$(4, 1)
LOCATE 12, 15: PRINT z4$(4, 2)
LOCATE 13, 5: PRINT z4$(5, 1)
LOCATE 13, 15: PRINT z4$(5, 2)
LOCATE 14, 5: PRINT z4$(6, 1)
LOCATE 14, 15: PRINT z4$(6, 2)
LOCATE 15, 5: PRINT z4$(7, 1)
LOCATE 15, 15: PRINT z4$(7, 2)
LOCATE 16, 5: PRINT z4$(8, 1)
LOCATE 16, 15: PRINT z4$(8, 2)
LOCATE 17, 5: PRINT z4$(9, 1)
LOCATE 17, 15: PRINT z4$(9, 2)
LOCATE 18, 5: PRINT z4$(10, 1)
LOCATE 18, 15: PRINT z4$(10, 2)
LOCATE 19, 5: PRINT z4$(11, 1)
LOCATE 19, 15: PRINT z4$(11, 2)
LOCATE 20, 5: PRINT z4$(12, 1)
LOCATE 20, 15: PRINT z4$(12, 2)
LOCATE 21, 5: PRINT z4$(13, 1)
LOCATE 21, 15: PRINT z4$(13, 2)
LOCATE 22, 5: PRINT z4$(14, 1)
LOCATE 22, 15: PRINT z4$(14, 2)
LOCATE 23, 5: PRINT z4$(15, 1)
LOCATE 23, 15: PRINT z4$(15, 2)
RETURN

secondfldata:
LOCATE 4, 50: PRINT z5$(0, 0)'subroutine prints 2nd Floor data
LOCATE 6, 48: PRINT z$(0, 1)
LOCATE 6, 58: PRINT z$(0, 2)
LOCATE 8, 46: PRINT z5$(0, 1)
LOCATE 8, 56: PRINT z5$(0, 2)
LOCATE 9, 46: PRINT z5$(1, 1)
LOCATE 9, 56: PRINT z5$(1, 2)
LOCATE 10, 46: PRINT z5$(2, 1)
LOCATE 10, 56: PRINT z5$(2, 2)
LOCATE 11, 46: PRINT z5$(3, 1)
LOCATE 11, 56: PRINT z5$(3, 2)
LOCATE 12, 46: PRINT z5$(4, 1)
LOCATE 12, 56: PRINT z5$(4, 2)
LOCATE 13, 46: PRINT z5$(5, 1)
LOCATE 13, 56: PRINT z5$(5, 2)
LOCATE 14, 46: PRINT z5$(6, 1)
LOCATE 14, 56: PRINT z5$(6, 2)
LOCATE 15, 46: PRINT z5$(7, 1)
LOCATE 15, 56: PRINT z5$(7, 2)
LOCATE 16, 46: PRINT z5$(8, 1)
LOCATE 16, 56: PRINT z5$(8, 2)
LOCATE 17, 46: PRINT z5$(9, 1)
LOCATE 17, 56: PRINT z5$(9, 2)
LOCATE 18, 46: PRINT z5$(10, 1)
LOCATE 18, 56: PRINT z5$(10, 2)
LOCATE 19, 46: PRINT z5$(11, 1)
LOCATE 19, 56: PRINT z5$(11, 2)
LOCATE 20, 46: PRINT z5$(12, 1)
LOCATE 20, 56: PRINT z5$(12, 2)
LOCATE 21, 46: PRINT z5$(13, 1)
LOCATE 21, 56: PRINT z5$(13, 2)
LOCATE 22, 46: PRINT z5$(14, 1)
'LOCATE 22, 56: PRINT z5$(14, 2)

RETURN

hotwtrdata:
'LOCATE 14, 50: PRINT z6$(0, 0)'subroutine 6000 prints Hot Water data
'LOCATE 16, 48: PRINT z$(0, 1)
'LOCATE 16, 58: PRINT z$(0, 2)
'LOCATE 18, 46: PRINT z6$(0, 1)
'LOCATE 18, 56: PRINT z6$(0, 2)
RETURN


alldata:
GOSUB basementdata'subroutine prints all zones
GOSUB shopdata
GOSUB maindata
GOSUB aptdata
GOSUB secondfldata
'GOSUB hotwtrdata
RETURN


printer:
OPEN "lpt1" FOR OUTPUT AS 1
PRINT #1, TAB(4); z4$(0, 0);
PRINT #1, TAB(32); z2$(0, 0); TAB(53); z5$(0, 0)
PRINT #1, TAB(4); z$(0, 1); TAB(14); z$(0, 2);
PRINT #1, TAB(28); z$(0, 1); TAB(38); z$(0, 2); TAB(52); z$(0, 1);
GOSUB space1
PRINT #1, z$(0, 2)
PRINT #1, z4$(0, 1);
GOSUB space1 'spaces off time under apt
PRINT #1, z4$(0, 2);

PRINT #1, TAB(25); z2$(0, 1); TAB(35); z2$(0, 2); TAB(50); z5$(0, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(0, 2)
PRINT #1, z4$(1, 1);
GOSUB space1
PRINT #1, z4$(1, 2); TAB(25); z2$(1, 1); TAB(35); z2$(1, 2);
PRINT #1, CHR$(32); TAB(50); z5$(1, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(1, 2)
PRINT #1, z4$(2, 1);
GOSUB space1
PRINT #1, z4$(2, 2);
PRINT #1, TAB(25); z2$(2, 1); TAB(35); z2$(2, 2);
PRINT #1, TAB(50); z5$(2, 1); CHR$(32); CHR$(32); z5$(2, 2)
PRINT #1, z4$(3, 1);
GOSUB space1
PRINT #1, z4$(3, 2);
PRINT #1, TAB(25); z2$(3, 1); TAB(35); z2$(3, 2); TAB(50); z5$(3, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(3, 2)
PRINT #1, z4$(4, 1);
GOSUB space1
PRINT #1, z4$(4, 2);
PRINT #1, TAB(25); z2$(4, 1); TAB(35); z2$(4, 2); TAB(50); z5$(4, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(4, 2)
PRINT #1, z4$(5, 1);
GOSUB space1
PRINT #1, z4$(5, 2);
PRINT #1, TAB(25); z2$(5, 1); TAB(35); z2$(5, 2); TAB(50); z5$(5, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(5, 2)
PRINT #1, z4$(6, 1);
GOSUB space1
PRINT #1, z4$(6, 2);
PRINT #1, TAB(25); z2$(6, 1); TAB(35); z2$(6, 2); TAB(50); z5$(6, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(6, 2)
PRINT #1, z4$(7, 1);
GOSUB space1
PRINT #1, z4$(7, 2);
PRINT #1, TAB(25); z2$(7, 1); TAB(35); z2$(7, 2); TAB(50); z5$(7, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(7, 2)
PRINT #1, z4$(8, 1);
GOSUB space1
PRINT #1, z4$(8, 2);
PRINT #1, TAB(25); z2$(8, 1); TAB(35); z2$(8, 2); TAB(50); z5$(8, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(8, 2)
PRINT #1, z4$(9, 1);
GOSUB space1
PRINT #1, z4$(9, 2);
PRINT #1, TAB(25); z2$(9, 1); TAB(35); z2$(9, 2); TAB(50); z5$(9, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(9, 2)
PRINT #1, z4$(10, 1);
GOSUB space1
PRINT #1, z4$(10, 2);
PRINT #1, TAB(25); z2$(10, 1); TAB(35); z2$(10, 2); TAB(50); z5$(10, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(10, 2)
PRINT #1, z4$(11, 1);
GOSUB space1
PRINT #1, z4$(11, 2);
PRINT #1, TAB(25); z2$(11, 1); TAB(35); z2$(11, 2); TAB(50); z5$(11, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(11, 2)
PRINT #1, z4$(12, 1);
GOSUB space1
PRINT #1, z4$(12, 2);
PRINT #1, TAB(25); z2$(12, 1); TAB(35); z2$(12, 2); TAB(50); z5$(12, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(12, 2)
PRINT #1, z4$(13, 1);
GOSUB space1
PRINT #1, z4$(13, 2);
PRINT #1, TAB(25); z2$(13, 1); TAB(35); z2$(13, 2); TAB(50); z5$(13, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(13, 2)
PRINT #1, z4$(14, 1);
GOSUB space1
PRINT #1, z4$(14, 2);
PRINT #1, TAB(25); z2$(14, 1); TAB(35); z2$(14, 2); TAB(50); z5$(14, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(14, 2)
PRINT #1, z4$(15, 1);
GOSUB space1
PRINT #1, z4$(15, 2);
PRINT #1, TAB(25); z2$(15, 1); TAB(35); z2$(15, 2); TAB(50); z5$(15, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(15, 2)
PRINT #1, z4$(16, 1);
GOSUB space1
PRINT #1, z4$(16, 2);
PRINT #1, TAB(25); z2$(16, 1); TAB(35); z2$(16, 2); TAB(50); z5$(16, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(16, 2)
PRINT #1, z4$(17, 1);
GOSUB space1
PRINT #1, z4$(17, 2);
PRINT #1, TAB(25); z2$(17, 1); TAB(35); z2$(17, 2); TAB(50); z5$(17, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(17, 2)
PRINT #1, z4$(18, 1);
GOSUB space1
PRINT #1, z4$(18, 2);
PRINT #1, TAB(25); z2$(18, 1); TAB(35); z2$(18, 2); TAB(50); z5$(18, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(18, 2)
PRINT #1, z4$(19, 1);
GOSUB space1
PRINT #1, z4$(19, 2);
PRINT #1, TAB(25); z2$(19, 1); TAB(35); z2$(19, 2); TAB(50); z5$(19, 1);
PRINT #1, CHR$(32); CHR$(32); z5$(19, 2)
PRINT #1, CHR$(12);
CLOSE
RETURN

space1:
FOR n = 1 TO 6
PRINT #1, CHR$(32);
NEXT n
RETURN

space2:
FOR n = 1 TO 3
PRINT #1, CHR$(32);
NEXT n
'PRINT #1, z4$(0, 2);
RETURN








Posted on Jan 31, 2013, 9:38 AM

Respond to this message   

Return to Index


*******...

by Ben (no login)



    
This message has been edited by MCalkins on Jan 31, 2013 3:59 PM

Posted on Jan 31, 2013, 12:19 PM

Respond to this message   

Return to Index


not helpful

by Leon Schrecengost (no login)

Explain message

Posted on Jan 31, 2013, 1:34 PM

Respond to this message   

Return to Index


Re: not helpful

by (Login MCalkins)
Moderator

My impression is that the program is extremely complicated. I suspect that it is unnecessarily so. It would be much better to simplify the program.

I don't know, but I suspect Ben's comments were a reaction to the complexity of the program.

Regards,
Michael

Posted on Jan 31, 2013, 4:06 PM

Respond to this message   

Return to Index


* the program can be greatly simplified. I'm working on it...

by (Login MCalkins)
Moderator

Posted on Jan 31, 2013, 4:27 PM

Respond to this message   

Return to Index


*There's some hardware I/O in there. Is that for LPT3? What's it for?

by (Login MCalkins)
Moderator

Posted on Jan 31, 2013, 4:09 PM

Respond to this message   

Return to Index


hardware

by Leon Schrecengost (no login)

I think your are refering to the select bits 0-3 and 4-7. This is because the I/O card does not support bi-directional operation on the data lines. It may be that in testing I was useing LPT3 as a test source and any reference to it could be eliminated.
I've came a long way (thanks to you guys) from using line numbers.
Leon

Posted on Jan 31, 2013, 4:42 PM

Respond to this message   

Return to Index


Clarify

by Leon Schrecengost (no login)

Michael,Just wanted to be sure I gave you the proper info. I,m using LPT2 for my I/O and LPT1 for printing to the printer. I use DOS print and redirect LPT1 to the USB local printer.
Were you able to recreate my orginal problem?
Thanks for the help
Leon

Posted on Feb 1, 2013, 5:57 AM

Respond to this message   

Return to Index


Re: Clarify

by (Login MCalkins)
Moderator

I didn't actually run your original program. I didn't run it until most of the way through the revision.

I was going by:
http://en.wikipedia.org/wiki/Input/output_base_address

Regards,
Michael

Posted on Feb 1, 2013, 7:23 AM

Respond to this message   

Return to Index


Suggestions:

by Solitaire (no login)

Use SELECT CASE instead of all those IF THEN ELSEIFs.

If possible, instead of using 0 and -1 conditions, you might be able to use all the 0s together and separate the NOT 0 as ELSE or some other way, to simplify the code.

Posted on Jan 31, 2013, 6:58 PM

Respond to this message   

Return to Index


I might have gotten a bit overzealous... (5 edits)

by (Login MCalkins)
Moderator

I believe that this does basically the same thing, except for a few obvious changes.

I believe that it is far more maintainable, and, from my perspective, simpler.

Due to changes to the arrays, memory usage should be significantly lower.

Due to replacing the ELSEIFs with a more efficient construction, execution speed should be improved, and the source code is far more compact.

Regards,
Michael

'Program name is FURNMONx

CONST Basement = 0
CONST Shop = 1
CONST MainFloor = 2
CONST GuestApt = 3
CONST SecondFloor = 4
CONST HotWater = 5

CONST maxRoom = 5

DIM maxCounter(0 TO maxRoom) AS INTEGER ' consider making maxCounter a constant at 40 instead of an array.
maxCounter(Basement) = 6
maxCounter(Shop) = 40
maxCounter(MainFloor) = 2
maxCounter(GuestApt) = 40
maxCounter(SecondFloor) = 40
maxCounter(HotWater) = 2

DIM counter(0 TO maxRoom) AS INTEGER
DIM in(0 TO 7) AS INTEGER

DIM maxDisplay(0 TO maxRoom) AS INTEGER
DIM column(0 TO maxRoom) AS INTEGER
DIM tag(0 TO maxRoom) AS STRING

DIM s(0 TO maxRoom, 0 TO 39) AS STRING
DIM w AS INTEGER, x AS INTEGER, y AS INTEGER, z AS INTEGER
DIM t AS STRING, k AS STRING

tag(Basement) = "Basement"
tag(Shop) = "Shop"
tag(MainFloor) = "main"
tag(GuestApt) = "Guest apt"
tag(SecondFloor) = "2nd Floor"
tag(HotWater) = "hot water"

column(GuestApt) = 5
column(Shop) = 25
column(SecondFloor) = 46 '             second floor tag will be at 51 instead of 50

maxDisplay(Shop) = 31
maxDisplay(GuestApt) = 31
maxDisplay(SecondFloor) = 31 '         would have been 30 because LOCATE 22, 56: PRINT z5$(14, 2) was commented

CLS
VIEW PRINT '                           to improve behavior of 24th screen line.

DO
 LOCATE 2, 65: PRINT TIME$: LOCATE 1, 65: PRINT DATE$ '        moved inside loop
 t = TIME$

 '     s(GuestApt, 0) = "00:00:00": s(GuestApt, 1) = "11:11:11"
 '     s(GuestApt, 2) = "22:22:22": s(GuestApt, 3) = "33:33:33"
 '     s(GuestApt, 34) = "44:44:44": s(GuestApt, 35) = "55:55:55"
 '     IF k = "a" THEN in(MainFloor) = -1
 '     IF k = "b" THEN in(MainFloor) = 0
 '     LOCATE 2, 51: PRINT "in(MainFloor)=": LOCATE 2, 56: PRINT in(MainFloor)
 '     LOCATE 1, 51: PRINT "in(Shop)=": LOCATE 1, 56: PRINT in(Shop)
 LOCATE 1, 33: PRINT " e to exit pgm"
 '     LOCATE 1, 1: PRINT "press v to view : "
 LOCATE 1, 18: PRINT " p to print :"

 k = INKEY$
 SELECT CASE k
 CASE "e", CHR$(&H1B): END '   Esc is &h1b
 '     CASE "v": GOSUB alldata
 CASE "p": GOSUB printer
 CASE "0" TO "5" '             hard coded hack
  x = ASC(k) - &H30 '          convert from decimal. "0" is &h30.
  in(x) = in(x) XOR 2 ^ (3 + (3 AND x)) '       use key press to simulate state change
 END SELECT

 '     OUT &h27a, &hfd ' Selects zones 0-3'hardware multiplexer
 '     in(0) = INP(&h279) AND 8
 '     in(1) = INP(&h279) AND &h10 'lines 160 to
 '     in(2) = INP(&h279) AND &h20
 '     in(3) = INP(&h279) AND &h40 '200 test
 '     OUT &h27a, 2 ' selects zones 4-7 'ea bit
 '     in(4) = INP(&h279) AND 8
 '     in(5) = INP(&h279) AND &h10
 '     in(6) = INP(&h279) AND &h20
 '     in(7) = INP(&h279) AND &h40

 FOR x = 0 TO maxRoom '                        loop through rooms
  IF counter(x) < maxCounter(x) THEN '         not maxed out?
   IF 1 AND (counter(x) XOR 0 <> in(x)) THEN ' state change? (there is an XOR relationship between the even/odd-ness of the counter, and the truth/falsehood of the hardware input.)
    s(x, counter(x)) = t$ '                    record time
    counter(x) = counter(x) + 1 '              increment counter
   END IF
  ELSE
   '                                           maxed out...
  END IF
 NEXT

 '                                             special case... Note: counter has already been incremented.
 '     IF 0 <> in(GuestApt) AND counter(GuestApt) = 33 THEN
 '      s(GuestApt, 32) = "11:11:11"
 '     ELSEIF 0 = in(GuestApt) AND counter(GuestApt) = 34 THEN
 '      s(GuestApt, 33) = "22:22:22"
 '     END IF

 GOSUB alldata '               always displays. (perhaps the inside of the state change code could set a flag indicating a change, that would be cleared when the display is updated.)
 LOCATE 2, 1
 FOR x = 0 TO maxRoom
  PRINT LTRIM$(STR$(x)); ":"; LTRIM$(STR$(in(x))); ","; LTRIM$(STR$(counter(x))); SPACE$(3);
 NEXT
 PRINT

 '     PRINT s(Basement, 2): PRINT s(Basement, 3)
LOOP
END

alldata:
x = Shop: GOSUB Display
x = GuestApt: GOSUB Display
x = SecondFloor: GOSUB Display
RETURN

Display:
LOCATE 4, column(x) + 5: PRINT tag(x)
LOCATE 6, column(x) + 2: PRINT "ON"
LOCATE 6, column(x) + 12: PRINT "OFF"
FOR y = 0 TO maxDisplay(x) '           consider hardcoding 31 and getting rid of maxDisplay
 LOCATE 8 + y \ 2, column(x) + (10 AND 0 <> (1 AND y)): PRINT s(x, y); ' y;
NEXT
RETURN

printer:
'      OPEN "lpt1" FOR OUTPUT AS 1
OPEN "delme.txt" FOR OUTPUT AS 1 '             using delme.txt instead of lpt1
x = GuestApt
y = Shop
z = SecondFloor
PRINT #1, TAB(4); tag$(x); TAB(32); tag$(y); TAB(53); tag$(z)
PRINT #1, TAB(4); "ON"; TAB(14); "OFF"; TAB(28); "ON"; TAB(38); "OFF"; TAB(52); "ON"; SPACE$(6); "OFF"
FOR w = 0 TO 19
 PRINT #1, s(x, 2 * w); SPACE$(6); s(x, 2 * w + 1);
 PRINT #1, TAB(25); s(y, 2 * w); TAB(35); s(y, 2 * w + 1);
 PRINT #1, TAB(50); s(z, 2 * w); SPACE$(2); s(z, 2 * w + 1)
NEXT
PRINT #1, CHR$(12);
CLOSE
SHELL "notepad delme.txt"
RETURN



    
This message has been edited by MCalkins on Jan 31, 2013 10:34 PM
This message has been edited by MCalkins on Jan 31, 2013 9:34 PM
This message has been edited by MCalkins on Jan 31, 2013 9:30 PM
This message has been edited by MCalkins on Jan 31, 2013 9:25 PM
This message has been edited by MCalkins on Jan 31, 2013 9:05 PM

Posted on Jan 31, 2013, 9:02 PM

Respond to this message   

Return to Index


fixed a bug

by (Login MCalkins)
Moderator

in the 5th edit.

deleted this line:
x = x + 1 ' move on to the next room. (maintains ELSEIF behavior.)

I had put it in there during some confusion.

Regards,
Michael

Posted on Jan 31, 2013, 10:37 PM

Respond to this message   

Return to Index


Moving Pgm

by Leon Schrecengost (no login)

Having a problem getting program to USB memory.
I copy to word but when I try to open it on the other computer it's not compatable with the version of word I have. Any ideas? The other computer is not connected to the internet so I can't down load newer version of word.
Leon

Posted on Feb 1, 2013, 6:56 AM

Respond to this message   

Return to Index


*Save it an ASCII text file - that's all you need. Text files will be compatible anywhere.

by (Login qb432l)
R

*

Posted on Feb 1, 2013, 7:06 AM

Respond to this message   

Return to Index


Why Word?

by (Login MCalkins)
Moderator

It's plain text. Just use Notepad...

Copy from the forum, paste it into Notepad, and save it as a plain text file in ANSI encoding.

(I never create Word documents. If I need formatting, I use RTF or HTML/CSS. If I were to need anything fancier than that, I would probably go with something native to LibreOffice (like ODT) or AbiWord.)

As I commented out the hardware and printer stuff, you should be able to try the program on whichever computer you are using now. (it clobbers "delme.txt". Assuming "delme" is short for "delete me", I always assume that files of that name are safe to clobber.)

Don't rely on it on your real hardware until you have examined it and understand it. The loops and logic might take some time to understand, but once you do, I think that you'll find that small compact loops and a little bit of straightforward arithmetic/logic is a lot more manageable than a hundred hard-coded ELSEIFs and PRINTs.

Regards,
Michael



    
This message has been edited by MCalkins on Feb 1, 2013 7:20 AM

Posted on Feb 1, 2013, 7:16 AM

Respond to this message   

Return to Index


Tried to run

by Leon Schrecengost (no login)

I ran the new code. It does not know when to stop. When one of the inputs goes to "-1" incadating a zone has turned on it just keeps printing to screen until it is full. Does't wait for zone to turn off then print the off time and wait for next on cycle. Does this for all zones.
Leon

Posted on Feb 1, 2013, 9:30 AM

Respond to this message   

Return to Index


Re: Tried to run (3 edits)

by (Login MCalkins)
Moderator

Are you using the hardware, or the keyboard simulation? Did you change anything?

The code that I have posted (5th edit) does not do what you describe.

IF 1 AND (counter(x) XOR 0 <> in(x)) THEN

in(x) will be zero if the room is off, and non-zero if the room is on.

0<>in(x) tests whether the room is zero or non-zero. It evaluates to 0 if in(x) is 0, and to -1 (all bits 1) if in(x) is non-zero.

If counter(x) is odd (rightmost bit 1), then our state is showing that the room is on.
If counter(x) is even (rightmost bit 0), then our state is showing that the room is off.

counter(x) XOR 0 <> in(x)

performs the bit-wise XOR. (We are only interested in the right-most bit. The others are irrelevant, and will be masked out later.)

So, if we show that the room is off (counter(x) rightmost bit 0), but the room is actually on (in(x) non-zero), or:
if we show that the room is on (counter(x) rightmost bit 1), but the room is actually off (in(x) is 0), then we need to do something. Otherwise we do nothing. This is an XOR relationship (Because we do something only if one side or the other is true, not both, and not neither) between the rightmost bit of counter(x) and the zero/non-zero-ness of in(x).

1 AND (counter(x) XOR 0 <> in(x))

And here, we are selecting only the rightmost bit, masking out the irrelevant ones. This is effectively equivalent to:

1 AND counter(x) XOR 1 AND 0 <> in(x)

<> has the highest precedence, then AND, then XOR.

I prefer:
1 AND (counter(x) XOR 0 <> in(x))

IF 1 AND (counter(x) XOR 0 <> in(x)) THEN

IF...THEN tests the condition for zero/non-zero.

At a high level:

If we are showing that the room is off, but it is really on, we execute the block.
If we are showing that the room is on, but it is really off, we execute the block.
Otherwise, we do nothing.

Inside the block, we have:

s(x, counter(x)) = t$
counter(x) = counter(x) + 1

Which records the timestamp into the array, and increments the counter. Incrementing the counter toggles its even/oddness, its rightmost bit.

Regards,
Michael

In 3rd edit to this post, fixed a mistake in this post about the rightmost bit. I had gotten the even/odd backwards.



    
This message has been edited by MCalkins on Feb 1, 2013 11:56 AM
This message has been edited by MCalkins on Feb 1, 2013 11:52 AM
This message has been edited by MCalkins on Feb 1, 2013 11:50 AM

Posted on Feb 1, 2013, 11:50 AM

Respond to this message   

Return to Index


maxDisplay

by (Login MCalkins)
Moderator

I said:
consider hardcoding 31 and getting rid of maxDisplay
That should be:
consider making maxDisplay a constant at 31 instead of an array.

Regards,
Michael

Posted on Feb 1, 2013, 7:05 AM

Respond to this message   

Return to Index


slow learner

by Leon Schrecengost (no login)

Machael, I know you thought my code was complex but I understood it and could fix most problems. It did work except for the problem in z5$ above (21,1).(I still would like to know what that error was in the orginal code.
To change to a constant just rename it shop and drop the 31?
You're probably having a good laugh but this is all new to me. I haven't writen any programs since 1980's. Then it was just basic.
Leon

Posted on Feb 1, 2013, 11:59 AM

Respond to this message   

Return to Index


your original program... (added P.S.)

by (Login MCalkins)
Moderator

I think Pete and I both thought that you were having array subscript issues. Instead, it's a text scrolling issue.

First:

The screen is 80 columns by 25 rows. Normally, in QBASIC, you can print to rows 1 to 23 without a semicolon, and without scrolling. Printing to line 24 would require a semicolon to prevent scrolling, as would printing to line 25.

If you use VIEW PRINT, then you can print to 1 to 24 with no semicolon, with no scrolling. Printing to 25 still needs a semicolon to prevent scrolling.

By semicolon, I mean:

PRINT "something";

The semicolon at the end tells PRINT to keep the cursor on the same line.

Anyway...

The scrolling goes away, when you comment:

LOCATE 22, 46: PRINT z5$(14, 1)
LOCATE 22, 56: PRINT z5$(14, 2)

But that makes you wonder, why can the other two print to lines 22 and 23 with no problem?

secondfldata is not the problem. If you comment out the GOSUB secondfldata, you'll see that it still happens.

So, if the cursor gets left on line 22, we're okay, but if the cursor gets left on line 24, we're in trouble, but the problem is not happening in secondfldata.

So, ask yourself, what prints after secondfldata? It's the last one to get called in alldata. After alldata, the next thing to print is:

PRINT z1$(1, 1): PRINT z1$(1, 2)

right before the GOTO start.

As you can see, it prints 2 lines without semicolons. So, if you start on line 22, it prints to 22 and 23, and you don't have scrolling. But if you start from line 23 or 24, you're going to have scrolling. Comment that line, and the scrolling stops.

Regards,
Michael

QBASIC 1.1 gives you tools to find out what is happening when. It is an interpreter with good debugging capabilities. You can set breakpoints with F9, step through a program with F8, and check the output screen with F4, to see what is happening, and when it is happening.



    
This message has been edited by MCalkins on Feb 1, 2013 12:30 PM

Posted on Feb 1, 2013, 12:26 PM

Respond to this message   

Return to Index


Thanks

by Leon Schrecengost (no login)

Thanks to everyone for you EXTRIME patience with me. It's not easy to teach an old dog new code.
Leon

Posted on Feb 1, 2013, 1:35 PM

Respond to this message   

Return to Index


*you're welcome.

by (Login MCalkins)
Moderator

Posted on Feb 1, 2013, 1:56 PM

Respond to this message   

Return to Index


Re: slow learner

by (Login MCalkins)
Moderator

> I know you thought my code was complex


It was complex...

It used over 250 lines of hardcoded IF...ELSEIF blocks to accomplish what could easily be expressed in about 8 lines. (1 FOR/NEXT, and two IF...THEN blocks.).

It used over 100 lines of hardcoded display code to do what could be expressed in less than a dozen lines. (8 line subroutine + several lines of supporting code)

It used over 100 lines of hardcoded printer output code to do what could be expressed in about 15 lines.

It's a lot of typing, it's laborious, it's error-prone, it's inflexible. Especially in the case of the ELSEIFs, it's inefficient (unless the compiler gets really clever about optimization.) It is way too many conditional branches...

In terms of the array usage, there was probably about a third of each of the numbered z$ arrays that was not being used at all, and only 1/21th of the unnumbered z$ array was being used.


>but I understood it and could fix most problems.


It is certainly vital to be able to understand your own code. (You know that you're in trouble when you can't. (I've been there many times...))

However, that style of code is not very flexible or scalable. It you want to change something, you have to go change 100 lines, and hope that you don't make a typo somewhere. In your original, if you want to change the column location of the Second Floor data, you have to change 33 lines. In the revision, you have to change 1 line...

I highly recommend that you study the revised version, and try to understand it. Ask for help on the specific details if you have to. Sometimes, I'm not the best guy to explain things. Hopefully the others here will be able to help out also.

I did get a bit zealous. Some of the changes, for example, the switch to hex numbers, were not actually necessary. (However, you'll find that some things, like port addresses, are almost always expressed in hex. Might as well get used to it now. (I still resent the fact that the QBASIC Help ASCII chart wasn't in hex...)).

I think that the usage of the symbolic constant names was practical. Now, you don't have to remember that the Guest Apartment is in z4$ or s(3, ). you just can type: s(GuestApt, ). (Should you need to hard code it, for whatever reason... If you ever get into Windows programming, you'll find more symbolic constants than you can shake a stick at...)

For a while, I made the timestamp array a three dimension array: Something like (1 to 6, 0 to 20, 1 to 2). However, it seemed practical to combine the 2nd and third dimensions. They could have been kept separate, but I think that the code is slightly simpler with them together. For example, the Display routine can have:

FOR y = 0 TO maxDisplay(x)
LOCATE 8 + y \ 2, column(x) + (10 AND 0 <> (1 AND y)): PRINT s(x, y);
NEXT

instead of:

FOR y = 0 TO whatever
LOCATE 8 + y, column(x): PRINT s(x, y , 1);
LOCATE , column(x) + 10: PRINT s(x, y , 2);
NEXT

That's actually not so bad. It would have been worse if I had stuck to skipping the last "OFF" time for SecondFloor...

s(x, counter(x)) = t$

would have had to have been:

s(x, counter(x) \ 2, 1 AND counter(x)) = t$ ' if 0 based.
or:
s(x, counter(x) \ 2, 1 + (1 AND counter(x))) = t$ ' if 1 based.

(I forgot to remove the $ from t...)

I renamed z to s, because I wanted to use z as a normal variable in w,x,y,z... "s" standing for either String or timeStamp.


>To change to a constant just rename it shop and drop the 31?


DIM maxDisplay(0 TO maxRoom) AS INTEGER
maxDisplay(Shop) = 31
maxDisplay(GuestApt) = 31
maxDisplay(SecondFloor) = 31 ' would have been 30 because LOCATE 22, 56: PRINT z5$(14, 2) was commented

would become:

CONST maxDisplay = 31

and:

FOR y = 0 TO maxDisplay(x)

would become:

FOR y = 0 TO maxDisplay

Replacing the array with the constant potentially improves the efficiency of the program. Also, if you ever add a WIDTH statement to change the text dimensions, you would only have to change one line to take advantage of it.

Likewise:

DIM maxCounter(0 TO maxRoom) AS INTEGER
maxCounter(Basement) = 6
maxCounter(Shop) = 40
maxCounter(MainFloor) = 2
maxCounter(GuestApt) = 40
maxCounter(SecondFloor) = 40
maxCounter(HotWater) = 2
DIM s(0 TO maxRoom, 0 TO 39) AS STRING

could become;

CONST maxCounter = 40
DIM s(0 TO maxRoom, 0 TO maxCounter - 1) AS STRING

and:

IF counter(x) < maxCounter(x) THEN

would become:

IF counter(x) < maxCounter THEN

Again, with a potential efficiency improvement from using a constant instead of an array.


>You're probably having a good laugh


Well, I wasn't going to say so, but honestly, yes, I did laugh pretty hard last night.

That kind of programming style is like picking up a perfectly good bicycle, carrying it over your head, and jogging 5 miles on a highway while carrying it. Instead, you could get on the bicycle, and ride it the 5 miles much more easily. And then, you'll be more rested to ride another 10 miles...

The programming language is a tool. If you can put forth a little bit of effort to use it more effectively, you can save yourself a lot of unnecessary work. Computers are supposed to make our lives easier. It seems not ideal to program in a style that makes you work so hard for no reason. Programming languages offer what they do precisely to make that style of programming unnecessary.


So, whether a slow learner or a fast learner, we should all keep on learning. I hope that you do continue learning, and I hope you have an easier time in the future.

Regards,
Michael



    
This message has been edited by MCalkins on Feb 1, 2013 1:29 PM

Posted on Feb 1, 2013, 1:27 PM

Respond to this message   

Return to Index


LOL

by Leon Schrecengost (no login)

Thanks for the info and I'll try to put the bicycle down and ride for awhile.
Leon

Posted on Feb 1, 2013, 1:41 PM

Respond to this message   

Return to Index


:-)

by (Login MCalkins)
Moderator

One problem with symbolic constants in QBASIC is that it's too easy to misspell them... For example, GuestApt is 3, but GuestApartment would be implicitly 0...

One thing that I do is temporarily put

DEFSTR A-Z

at the top of the program, just to see if that catches any typos/misspellings or variables not explicitly DIMmed, etc...

Regards,
Michael

Posted on Feb 1, 2013, 1:55 PM

Respond to this message   

Return to Index


MC, what a novel idea. I wish I'd thought of it... no, really.

by (Login Kewbie)
R

It's not quite as good as OPTION EXPLICIT or DIM ALL, but certainly could help catch at least any misspelled numeric variable names.

Thanks for an excellent tip.

Kew

Posted on Feb 1, 2013, 6:32 PM

Respond to this message   

Return to Index


It's not perfect.

by (Login MCalkins)
Moderator

It doesn't catch everything, but it catches some things.

I didn't invent it. I know that Mac used it. I'm not sure, but I suspect that I got it from him.

Galleon has said that he will make the QB64 IDE give different color highlighting to wherever variables are defined (whether implicitly or explicitly), which will be a nice thing.

Regards,
Michael

Posted on Feb 1, 2013, 9:16 PM

Respond to this message   

Return to Index


*Even better would be to add something like 'OPTION EXPLICIT' or '#DIM ALL'

by (Login Kewbie)
R

Posted on Feb 6, 2013, 8:22 AM

Respond to this message   

Return to Index


*What exactly are you trying to do with this program?

by AlGoreIthm (no login)

Posted on Feb 8, 2013, 6:40 PM

Respond to this message   

Return to Index


Trapping User Input - but continue program if none enetered for nn seconds?

by B.Worth (no login)

Hello! May I ask how to code a program for the following situation? :

I'm running MS-DOS DOS 6.22 + Windows 3.11 in an actual DOS machine (486).

In one of the multiboot configuration is the Windows 3.11 menu, with the final command to run windows at the end of the autoexec.bat file.

What I want to do :

1. Display a message saying "Loading Windows 3.11. Press Esc to cancel..."
2. This message will wait for 3 seconds.
3. If the user DIDN'T press Esc, the program will proceed and run Windows.
4. If the user pressed Esc, it will cancel the command to load win.com.

Problem :

I do not know how to trap the Esc key (CHR$(27)) WITHOUT waiting for the user to input. If I use the INPUT function, the program waits infinitely till the user enters a key. I would like the program to proceed with the normal execution of running windows if the user didn't press anything after the 3 seconds.


How may I proceed with this?

Thanks for any help.

-B.Worth.

Posted on Jan 30, 2013, 7:40 PM

Respond to this message   

Return to Index


A simple QB code...

by Pete (Login The-Universe)
Admin

SLEEP 3
keyinput$ = INKEY$
IF keyinput$ = chr$(27) then
PRINT "ESC key was pressed!"
ELSE
PRINT "Starting Windows..."
END IF

-----------------------------

But it sounds like you want to be able to run a program on start up from the autoexec file. It's been several years since I have worked with .bat files, that might be a possibility; otherwise, if you did run a QB program at start up, from the bios, it would have to start Windows. It's been 20 years since I used Win 3.1, a bit too long to recall how to set that up. Maybe MC would have some further comments and suggestions.

Pete

Posted on Jan 30, 2013, 8:15 PM

Respond to this message   

Return to Index


Re: A simple QB code...

by B.Worth (no login)

Thanks, Pete!

That worked! (Somehow my previous codes didn't work properly. I think somehow I messed up the sequence.)

To begin Windows 3.11, the executable is "win.com" residing in Windows directory.

Is it possible to end QBASIC by the time Windows 3.11 is loaded? Will Qbasic take much memory if it "calls" Windows? Can Qbasic terminate itslef from memory when loading an external program like Windows?

Thanks.

Posted on Jan 31, 2013, 1:51 AM

Respond to this message   

Return to Index


Re: A simple QB code...

by Pete (Login The-Universe)
Admin

Find what directory win.com is in. If it is in the root, assuming that's the C drive, you don;t even need a directory name:

RUN Win.com

Put that where the "Esc key was pressed" line is.

Example if in a directory, like System

RUN "C:\SYSTEM\Win.com"

RUN will terminate QB and start the program it was instructed to run.

Please report back if this worls, as most of us have no way to test and confirm it.

Pete

Posted on Jan 31, 2013, 8:21 AM

Respond to this message   

Return to Index


Re: A simple QB code...

by (Login MCalkins)
Moderator

RUN is for running QBASIC programs, not executables. It does not terminate QBASIC. (This is QBASIC 1.1. QuickBASIC 4.5 compiled programs might be different.)

Regards,
Michael

Posted on Jan 31, 2013, 9:43 PM

Respond to this message   

Return to Index


Re: A simple QB code...

by (Login MCalkins)
Moderator

Why use QBASIC at all? If it's just a boot menu, you can do it from a batch file (autoexec.bat, probably).

You can use CHOICE from within a batch file to give a user choices, with a time out.

However, DOS offered direct support for boot menus. It's been years since I used it. (I had a boot menu on my last Windows 98SE computer to let me go into the DOS Mode...). See "Commands for Defining Multiple Configurations" in your DOS 6.22 Help file.

Regards,
Michael

Posted on Jan 31, 2013, 9:49 PM

Respond to this message   

Return to Index


QBASIC circa1981-1991

by (no login)

In 1991 purchased a Packard Bell PC loaded with V3.1 Windows & MS-DOS5. This package had QBasic, and I developed many programs for math and enginering applications i.e. time history and y=f(x) plots.

In mid 2000 purchased a Gateway Laptop PC with Windows Vista Home Premium. Loaded qBasic.exe and attempted to execute my programs with XXXXX.BAK or XXXXX.BAS file names. The programs are displayed on my monitor, can edit, etc. and the displayed text is ok. When I attempt to run, or print, get an error message that my printer is not connected to the the program. Would a qb64.exe solve this problem?

HELP!!

Thanks

Posted on Jan 27, 2013, 4:08 PM

Respond to this message   

Return to Index


Printing has changed in the past 10 years...

by Pete (Login The-Universe)
Admin

QB64 does its level best to emulate as much of the old QB printing ability as possible. A lot of us who stayed with QB through the years MS abandoned it had to SHELL our printing to Wordpad or Notepad. USB was never supported in QBasic, and most printers are USB now.

I would highly recommending downloading the latest SDL version of QB64 for Windows. The new GL version is neat, but it has a ways to go before I'd recommend it to a newbie.

Just be sure with the SDL version that you keep all your files in the QB64 folder. The dll files in that folder are needed to run your QB64 programs. You should just be able to copy your .bas and .bak files right into the new QB64 folder, and you will be good to go.

Latest SDL version is on this page:

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

Pete

Posted on Jan 27, 2013, 5:20 PM

Respond to this message   

Return to Index


Your interesting backlog of old QBAS progs

by (no login)

Like you I have so many progs writ in Basic from 1960s onwards

Microsoft in SP2 (their botch fix 2) changed things to prevent BAS progs running. I found a way around that - or you can use QB64 (more powerful and thus not so easy to find where you went wrong). Its sound, _SNDRAW, and image-transfer features are great.

My main interest is in APPLYING code (not writing clever code).
My posts on the qb64 forum are simulations of real world tasks to see and understand what is going on. For example simulating the sounds of musical instruments, and of dynamic interactive abstract art.

Email me some of your progs, or reply here so we can exchange ideas.

Posted on Feb 21, 2013, 3:32 AM

Respond to this message   

Return to Index


*Who maintains the Forum Community page at http://www.network54.com/Index/10167 ?

by (Login Kewbie)
R

Posted on Jan 26, 2013, 9:40 AM

Respond to this message   

Return to Index


*I'm guessing it's forum-owner Pete -- is it in need of maintainance?

by (Login qb432l)
R

*

Posted on Jan 26, 2013, 10:26 AM

Respond to this message   

Return to Index


* Pete.

by (Login MCalkins)
Moderator

Posted on Jan 26, 2013, 10:26 AM

Respond to this message   

Return to Index


I'd like to have...

by (Login Kewbie)
R

the chat info and link moved or copied somewhere near the top of the page. I've been (trying) to hang out there to (hopefully) say 'hi' to some of my long-time forum friends.

If the info is up where it could more likely be noticed, more people might check in when they see that someone else is there.

Just an idea.

Kew

P.S. MC and CG, sorry I keep missing you. I need to remember to indicate when I'm away from the computer for a bit, and keep forgetting to.

KN

Posted on Jan 26, 2013, 11:16 AM

Respond to this message   

Return to Index


Re: I'd like to have...

by (Login MCalkins)
Moderator

When I check the index, I usually give it a quick glance. I don't usually loot at every forum, but I usually check the ones that are likely to interest me, including the Community Cafe. I usually notice if someone is in the chatroom. I've been seeing you in there a number of times the last few days. I've gone in there twice, but you didn't respond. Other times, honestly, I wasn't in a chatting mood. (No offense.)

Regards,
Michael

Posted on Jan 26, 2013, 1:19 PM

Respond to this message   

Return to Index


* Loot?

by (Login burger2227)
R

happy.gif

Posted on Jan 29, 2013, 11:57 AM

Respond to this message   

Return to Index


* I meant "look"... :-P

by (Login MCalkins)
Moderator

Posted on Jan 29, 2013, 10:51 PM

Respond to this message   

Return to Index


I caught that, too...

by Pete (Login The-Universe)
Admin

But I decided not to comment on it, for fear he'd steal our javascript!

Pete happy.gif

- Quit looting at my forum Michael!

Posted on Jan 30, 2013, 12:11 PM

Respond to this message   

Return to Index


Chatroom

by Pete (Login The-Universe)
Admin

You are welcome to leave a message here, on the main board, that you are in the chatroom. Just reply "Gone" when you leave. That way, it will be seen and read form either page.

I don't think I've been in chat since Mac passed away.

Pete

Posted on Jan 26, 2013, 7:33 PM

Respond to this message   

Return to Index


*Thanks Pete. That should work just fine.

by (Login Kewbie)
R

Posted on Jan 26, 2013, 11:35 PM

Respond to this message   

Return to Index


* You were in there...

by (Login burger2227)
R

Posted on Jan 29, 2013, 11:58 AM

Respond to this message   

Return to Index


Hello and well met!

by (no login)

I was pleasantly surprised when I found QB64! I could not believe that someone had actually gotten a QuickBasic compiler to run on the Macintosh (let alone Windows). I just wanted to pop by and say hello and I hope things are going well for you in this endeavor.

One thing I noticed is that the compiled programs are put into the same directory where the compiler resides. Can I make a suggestion to make the IDE have a "Where do EXEs go?" option so this can be set. But it is just as easy to take the compiled program out of the main directory. So not a high priority kind of request. :-)

I really was going OMG!!! At work today. We use Macs at work (The University of Houston) and it just shocked me no end to actually see a compiler that works for QB! I about fell out of my chair. A couple of people asked me what I was staring at and I just had to show them. And small too! The compiled samples are all smaller than a megabyte in size! This really impressed me too. It is something like this that Linux needs to be able to create CDs that don't require something like Python to run scripts. Makes me wonder if this isn't the thing they were looking for when they settled on using Python.

Anyway - off to bed! It is 1:00am here and I have to get some sleep. Lots of meetings tomorrow and I have to be at least partially awake! :-) Congratulations again on a wonderful compiler. It is simple, fast, and works right out of the box! :-)

Mark

Posted on Jan 14, 2013, 10:16 PM

Respond to this message   

Return to Index


Executables reside in the QB64 directory because...

by (Login qb432l)
R

...there are certain files required for their execution. For example, if you create a zip file of an executable compiled in QB64, you must include these support files. The same would apply if you wanted to move an executable to a different directory. Of coure, your "which directory?" option could accommodate that, but you would end up with a lot of duplicate files scattered all over the place.

Anyway, Hello!
-Bob

Posted on Jan 15, 2013, 4:40 AM

Respond to this message   

Return to Index


Just out of curiosity, since I'm not a QB64 enthusiast,

by (Login Kewbie)
R

are you saying that QB64 requires some kind of runtime library? And if so, that it MUST reside in the same directory as the executable?

If that be the case, then "yuck". I hope they eventually correct it so only a single copy can reside in a known location.

Mostly I keep quiet about QB64, since I have no interest in it. I prefer to stick to PowerBASIC.

Kew, wearng asbestos suit to shield himself from Menno's flames :-D

Posted on Jan 15, 2013, 11:00 AM

Respond to this message   

Return to Index


Re: Just out of curiosity, since I'm not a QB64 enthusiast,

by (Login MCalkins)
Moderator

All Windows applications require Windows DLLs, such as kernel32.dll. These are usually in the System32 folder.

Additionally, the SDL version of QB64 requires a number of DLLs, the C++ Standard Library DLL, the SDL DLLs, and a few others.

The GL version of QB64 statically links to it's libraries, or includes them as source. The result is a larger, but more self contained executable that only depends on the Windows DLLs.

The DLLs don't have to be in the same folder. Windows searches in several places for them. However, it's probably better to keep them in the same folder to avoid DLL Hell, or else use a manifest, and load them from WinSxS.

Regards,
Michael

Posted on Jan 15, 2013, 12:34 PM

Respond to this message   

Return to Index


RE: Executables in main folder and dependent files

by Galleon (no login)

I agree, there should now be an option to set this path.

Originally, QB64 could not produce stand-alone executables and programs were dependent on DLLs or the 'common' folder, which would have meant recreating every DLL or common folder for every executable program.

Now, with QB64 GL, stand-alone executables are the norm so this is not a concern.

I should note that QB64 GL has not been released for MacOSX yet, but expect a release sometime within the next 2 weeks.

Posted on Jan 18, 2013, 1:15 PM

Respond to this message   

Return to Index


Qb vs turbo C

by (no login)

Hi,

After enjoying for a while my collection of calculators, a question rise up : For example, all casio machines feature a sort of Basic dialect, which however could not be compiled, i dunno why. So 100 times i read, Basic is not performant, assembler is faster, Turbo C, etc yes because all theses years, an interpreted language was compared to a compiled one (even is assembler isn't compiled, but C is). Now i wonder if C is really faster than Qb if both are compiled. Anyway i never programmed in C, also i don't have yet the cable to transfer anything to my calculators. Thanks, L

Posted on Jan 14, 2013, 1:55 PM

Respond to this message   

Return to Index


Re: Qb vs turbo C

by (Login MCalkins)
Moderator

Are you asking about your computer, or about your calculators? I have no knowledge of calculators.

As a matter of principle, a compiled program should be significantly faster than an interpreted program.

As to whether compiler X produces faster code than compiler Y, that depends very much on the compiler, and the compiler's options. How well does it optimize? What machine is it targeting? It depends also on the program. How well does the program express the intent of the programmer? The better the optimizing compiler understands what the program is actually supposed to do, and supposed not to do, the better it can optimize.

I would expect C to be generally a little faster than BASIC. The C and C++ languages are a little more expressive on certain things that can help optimization. That having been said, in many cases, I would expect that a good BASIC compiler could probably generate near equivalent code to a C compiler.

Without benchmarking the program, you won't know for sure.

Why Turbo C? There are more modern compilers...

GCC (in the form of mingw-w32, or perhaps djgpp)
Microsoft 32-bit C/C++ Optimizing Compiler (comes with Visual Studio Express)
Clang/LLVM
OpenWatcom
Intel C/C++ compiler (free for non-commercial use)

would probably all be worth considering.

Note that GCC and Microsoft do not optimize by default. You have to tell them to optimize, with -O3 (GCC) or /O2 (Microsoft).

I find that QB64 is many times faster than interpreted QBASIC 1.1 through NTVDM. And that's despite QB64 generating inefficient code.

Regards,
Michael

Posted on Jan 14, 2013, 2:39 PM

Respond to this message   

Return to Index


Why Turbo C ?

by (no login)

Ok thanks Micheal,

http://fr.wikipedia.org/wiki/Casio_Graph_100%2B

Compilateurs C/C++ pour Graph 100+

Les compilateurs les plus couramment utilisés sont Digital Mars et Turbo C

-> The most used compiler are Digital Mars and Turbo C...

BTW this machine has an 80286 compatible. I found where to buy the cable already:

http://www.util-pocket.com/casio/index.htm

Cheers, L



Posted on Jan 14, 2013, 3:38 PM

Respond to this message   

Return to Index


Interesting...

by (Login MCalkins)
Moderator

So, it's an Intel 286 compatible (16 bit), but it doesn't say what operating system... DOS? Or is it something else that Borland and Digital Mars just happen to support? The CRT and the executable image format will be specific to whatever operating system it uses.

Nevermind about using GCC or Microsoft. Those are 32 bit/64 bit compilers. You need a 16 bit compiler.

OpenWatcom and Borland Turbo C have 16 bit compilers.

Nasm would support it, if you could figure out what image format and libraries to use.

Why use a 286 calculator at all? Surely your computer is much, much more powerful...

Regards,
Michael

Posted on Jan 14, 2013, 5:18 PM

Respond to this message   

Return to Index


Subscript out of range

by Leon Schrecengost (no login)

I have a program with 6 arrays dimisioned as dim 20,2. They work fine 0,0 and 0,1 thru 10,0 and 10,1. When I try to put data in to 11,0 I get the subscript error. The data I'm trying to store is time$. I use the program to monitor furnace zone on/off times. I would like to post the pgm so you could take a look at it. I have it saved to a usb drive. The computer I use for the pgm is not connected to the internet. How can I post the code?
Leon

Posted on Jan 12, 2013, 5:24 PM

Respond to this message   

Return to Index


Save the program to a text file using Notepad.

by Solitaire (no login)

Start Notepad on your computer and select All Files instead of Text Documents.
Navigate to the folder containing your QB program code and open it.
Save it to a text file on your USB drive.
You can then copy and paste it to the forum.

Posted on Jan 12, 2013, 5:47 PM

Respond to this message   

Return to Index


Save the program in QB4.5 as text readable in Save As

by (Login burger2227)
R

Make sure the code is text before closing the BAS file and open it with Notepad. Then you can copy and paste here. Indentation will be lost on this forum.

If you can't open a BAS file with Notepad, add it to your Open with right click menu. Make sure the Always box is not checked after you select it.

Posted on Jan 12, 2013, 6:30 PM

Respond to this message   

Return to Index


posting code

by Leon Schrecengost (no login)

I have the code in a txt file. I copy it but it doesn't want to paste into this site. Do I have to post it to a different site rather than use the respond to your message?
Leon

Posted on Jan 13, 2013, 11:36 AM

Respond to this message   

Return to Index


*Make sure you've copied it, then just click Edit/Paste with the cursor in 'Message Text'.

by (Login qb432l)
R

*

Posted on Jan 13, 2013, 5:59 PM

Respond to this message   

Return to Index


Posting code

by Leon Schrecengost (no login)

I hate to be so naive but where is the screen with message text selection. I,ve been trying to put the code on the respond to your message line.
I have the text pgm in my document file and can copy it. When I return to the qbasic screen paste is not highlited.
Leon

Posted on Jan 14, 2013, 6:38 AM

Respond to this message   

Return to Index


Strange...

by (Login qb432l)
R

When you click "Respond to this message", you should see four input boxes: Your Name, Your Email, Message Title, and Message Text. Click in the Message Text box and then click Edit/Paste. Shouldn't be a problem (at least, it never has been before). When you reponded to my message, didn't you get a "Message Text" box in which you typed your response? That's where you paste the code.

-Bob

Posted on Jan 14, 2013, 11:02 AM

Respond to this message   

Return to Index


posting code

by Leon Schrecengost (no login)

CLS : 'Program name is FURNMON4
flag1 = 0: flag2 = 0: flag3 = 0: flag4 = 0: flag5 = 0: flag6 = 0: flag7 = 0
flag8 = 0: LOCATE 2, 65: PRINT TIME$: LOCATE 1, 65: PRINT DATE$
DIM zone1$(20, 2): 'zone 1 is Basement data array all arrays are 20 rows
DIM zone2%(20, 2): 'zone 2 is Shop data array 2 col
DIM zone3$(20, 2): 'zone 3 is main floor data array
DIM zone4$(20, 2): 'zone 4 is Guest apt data array
DIM zone5$(20, 2): 'zone 5 is 2nd Flooe data array
DIM zone6$(20, 2): 'zone 6 is Hot water data array
start:
t$ = TIME$
i$ = INKEY$
IF i$ = "e" THEN END
LOCATE 2, 51: PRINT "in2=": LOCATE 2, 56: PRINT in2
LOCATE 1, 51: PRINT "in1=": LOCATE 1, 56: PRINT in1
z1$ = zone1$: 'Basement"
z2 = zone2%: '"Shop"
z3$ = zone3$: '"Main"
z4$ = zone4$: '"Guest Apt"
z5$ = zone5$: '"2nd Floor"
z6$ = zone6$: '"Hot Water"
'p1$ = Z$(0, 1): p2$ = Z$(0, 2): p3$ = Z$(0, 0)
LOCATE 1, 33: PRINT " e to exit pgm"
LOCATE 1, 1: PRINT "press v to view : "
LOCATE 1, 18: PRINT " p to print :"
IF i$ = "v" THEN GOSUB alldata
IF i$ = "p" THEN GOSUB printer
IF i$ = "s" THEN GOSUB allshop
IF i$ = "a" THEN GOSUB allapt
z1$(0, 0) = "Basement": z2$(0, 0) = "Shop": z3$(0, 0) = "main"
z4$(0, 0) = "Guest apt": z5$(0, 0) = "2nd Floor"
z6$(0, 0) = "hot water"
Z$(0, 1) = "ON"
Z$(0, 2) = "OFF"
Z$(0, 0) = "ZONE"
OUT 634, 253: REM Selects zones 1-4'hardware multiplexer
in1 = ((INP(633) AND 8) = 8): in2 = ((INP(633) AND 16) = 16) 'lines 160 to
in3 = ((INP(633) AND 32) = 32): in4 = ((INP(633) AND 64) = 64) '200 test
OUT 634, 2: REM selects zones 5-8 'ea bit
in5 = ((INP(633) AND 8) = 8): in6 = ((INP(633) AND 16) = 16)
in7 = ((INP(633) AND 32) = 32): in8 = ((INP(633) AND 64) = 64)


IF in1 = -1 AND flag1 = 0 THEN 'tests for basement status
z1$(0, 1) = t$: flag1 = 1
ELSEIF in1 = 0 AND flag1 = 1 THEN
z1$(0, 2) = t$: flag1 = 2
ELSEIF in1 = -1 AND flag1 = 2 THEN
z1$(1, 1) = t$: flag1 = 3
ELSEIF in1 = 0 AND flag1 = 3 THEN
z1$(1, 2) = t$: flag1 = 4
ELSEIF in1 = -1 AND flag1 = 4 THEN
z1$(2, 1) = t$: flag1 = 5
ELSEIF in1 = 0 AND flag1 = 5 THEN
z1$(2, 2) = t$: flag1 = 6
END IF


IF in2 = -1 AND flag2 = 0 THEN 'tests for shop status
z2$(0, 1) = t$: flag2 = 1
ELSEIF in2 = 0 AND flag2 = 1 THEN
z2$(0, 2) = t$: flag2 = 2
ELSEIF in2 = -1 AND flag2 = 2 THEN
z2$(1, 1) = t$: flag2 = 3
ELSEIF in2 = 0 AND flag2 = 3 THEN
z2$(1, 2) = t$: flag2 = 4
ELSEIF in2 = -1 AND flag2 = 4 THEN
z2$(2, 1) = t$: flag2 = 5
ELSEIF in2 = 0 AND flag2 = 5 THEN
z2$(2, 2) = t$: flag2 = 6
ELSEIF in2 = -1 AND flag2 = 6 THEN
z2$(3, 1) = t$: flag2 = 7
ELSEIF in2 = 0 AND flag2 = 7 THEN
z2$(3, 2) = t$: flag2 = 8
ELSEIF in2 = -1 AND flag2 = 8 THEN
z2$(4, 1) = t$: flag2 = 9
ELSEIF in2 = 0 AND flag2 = 9 THEN
z2$(4, 2) = t$: flag2 = 10
ELSEIF in2 = -1 AND flag2 = 10 THEN
z2$(5, 1) = t$: flag2 = 11
ELSEIF in2 = 0 AND flag2 = 11 THEN
z2$(5, 2) = t$: flag2 = 12
ELSEIF in2 = -1 AND flag2 = 12 THEN
z2$(6, 1) = t$: flag2 = 13
ELSEIF in2 = 0 AND flag2 = 13 THEN
z2$(6, 2) = t$: flag2 = 14
ELSEIF in2 = -1 AND flag2 = 14 THEN
z2$(7, 1) = t$: flag2 = 15
ELSEIF in2 = 0 AND flag2 = 15 THEN
z2$(7, 2) = t$: flag2 = 16
ELSEIF in2 = -1 AND flag2 = 16 THEN
z2$(8, 1) = t$: flag2 = 17
ELSEIF in2 = 0 AND flag2 = 17 THEN
z2$(8, 2) = t$: flag2 = 18
ELSEIF in2 = -1 AND flag2 = 18 THEN
z2$(9, 1) = t$: flag2 = 19
ELSEIF in2 = 0 AND flag2 = 19 THEN
z2$(9, 2) = t$: flag2 = 20
ELSEIF in2 = -1 AND flag2 = 20 THEN
z2$(10, 1) = t$: flag2 = 21
ELSEIF in2 = 0 AND flag2 = 21 THEN
z2$(10, 2) = t$: flag2 = 22
ELSEIF in2 = -1 AND flag2 = 22 THEN
z2$(11, 1) = t$: flag2 = 23
ELSEIF in2 = 0 AND flag2 = 23 THEN
z2$(11, 2) = t$: flag2 = 24
END IF


IF in3 = -1 AND flag3 = 0 THEN 'tests for main status
z3$(0, 1) = t$: flag3 = 1
ELSEIF in3 = 0 AND flag3 = 1 THEN
z3$(0, 2) = t$: flag3 = 2
END IF

IF in4 = -1 AND flag4 = 0 THEN ' tests for apt status
z4$(0, 1) = t$: flag4 = 1
ELSEIF in4 = 0 AND flag4 = 1 THEN
z4$(0, 2) = t$: flag4 = 2
ELSEIF in4 = -1 AND flag4 = 2 THEN
z4$(1, 1) = t$: flag4 = 3
ELSEIF in4 = 0 AND flag4 = 3 THEN
z4$(1, 2) = t$: flag4 = 4
ELSEIF in4 = -1 AND flag4 = 4 THEN
z4$(2, 1) = t$: flag4 = 5
ELSEIF in4 = 0 AND flag4 = 5 THEN
z4$(2, 2) = t$: flag4 = 6
ELSEIF in4 = -1 AND flag4 = 6 THEN
z4$(3, 1) = t$: flag4 = 7
ELSEIF in4 = 0 AND flag4 = 7 THEN
z4$(3, 2) = t$: flag4 = 8
ELSEIF in4 = -1 AND flag4 = 8 THEN
z4$(4, 1) = t$: flad4 = 9
ELSEIF in4 = 0 AND flag4 = 9 THEN
z4$(4, 2) = t$: flag4 = 10
ELSEIF in4 = -1 AND flag4 = 10 THEN
z4$(5, 1) = t$: flag4 = 11
ELSEIF in4 = 0 AND flag4 = 11 THEN
z4$(5, 2) = t$: flaf4 = 12
ELSEIF in4 = -1 AND flag4 = 12 THEN
z4$(6, 1) = t$: flag4 = 13
ELSEIF in4 = 0 AND flag4 = 13 THEN
z4$(6, 2) = t$: flag4 = 14
END IF

IF in5 = -1 AND flag5 = 0 THEN 'tests for 2nd floor status
z5$(0, 1) = t$: flag5 = 1
ELSEIF in5 = 0 AND flag5 = 1 THEN
z5$(0, 2) = t$: flag5 = 2
END IF

IF in6 = -1 AND flag6 = 0 THEN 'tests for hot water status
z6$(0, 1) = t$: flag6 = 1
ELSEIF in6 = 0 AND flag6 = 1 THEN
z6$(0, 2) = t$: flag6 = 2
END IF

PRINT z1$(1, 1): PRINT z1$(1, 2)
GOTO start

basementdata:
LOCATE 4, 10: PRINT z1$(0, 0): 'subroutine 1000 Prints Basement data
LOCATE 6, 8: PRINT Z$(0, 1):
LOCATE 6, 17: PRINT Z$(0, 2):
LOCATE 8, 5: PRINT z1$(0, 1)
LOCATE 8, 15: PRINT z1$(0, 2)
LOCATE 9, 5: PRINT z1$(1, 1)
LOCATE 9, 15: PRINT z1$(1, 2)
LOCATE 10, 5: PRINT z1$(2, 1)
LOCATE 10, 15: PRINT z1$(2, 2)
RETURN

shopdata:
LOCATE 4, 30: PRINT z2$(0, 0) 'subroutine 2000 Prints Shop data
LOCATE 6, 28: PRINT Z$(0, 1)
LOCATE 6, 37: PRINT Z$(0, 2)
LOCATE 8, 25: PRINT z2$(0, 1)
LOCATE 8, 35: PRINT z2$(0, 2)
LOCATE 9, 25: PRINT z2$(1, 1)
LOCATE 9, 35: PRINT z2$(1, 2)
LOCATE 10, 25: PRINT z2$(2, 1)
LOCATE 10, 35: PRINT z2$(2, 2)
LOCATE 11, 25: PRINT z2$(3, 1)
LOCATE 11, 35: PRINT z2$(3, 2)
LOCATE 12, 25: PRINT z2$(4, 1)
LOCATE 12, 35: PRINT z2$(4, 2)
LOCATE 13, 25: PRINT z2$(5, 1)
LOCATE 13, 35: PRINT z2$(5, 2)
RETURN

maindata:
LOCATE 4, 52: PRINT z3$(0, 0)'subroutine 3000 prints main data
LOCATE 6, 48: PRINT Z$(0, 1)
LOCATE 6, 58: PRINT Z$(0, 2)
LOCATE 8, 46: PRINT z3$(0, 1)
LOCATE 8, 56: PRINT z3$(0, 2)
RETURN

aptdata:
LOCATE 14, 11: PRINT z4$(0, 0)'subroutine 4000 prints Guest Apt data
LOCATE 16, 8: PRINT Z$(0, 1)
LOCATE 16, 17: PRINT Z$(0, 2)
LOCATE 18, 5: PRINT z4$(0, 1)
LOCATE 18, 15: PRINT z4$(0, 2)
LOCATE 19, 5: PRINT z4$(1, 1)
LOCATE 19, 15: PRINT z4$(1, 2)
LOCATE 20, 5: PRINT z4$(2, 1)
LOCATE 20, 15: PRINT z4$(2, 2)
LOCATE 21, 5: PRINT z4$(3, 1)
LOCATE 21, 15: PRINT z4$(3, 2)
LOCATE '22, 5: PRINT z4$(4, 1)
LOCATE '22, 15: PRINT z4(4, 2)
LOCATE '23, 5: PRINT z4$(5, 1)
LOCATE '23, 15: PRINT z4$(5, 2)
LOCATE '24, 5: PRINT z4$(6, 1)
LOCATE '24, 15: PRINT z4$(6, 2)
RETURN

secondfldata:
LOCATE 14, 30: PRINT z5$(0, 0)'subroutine 5000 prints 2nd Floor data
LOCATE 16, 28: PRINT Z$(0, 1)
LOCATE 16, 37: PRINT Z$(0, 2)
LOCATE 18, 25: PRINT z5$(0, 1)
LOCATE 18, 35: PRINT z5$(0, 2)
RETURN

hotwtrdata:
LOCATE 14, 50: PRINT z6$(0, 0)'subroutine 6000 prints Hot Water data
LOCATE 16, 48: PRINT Z$(0, 1)
LOCATE 16, 58: PRINT Z$(0, 2)
LOCATE 18, 46: PRINT z6$(0, 1)
LOCATE 18, 56: PRINT z6$(0, 2)
RETURN


alldata:
GOSUB basementdata'subroutine 7000 prints all zones
GOSUB shopdata
GOSUB maindata
GOSUB aptdata
GOSUB secondfldata
GOSUB hotwtrdata
RETURN

allshop:
LOCATE 3, 62: PRINT z2$(0, 1)
LOCATE 3, 72: PRINT z2$(0, 2)
LOCATE 4, 62: PRINT z2$(1, 1)
LOCATE 4, 72: PRINT z2$(1, 2)
LOCATE 5, 62: PRINT z2$(2, 1)
LOCATE 5, 72: PRINT z2$(2, 2)
LOCATE 6, 62: PRINT z2$(3, 1)
LOCATE 6, 72: PRINT z2$(3, 2)
LOCATE 7, 62: PRINT z2$(4, 1)
LOCATE 7, 72: PRINT z2$(4, 2)
LOCATE 8, 62: PRINT z2$(5, 1)
LOCATE 8, 72: PRINT z2$(5, 2)
LOCATE 9, 62: PRINT z2$(6, 1)
LOCATE 9, 72: PRINT z2$(6, 2)
LOCATE 10, 62: PRINT z2$(7, 1)
LOCATE 10, 72: PRINT z2$(7, 2)
LOCATE 11, 62: PRINT z2$(8, 1)
LOCATE 11, 72: PRINT z2$(8, 2)
LOCATE 12, 62: PRINT z2$(9, 1)
LOCATE 12, 72: PRINT z2$(9, 2)
LOCATE 13, 62: PRINT z2$(10, 1)
LOCATE 13, 72: PRINT z2$(10, 2)
'LOCATE 14, 62: PRINT z2$(11, 1)
'LOCATE 14, 72: PRINT z2$(11, 2)
RETURN


printer:
OPEN "lpt1" FOR OUTPUT AS 1
PRINT #1, TAB(7); z1$(0, 0);
PRINT #1, TAB(40); z2$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, z1$(0, 1); , z1$(0, 2);
PRINT #1, TAB(33); z2$(0, 1); TAB(49); z2$(0, 2)
PRINT #1, z1$(1, 1), z1$(1, 2);
PRINT #1, TAB(33); z2$(1, 1); TAB(49); z2$(1, 2)
PRINT #1, z1$(2, 1), z1$(2, 2)
PRINT #1, CHR$(10), CHR$(10), CHR$(10), CHR$(10), CHR$(10)
PRINT #1, TAB(7); z3$(0, 0)
PRINT #1, TAB(40); z4$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, z3$(0, 1), z3$(0, 2);
PRINT #1, TAB(33); z4$(0, 1); TAB(49); z4$(0, 2)
PRINT #1, z3$(1, 1), z3$(1, 2)
PRINT #1, CHR$(10), CHR$(10), CHR$(10), CHR$(10), CHR$(10)
PRINT #1, TAB(7); z5$(0, 0)
PRINT #1, TAB(40); z5$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, CHR$(12);
CLOSE
RETURN

allapt:
LOCATE 3, 62: PRINT z4$(0, 1)
LOCATE 3, 72: PRINT z4$(0, 2)
RETURN







flag1 = 0: flag2 = 0: flag3 = 0: flag4 = 0: flag5 = 0: flag6 = 0: flag7 = 0
flag8 = 0: LOCATE 2, 65: PRINT TIME$: LOCATE 1, 65: PRINT DATE$
DIM zone1$(20, 2): 'zone 1 is Basement data array all arrays are 20 rows
DIM zone2%(20, 2): 'zone 2 is Shop data array 2 col
DIM zone3$(20, 2): 'zone 3 is main floor data array
DIM zone4$(20, 2): 'zone 4 is Guest apt data array
DIM zone5$(20, 2): 'zone 5 is 2nd Flooe data array
DIM zone6$(20, 2): 'zone 6 is Hot water data array
start:
t$ = TIME$
i$ = INKEY$
IF i$ = "e" THEN END
LOCATE 2, 51: PRINT "in2=": LOCATE 2, 56: PRINT in2
LOCATE 1, 51: PRINT "in1=": LOCATE 1, 56: PRINT in1
z1$ = zone1$: 'Basement"
z2 = zone2%: '"Shop"
z3$ = zone3$: '"Main"
z4$ = zone4$: '"Guest Apt"
z5$ = zone5$: '"2nd Floor"
z6$ = zone6$: '"Hot Water"
'p1$ = Z$(0, 1): p2$ = Z$(0, 2): p3$ = Z$(0, 0)
LOCATE 1, 33: PRINT " e to exit pgm"
LOCATE 1, 1: PRINT "press v to view : "
LOCATE 1, 18: PRINT " p to print :"
IF i$ = "v" THEN GOSUB alldata
IF i$ = "p" THEN GOSUB printer
IF i$ = "s" THEN GOSUB allshop
IF i$ = "a" THEN GOSUB allapt
z1$(0, 0) = "Basement": z2$(0, 0) = "Shop": z3$(0, 0) = "main"
z4$(0, 0) = "Guest apt": z5$(0, 0) = "2nd Floor"
z6$(0, 0) = "hot water"
Z$(0, 1) = "ON"
Z$(0, 2) = "OFF"
Z$(0, 0) = "ZONE"
OUT 634, 253: REM Selects zones 1-4'hardware multiplexer
in1 = ((INP(633) AND 8) = 8): in2 = ((INP(633) AND 16) = 16) 'lines 160 to
in3 = ((INP(633) AND 32) = 32): in4 = ((INP(633) AND 64) = 64) '200 test
OUT 634, 2: REM selects zones 5-8 'ea bit
in5 = ((INP(633) AND 8) = 8): in6 = ((INP(633) AND 16) = 16)
in7 = ((INP(633) AND 32) = 32): in8 = ((INP(633) AND 64) = 64)


IF in1 = -1 AND flag1 = 0 THEN 'tests for basement status
z1$(0, 1) = t$: flag1 = 1
ELSEIF in1 = 0 AND flag1 = 1 THEN
z1$(0, 2) = t$: flag1 = 2
ELSEIF in1 = -1 AND flag1 = 2 THEN
z1$(1, 1) = t$: flag1 = 3
ELSEIF in1 = 0 AND flag1 = 3 THEN
z1$(1, 2) = t$: flag1 = 4
ELSEIF in1 = -1 AND flag1 = 4 THEN
z1$(2, 1) = t$: flag1 = 5
ELSEIF in1 = 0 AND flag1 = 5 THEN
z1$(2, 2) = t$: flag1 = 6
END IF


IF in2 = -1 AND flag2 = 0 THEN 'tests for shop status
z2$(0, 1) = t$: flag2 = 1
ELSEIF in2 = 0 AND flag2 = 1 THEN
z2$(0, 2) = t$: flag2 = 2
ELSEIF in2 = -1 AND flag2 = 2 THEN
z2$(1, 1) = t$: flag2 = 3
ELSEIF in2 = 0 AND flag2 = 3 THEN
z2$(1, 2) = t$: flag2 = 4
ELSEIF in2 = -1 AND flag2 = 4 THEN
z2$(2, 1) = t$: flag2 = 5
ELSEIF in2 = 0 AND flag2 = 5 THEN
z2$(2, 2) = t$: flag2 = 6
ELSEIF in2 = -1 AND flag2 = 6 THEN
z2$(3, 1) = t$: flag2 = 7
ELSEIF in2 = 0 AND flag2 = 7 THEN
z2$(3, 2) = t$: flag2 = 8
ELSEIF in2 = -1 AND flag2 = 8 THEN
z2$(4, 1) = t$: flag2 = 9
ELSEIF in2 = 0 AND flag2 = 9 THEN
z2$(4, 2) = t$: flag2 = 10
ELSEIF in2 = -1 AND flag2 = 10 THEN
z2$(5, 1) = t$: flag2 = 11
ELSEIF in2 = 0 AND flag2 = 11 THEN
z2$(5, 2) = t$: flag2 = 12
ELSEIF in2 = -1 AND flag2 = 12 THEN
z2$(6, 1) = t$: flag2 = 13
ELSEIF in2 = 0 AND flag2 = 13 THEN
z2$(6, 2) = t$: flag2 = 14
ELSEIF in2 = -1 AND flag2 = 14 THEN
z2$(7, 1) = t$: flag2 = 15
ELSEIF in2 = 0 AND flag2 = 15 THEN
z2$(7, 2) = t$: flag2 = 16
ELSEIF in2 = -1 AND flag2 = 16 THEN
z2$(8, 1) = t$: flag2 = 17
ELSEIF in2 = 0 AND flag2 = 17 THEN
z2$(8, 2) = t$: flag2 = 18
ELSEIF in2 = -1 AND flag2 = 18 THEN
z2$(9, 1) = t$: flag2 = 19
ELSEIF in2 = 0 AND flag2 = 19 THEN
z2$(9, 2) = t$: flag2 = 20
ELSEIF in2 = -1 AND flag2 = 20 THEN
z2$(10, 1) = t$: flag2 = 21
ELSEIF in2 = 0 AND flag2 = 21 THEN
z2$(10, 2) = t$: flag2 = 22
ELSEIF in2 = -1 AND flag2 = 22 THEN
z2$(11, 1) = t$: flag2 = 23
ELSEIF in2 = 0 AND flag2 = 23 THEN
z2$(11, 2) = t$: flag2 = 24
END IF


IF in3 = -1 AND flag3 = 0 THEN 'tests for main status
z3$(0, 1) = t$: flag3 = 1
ELSEIF in3 = 0 AND flag3 = 1 THEN
z3$(0, 2) = t$: flag3 = 2
END IF

IF in4 = -1 AND flag4 = 0 THEN ' tests for apt status
z4$(0, 1) = t$: flag4 = 1
ELSEIF in4 = 0 AND flag4 = 1 THEN
z4$(0, 2) = t$: flag4 = 2
ELSEIF in4 = -1 AND flag4 = 2 THEN
z4$(1, 1) = t$: flag4 = 3
ELSEIF in4 = 0 AND flag4 = 3 THEN
z4$(1, 2) = t$: flag4 = 4
ELSEIF in4 = -1 AND flag4 = 4 THEN
z4$(2, 1) = t$: flag4 = 5
ELSEIF in4 = 0 AND flag4 = 5 THEN
z4$(2, 2) = t$: flag4 = 6
ELSEIF in4 = -1 AND flag4 = 6 THEN
z4$(3, 1) = t$: flag4 = 7
ELSEIF in4 = 0 AND flag4 = 7 THEN
z4$(3, 2) = t$: flag4 = 8
ELSEIF in4 = -1 AND flag4 = 8 THEN
z4$(4, 1) = t$: flad4 = 9
ELSEIF in4 = 0 AND flag4 = 9 THEN
z4$(4, 2) = t$: flag4 = 10
ELSEIF in4 = -1 AND flag4 = 10 THEN
z4$(5, 1) = t$: flag4 = 11
ELSEIF in4 = 0 AND flag4 = 11 THEN
z4$(5, 2) = t$: flaf4 = 12
ELSEIF in4 = -1 AND flag4 = 12 THEN
z4$(6, 1) = t$: flag4 = 13
ELSEIF in4 = 0 AND flag4 = 13 THEN
z4$(6, 2) = t$: flag4 = 14
END IF

IF in5 = -1 AND flag5 = 0 THEN 'tests for 2nd floor status
z5$(0, 1) = t$: flag5 = 1
ELSEIF in5 = 0 AND flag5 = 1 THEN
z5$(0, 2) = t$: flag5 = 2
END IF

IF in6 = -1 AND flag6 = 0 THEN 'tests for hot water status
z6$(0, 1) = t$: flag6 = 1
ELSEIF in6 = 0 AND flag6 = 1 THEN
z6$(0, 2) = t$: flag6 = 2
END IF

PRINT z1$(1, 1): PRINT z1$(1, 2)
GOTO start

basementdata:
LOCATE 4, 10: PRINT z1$(0, 0): 'subroutine 1000 Prints Basement data
LOCATE 6, 8: PRINT Z$(0, 1):
LOCATE 6, 17: PRINT Z$(0, 2):
LOCATE 8, 5: PRINT z1$(0, 1)
LOCATE 8, 15: PRINT z1$(0, 2)
LOCATE 9, 5: PRINT z1$(1, 1)
LOCATE 9, 15: PRINT z1$(1, 2)
LOCATE 10, 5: PRINT z1$(2, 1)
LOCATE 10, 15: PRINT z1$(2, 2)
RETURN

shopdata:
LOCATE 4, 30: PRINT z2$(0, 0) 'subroutine 2000 Prints Shop data
LOCATE 6, 28: PRINT Z$(0, 1)
LOCATE 6, 37: PRINT Z$(0, 2)
LOCATE 8, 25: PRINT z2$(0, 1)
LOCATE 8, 35: PRINT z2$(0, 2)
LOCATE 9, 25: PRINT z2$(1, 1)
LOCATE 9, 35: PRINT z2$(1, 2)
LOCATE 10, 25: PRINT z2$(2, 1)
LOCATE 10, 35: PRINT z2$(2, 2)
LOCATE 11, 25: PRINT z2$(3, 1)
LOCATE 11, 35: PRINT z2$(3, 2)
LOCATE 12, 25: PRINT z2$(4, 1)
LOCATE 12, 35: PRINT z2$(4, 2)
LOCATE 13, 25: PRINT z2$(5, 1)
LOCATE 13, 35: PRINT z2$(5, 2)
RETURN

maindata:
LOCATE 4, 52: PRINT z3$(0, 0)'subroutine 3000 prints main data
LOCATE 6, 48: PRINT Z$(0, 1)
LOCATE 6, 58: PRINT Z$(0, 2)
LOCATE 8, 46: PRINT z3$(0, 1)
LOCATE 8, 56: PRINT z3$(0, 2)
RETURN

aptdata:
LOCATE 14, 11: PRINT z4$(0, 0)'subroutine 4000 prints Guest Apt data
LOCATE 16, 8: PRINT Z$(0, 1)
LOCATE 16, 17: PRINT Z$(0, 2)
LOCATE 18, 5: PRINT z4$(0, 1)
LOCATE 18, 15: PRINT z4$(0, 2)
LOCATE 19, 5: PRINT z4$(1, 1)
LOCATE 19, 15: PRINT z4$(1, 2)
LOCATE 20, 5: PRINT z4$(2, 1)
LOCATE 20, 15: PRINT z4$(2, 2)
LOCATE 21, 5: PRINT z4$(3, 1)
LOCATE 21, 15: PRINT z4$(3, 2)
LOCATE '22, 5: PRINT z4$(4, 1)
LOCATE '22, 15: PRINT z4(4, 2)
LOCATE '23, 5: PRINT z4$(5, 1)
LOCATE '23, 15: PRINT z4$(5, 2)
LOCATE '24, 5: PRINT z4$(6, 1)
LOCATE '24, 15: PRINT z4$(6, 2)
RETURN

secondfldata:
LOCATE 14, 30: PRINT z5$(0, 0)'subroutine 5000 prints 2nd Floor data
LOCATE 16, 28: PRINT Z$(0, 1)
LOCATE 16, 37: PRINT Z$(0, 2)
LOCATE 18, 25: PRINT z5$(0, 1)
LOCATE 18, 35: PRINT z5$(0, 2)
RETURN

hotwtrdata:
LOCATE 14, 50: PRINT z6$(0, 0)'subroutine 6000 prints Hot Water data
LOCATE 16, 48: PRINT Z$(0, 1)
LOCATE 16, 58: PRINT Z$(0, 2)
LOCATE 18, 46: PRINT z6$(0, 1)
LOCATE 18, 56: PRINT z6$(0, 2)
RETURN


alldata:
GOSUB basementdata'subroutine 7000 prints all zones
GOSUB shopdata
GOSUB maindata
GOSUB aptdata
GOSUB secondfldata
GOSUB hotwtrdata
RETURN

allshop:
LOCATE 3, 62: PRINT z2$(0, 1)
LOCATE 3, 72: PRINT z2$(0, 2)
LOCATE 4, 62: PRINT z2$(1, 1)
LOCATE 4, 72: PRINT z2$(1, 2)
LOCATE 5, 62: PRINT z2$(2, 1)
LOCATE 5, 72: PRINT z2$(2, 2)
LOCATE 6, 62: PRINT z2$(3, 1)
LOCATE 6, 72: PRINT z2$(3, 2)
LOCATE 7, 62: PRINT z2$(4, 1)
LOCATE 7, 72: PRINT z2$(4, 2)
LOCATE 8, 62: PRINT z2$(5, 1)
LOCATE 8, 72: PRINT z2$(5, 2)
LOCATE 9, 62: PRINT z2$(6, 1)
LOCATE 9, 72: PRINT z2$(6, 2)
LOCATE 10, 62: PRINT z2$(7, 1)
LOCATE 10, 72: PRINT z2$(7, 2)
LOCATE 11, 62: PRINT z2$(8, 1)
LOCATE 11, 72: PRINT z2$(8, 2)
LOCATE 12, 62: PRINT z2$(9, 1)
LOCATE 12, 72: PRINT z2$(9, 2)
LOCATE 13, 62: PRINT z2$(10, 1)
LOCATE 13, 72: PRINT z2$(10, 2)
'LOCATE 14, 62: PRINT z2$(11, 1)
'LOCATE 14, 72: PRINT z2$(11, 2)
RETURN


printer:
OPEN "lpt1" FOR OUTPUT AS 1
PRINT #1, TAB(7); z1$(0, 0);
PRINT #1, TAB(40); z2$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, z1$(0, 1); , z1$(0, 2);
PRINT #1, TAB(33); z2$(0, 1); TAB(49); z2$(0, 2)
PRINT #1, z1$(1, 1), z1$(1, 2);
PRINT #1, TAB(33); z2$(1, 1); TAB(49); z2$(1, 2)
PRINT #1, z1$(2, 1), z1$(2, 2)
PRINT #1, CHR$(10), CHR$(10), CHR$(10), CHR$(10), CHR$(10)
PRINT #1, TAB(7); z3$(0, 0)
PRINT #1, TAB(40); z4$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, z3$(0, 1), z3$(0, 2);
PRINT #1, TAB(33); z4$(0, 1); TAB(49); z4$(0, 2)
PRINT #1, z3$(1, 1), z3$(1, 2)
PRINT #1, CHR$(10), CHR$(10), CHR$(10), CHR$(10), CHR$(10)
PRINT #1, TAB(7); z5$(0, 0)
PRINT #1, TAB(40); z5$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, CHR$(12);
CLOSE
RETURN

allapt:
LOCATE 3, 62: PRINT z4$(0, 1)
LOCATE 3, 72: PRINT z4$(0, 2)
RETURN

I had to highlite the code before doing the copy.
I'm trying to access the zone2 array and that's where I'm haveing the subscript error when I try to use 11,0 or 11,1.
Don't laugh to much at my code. It works for me.
Leon






Posted on Jan 14, 2013, 4:31 PM

Respond to this message   

Return to Index


You've DIM'd it as zone2$(), but are accessing it as z2$() ...(more)...

by (Login qb432l)
R

The reason the (11, 1) generates an error, is that arrays of up to 10 elements are automatically DIM'd. Therefore, z2$() was acceptable until you tried to access the 11th element.

-Bob



    
This message has been edited by qb432l on Jan 14, 2013 6:12 PM

Posted on Jan 14, 2013, 6:08 PM

Respond to this message   

Return to Index


Good catch, Bob.

by (Login Kewbie)
R

It's been a long time since I've used QB. Does it support anything like

OPTION EXPLICIT

or

#DIM ALL

?

This kind of thing wouldn't happen in a language that requires declaration of all variables.

Kew

Posted on Jan 14, 2013, 10:35 PM

Respond to this message   

Return to Index


Not that I've heard of, Q...

by (Login qb432l)
R

I personally think that it's a flaw in QBasic that you can use an array that has not been DIM'd, in that these types of errors can happen - it invites sloppy programming. Non-array variables aren't likely to cause as much trouble (at least I've never had a problem) but you'll notice that disciplined programmers (e.g. Solitaire) always DIM their variables and hence know exactly what they're dealing with at all times.

-Bob

Posted on Jan 15, 2013, 4:08 AM

Respond to this message   

Return to Index


Sorry, Bob, I can't agree with you about

by (Login Kewbie)
R

DIMming variables letting programmers know exactly what they're working with, at least in a language that doesn't FORCE explicit declaration. I couldn't tell you HOW many times I've accidentally done this:

DIM aLongVariableName AS LONG

aLongVaraibleName = 15

... blah

IF aLongVariableName = 15 THEN ... bleh

Hmmmmm... 'bleh' SHOULD happen here, but it doesn't. #*&@(*^# it all. I'm gonna go take a nap. sad.gif

Kew



    
This message has been edited by Kewbie on Jan 15, 2013 10:49 AM

Posted on Jan 15, 2013, 10:48 AM

Respond to this message   

Return to Index


Spelling mistakes notwithstanding...

by (Login qb432l)
R

I'm not sure what you disagreed with. Except for arrays, I don't DIM anything. As a rule, variable names like x and y I only use for nested graphics loops which establish the variable value within the loop -- I would never casually use "x" as a variable name because I was lazy. Variable names I create say what they're for, such as NumROCKETS, so I don't get confused (once again, spelling mistakes aside).

I do, however, respect programmers like Solitaire who put lock washers on every bolt and tighten every nut. It seems to me that they would have less confusion or debugging problems in the long run.

-Bob

Posted on Jan 15, 2013, 3:24 PM

Respond to this message   

Return to Index


I know I'm probably belaboring this to the point of tedium, but...

by (Login Kewbie)
R

OK, so my example wasn't an array. All I'm saying is that DIMming an array won't keep you from mistyping it somewhere in your program, and a language that requires ALL variables, scalar or array or whatever, to be declared will refuse to compile or run it if an attempt is made to use an undeclared variable or array.

QBASIC doesn't offer this capability, and when as bad a typist as myself uses it, those kinds of mistakes are guaranteed.

The first thing I do in any perl code I write is enter 'use strict'. In VB, 'OPTION EXPLICIT', and in PB, 'DIM ALL'. To the best of my knowledge, c and FORTH never allow undeclared variables to be used.

As to variable naming, I'm of two minds. I HATE typing long variable names, but I equally hate cryptic code.

Anyway, I'm sorry to make too much of this, I just wanted to make sure I was getting my point across.

Kew

Posted on Jan 15, 2013, 8:34 PM

Respond to this message   

Return to Index


*Hey, I hear you (and better understand your misspelling example).

by (Login qb432l)
R

*

Posted on Jan 16, 2013, 1:25 AM

Respond to this message   

Return to Index


out range

by Leon Schrecengost (no login)

Bob, That was an error in the code I posted. I tried to change it from zone2$ to zone% to see if it made any difference. The code I'm running is zone2$.

Are you saying that an array can only be 10 rows? So when I use dim 20,2 it defaults to 10,2.Or is there another way to diminsion the arry to do what I need?
Leon

Posted on Jan 15, 2013, 7:14 AM

Respond to this message   

Return to Index


No Leon...

by (Login qb432l)
R

What I'm saying is that arrays you haven't DIM'd, can only have 10 elements. Arrays you've DIM'd can have any number up to available memory. In your case, you have the statement:

z2$(11, 1) = t$

The problem is, you didn't DIM an array called z2$, hence the error when you tried to access element 11. Up to that point, QBasic thought you were just creating an array on the fly, so to speak, named z2$(), so didn't call you on it till you exceeded the 10 element limit of non-DIM'd arrays.

-Bob

Posted on Jan 15, 2013, 3:32 PM

Respond to this message   

Return to Index


Not sure

by Leon Schrecengost (no login)

Bob, I understand if the array was not dim that I would get and error. When I dim the array zone2$(20,2) I still get the subscript out of range error. Do you have the ability to run the pgm. You would have to be able to input data to the paralel port to check it. If you don't have this capability I will try and modify the pgm to allow you to use keyboard input to test it.
Leon

Posted on Jan 15, 2013, 4:10 PM

Respond to this message   

Return to Index


*Try this: DIM z2$(20, 1) - Maybe it'll be clearer what's happening.

by (Login qb432l)
R

*

Posted on Jan 15, 2013, 4:26 PM

Respond to this message   

Return to Index


New Code

by Leon Schrecengost (no login)

Bob, I put a change in the pgm to allow it to be run without external hardware. If you togle between a and b on the keboard it acts like in2 is being switched on and off. Use the s to view array data. You have to hit s to keep updating the data displayed. I tried it and got the subscript error.

CLS : 'Program name is FURNMON4
flag1 = 0: flag2 = 0: flag3 = 0: flag4 = 0: flag5 = 0: flag6 = 0: flag7 = 0
flag8 = 0: LOCATE 2, 65: PRINT TIME$: LOCATE 1, 65: PRINT DATE$
DIM zone1$(20, 2): 'zone 1 is Basement data array all arrays are 20 rows
DIM zone2%(20, 2): 'zone 2 is Shop data array 2 col
DIM zone3$(20, 2): 'zone 3 is main floor data array
DIM zone4$(20, 2): 'zone 4 is Guest apt data array
DIM zone5$(20, 2): 'zone 5 is 2nd Flooe data array
DIM zone6$(20, 2): 'zone 6 is Hot water data array
start:
t$ = TIME$
i$ = INKEY$
IF i$ = "e" THEN END
IF i$ = "a" THEN in2 = -1
IF i$ = "b" THEN in2 = 0
LOCATE 2, 51: PRINT "in2=": LOCATE 2, 56: PRINT in2
LOCATE 1, 51: PRINT "in1=": LOCATE 1, 56: PRINT in1
z1$ = zone1$: 'Basement"
z2$ = zone2$: '"Shop"
z3$ = zone3$: '"Main"
z4$ = zone4$: '"Guest Apt"
z5$ = zone5$: '"2nd Floor"
z6$ = zone6$: '"Hot Water"
'p1$ = Z$(0, 1): p2$ = Z$(0, 2): p3$ = Z$(0, 0)
LOCATE 1, 33: PRINT " e to exit pgm"
LOCATE 1, 1: PRINT "press v to view : "
LOCATE 1, 18: PRINT " p to print :"
IF i$ = "v" THEN GOSUB alldata
IF i$ = "p" THEN GOSUB printer
IF i$ = "s" THEN GOSUB allshop
IF i$ = "a" THEN GOSUB allapt
z1$(0, 0) = "Basement": z2$(0, 0) = "Shop": z3$(0, 0) = "main"
z4$(0, 0) = "Guest apt": z5$(0, 0) = "2nd Floor"
z6$(0, 0) = "hot water"
Z$(0, 1) = "ON"
Z$(0, 2) = "OFF"
Z$(0, 0) = "ZONE"
OUT 634, 253: REM Selects zones 1-4'hardware multiplexer
in1 = ((INP(633) AND 8) = 8): ' in2 = ((INP(633) AND 16) = 16) 'lines 160 to
in3 = ((INP(633) AND 32) = 32): in4 = ((INP(633) AND 64) = 64) '200 test
OUT 634, 2: REM selects zones 5-8 'ea bit
in5 = ((INP(633) AND 8) = 8): in6 = ((INP(633) AND 16) = 16)
in7 = ((INP(633) AND 32) = 32): in8 = ((INP(633) AND 64) = 64)


IF in1 = -1 AND flag1 = 0 THEN 'tests for basement status
z1$(0, 1) = t$: flag1 = 1
ELSEIF in1 = 0 AND flag1 = 1 THEN
z1$(0, 2) = t$: flag1 = 2
ELSEIF in1 = -1 AND flag1 = 2 THEN
z1$(1, 1) = t$: flag1 = 3
ELSEIF in1 = 0 AND flag1 = 3 THEN
z1$(1, 2) = t$: flag1 = 4
ELSEIF in1 = -1 AND flag1 = 4 THEN
z1$(2, 1) = t$: flag1 = 5
ELSEIF in1 = 0 AND flag1 = 5 THEN
z1$(2, 2) = t$: flag1 = 6
END IF


IF in2 = -1 AND flag2 = 0 THEN 'tests for shop status
z2$(0, 1) = t$: flag2 = 1
ELSEIF in2 = 0 AND flag2 = 1 THEN
z2$(0, 2) = t$: flag2 = 2
ELSEIF in2 = -1 AND flag2 = 2 THEN
z2$(1, 1) = t$: flag2 = 3
ELSEIF in2 = 0 AND flag2 = 3 THEN
z2$(1, 2) = t$: flag2 = 4
ELSEIF in2 = -1 AND flag2 = 4 THEN
z2$(2, 1) = t$: flag2 = 5
ELSEIF in2 = 0 AND flag2 = 5 THEN
z2$(2, 2) = t$: flag2 = 6
ELSEIF in2 = -1 AND flag2 = 6 THEN
z2$(3, 1) = t$: flag2 = 7
ELSEIF in2 = 0 AND flag2 = 7 THEN
z2$(3, 2) = t$: flag2 = 8
ELSEIF in2 = -1 AND flag2 = 8 THEN
z2$(4, 1) = t$: flag2 = 9
ELSEIF in2 = 0 AND flag2 = 9 THEN
z2$(4, 2) = t$: flag2 = 10
ELSEIF in2 = -1 AND flag2 = 10 THEN
z2$(5, 1) = t$: flag2 = 11
ELSEIF in2 = 0 AND flag2 = 11 THEN
z2$(5, 2) = t$: flag2 = 12
ELSEIF in2 = -1 AND flag2 = 12 THEN
z2$(6, 1) = t$: flag2 = 13
ELSEIF in2 = 0 AND flag2 = 13 THEN
z2$(6, 2) = t$: flag2 = 14
ELSEIF in2 = -1 AND flag2 = 14 THEN
z2$(7, 1) = t$: flag2 = 15
ELSEIF in2 = 0 AND flag2 = 15 THEN
z2$(7, 2) = t$: flag2 = 16
ELSEIF in2 = -1 AND flag2 = 16 THEN
z2$(8, 1) = t$: flag2 = 17
ELSEIF in2 = 0 AND flag2 = 17 THEN
z2$(8, 2) = t$: flag2 = 18
ELSEIF in2 = -1 AND flag2 = 18 THEN
z2$(9, 1) = t$: flag2 = 19
ELSEIF in2 = 0 AND flag2 = 19 THEN
z2$(9, 2) = t$: flag2 = 20
ELSEIF in2 = -1 AND flag2 = 20 THEN
z2$(10, 1) = t$: flag2 = 21
ELSEIF in2 = 0 AND flag2 = 21 THEN
z2$(10, 2) = t$: flag2 = 22
ELSEIF in2 = -1 AND flag2 = 22 THEN
z2$(11, 1) = t$: flag2 = 23
ELSEIF in2 = 0 AND flag2 = 23 THEN
z2$(11, 2) = t$: flag2 = 24
END IF


IF in3 = -1 AND flag3 = 0 THEN 'tests for main status
z3$(0, 1) = t$: flag3 = 1
ELSEIF in3 = 0 AND flag3 = 1 THEN
z3$(0, 2) = t$: flag3 = 2
END IF

IF in4 = -1 AND flag4 = 0 THEN ' tests for apt status
z4$(0, 1) = t$: flag4 = 1
ELSEIF in4 = 0 AND flag4 = 1 THEN
z4$(0, 2) = t$: flag4 = 2
ELSEIF in4 = -1 AND flag4 = 2 THEN
z4$(1, 1) = t$: flag4 = 3
ELSEIF in4 = 0 AND flag4 = 3 THEN
z4$(1, 2) = t$: flag4 = 4
ELSEIF in4 = -1 AND flag4 = 4 THEN
z4$(2, 1) = t$: flag4 = 5
ELSEIF in4 = 0 AND flag4 = 5 THEN
z4$(2, 2) = t$: flag4 = 6
ELSEIF in4 = -1 AND flag4 = 6 THEN
z4$(3, 1) = t$: flag4 = 7
ELSEIF in4 = 0 AND flag4 = 7 THEN
z4$(3, 2) = t$: flag4 = 8
ELSEIF in4 = -1 AND flag4 = 8 THEN
z4$(4, 1) = t$: flad4 = 9
ELSEIF in4 = 0 AND flag4 = 9 THEN
z4$(4, 2) = t$: flag4 = 10
ELSEIF in4 = -1 AND flag4 = 10 THEN
z4$(5, 1) = t$: flag4 = 11
ELSEIF in4 = 0 AND flag4 = 11 THEN
z4$(5, 2) = t$: flaf4 = 12
ELSEIF in4 = -1 AND flag4 = 12 THEN
z4$(6, 1) = t$: flag4 = 13
ELSEIF in4 = 0 AND flag4 = 13 THEN
z4$(6, 2) = t$: flag4 = 14
END IF

IF in5 = -1 AND flag5 = 0 THEN 'tests for 2nd floor status
z5$(0, 1) = t$: flag5 = 1
ELSEIF in5 = 0 AND flag5 = 1 THEN
z5$(0, 2) = t$: flag5 = 2
END IF

IF in6 = -1 AND flag6 = 0 THEN 'tests for hot water status
z6$(0, 1) = t$: flag6 = 1
ELSEIF in6 = 0 AND flag6 = 1 THEN
z6$(0, 2) = t$: flag6 = 2
END IF

PRINT z1$(1, 1): PRINT z1$(1, 2)
GOTO start

basementdata:
LOCATE 4, 10: PRINT z1$(0, 0): 'subroutine 1000 Prints Basement data
LOCATE 6, 8: PRINT Z$(0, 1):
LOCATE 6, 17: PRINT Z$(0, 2):
LOCATE 8, 5: PRINT z1$(0, 1)
LOCATE 8, 15: PRINT z1$(0, 2)
LOCATE 9, 5: PRINT z1$(1, 1)
LOCATE 9, 15: PRINT z1$(1, 2)
LOCATE 10, 5: PRINT z1$(2, 1)
LOCATE 10, 15: PRINT z1$(2, 2)
RETURN

shopdata:
LOCATE 4, 30: PRINT z2$(0, 0) 'subroutine 2000 Prints Shop data
LOCATE 6, 28: PRINT Z$(0, 1)
LOCATE 6, 37: PRINT Z$(0, 2)
LOCATE 8, 25: PRINT z2$(0, 1)
LOCATE 8, 35: PRINT z2$(0, 2)
LOCATE 9, 25: PRINT z2$(1, 1)
LOCATE 9, 35: PRINT z2$(1, 2)
LOCATE 10, 25: PRINT z2$(2, 1)
LOCATE 10, 35: PRINT z2$(2, 2)
LOCATE 11, 25: PRINT z2$(3, 1)
LOCATE 11, 35: PRINT z2$(3, 2)
LOCATE 12, 25: PRINT z2$(4, 1)
LOCATE 12, 35: PRINT z2$(4, 2)
LOCATE 13, 25: PRINT z2$(5, 1)
LOCATE 13, 35: PRINT z2$(5, 2)
RETURN

maindata:
LOCATE 4, 52: PRINT z3$(0, 0)'subroutine 3000 prints main data
LOCATE 6, 48: PRINT Z$(0, 1)
LOCATE 6, 58: PRINT Z$(0, 2)
LOCATE 8, 46: PRINT z3$(0, 1)
LOCATE 8, 56: PRINT z3$(0, 2)
RETURN

aptdata:
LOCATE 14, 11: PRINT z4$(0, 0)'subroutine 4000 prints Guest Apt data
LOCATE 16, 8: PRINT Z$(0, 1)
LOCATE 16, 17: PRINT Z$(0, 2)
LOCATE 18, 5: PRINT z4$(0, 1)
LOCATE 18, 15: PRINT z4$(0, 2)
LOCATE 19, 5: PRINT z4$(1, 1)
LOCATE 19, 15: PRINT z4$(1, 2)
LOCATE 20, 5: PRINT z4$(2, 1)
LOCATE 20, 15: PRINT z4$(2, 2)
LOCATE 21, 5: PRINT z4$(3, 1)
LOCATE 21, 15: PRINT z4$(3, 2)
LOCATE '22, 5: PRINT z4$(4, 1)
LOCATE '22, 15: PRINT z4(4, 2)
LOCATE '23, 5: PRINT z4$(5, 1)
LOCATE '23, 15: PRINT z4$(5, 2)
LOCATE '24, 5: PRINT z4$(6, 1)
LOCATE '24, 15: PRINT z4$(6, 2)
RETURN

secondfldata:
LOCATE 14, 30: PRINT z5$(0, 0)'subroutine 5000 prints 2nd Floor data
LOCATE 16, 28: PRINT Z$(0, 1)
LOCATE 16, 37: PRINT Z$(0, 2)
LOCATE 18, 25: PRINT z5$(0, 1)
LOCATE 18, 35: PRINT z5$(0, 2)
RETURN

hotwtrdata:
LOCATE 14, 50: PRINT z6$(0, 0)'subroutine 6000 prints Hot Water data
LOCATE 16, 48: PRINT Z$(0, 1)
LOCATE 16, 58: PRINT Z$(0, 2)
LOCATE 18, 46: PRINT z6$(0, 1)
LOCATE 18, 56: PRINT z6$(0, 2)
RETURN


alldata:
GOSUB basementdata'subroutine 7000 prints all zones
GOSUB shopdata
GOSUB maindata
GOSUB aptdata
GOSUB secondfldata
GOSUB hotwtrdata
RETURN

allshop:
LOCATE 3, 62: PRINT z2$(0, 1)
LOCATE 3, 72: PRINT z2$(0, 2)
LOCATE 4, 62: PRINT z2$(1, 1)
LOCATE 4, 72: PRINT z2$(1, 2)
LOCATE 5, 62: PRINT z2$(2, 1)
LOCATE 5, 72: PRINT z2$(2, 2)
LOCATE 6, 62: PRINT z2$(3, 1)
LOCATE 6, 72: PRINT z2$(3, 2)
LOCATE 7, 62: PRINT z2$(4, 1)
LOCATE 7, 72: PRINT z2$(4, 2)
LOCATE 8, 62: PRINT z2$(5, 1)
LOCATE 8, 72: PRINT z2$(5, 2)
LOCATE 9, 62: PRINT z2$(6, 1)
LOCATE 9, 72: PRINT z2$(6, 2)
LOCATE 10, 62: PRINT z2$(7, 1)
LOCATE 10, 72: PRINT z2$(7, 2)
LOCATE 11, 62: PRINT z2$(8, 1)
LOCATE 11, 72: PRINT z2$(8, 2)
LOCATE 12, 62: PRINT z2$(9, 1)
LOCATE 12, 72: PRINT z2$(9, 2)
LOCATE 13, 62: PRINT z2$(10, 1)
LOCATE 13, 72: PRINT z2$(10, 2)
'LOCATE 14, 62: PRINT z2$(11, 1)
'LOCATE 14, 72: PRINT z2$(11, 2)
RETURN


printer:
OPEN "lpt1" FOR OUTPUT AS 1
PRINT #1, TAB(7); z1$(0, 0);
PRINT #1, TAB(40); z2$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, z1$(0, 1); , z1$(0, 2);
PRINT #1, TAB(33); z2$(0, 1); TAB(49); z2$(0, 2)
PRINT #1, z1$(1, 1), z1$(1, 2);
PRINT #1, TAB(33); z2$(1, 1); TAB(49); z2$(1, 2)
PRINT #1, z1$(2, 1), z1$(2, 2)
PRINT #1, CHR$(10), CHR$(10), CHR$(10), CHR$(10), CHR$(10)
PRINT #1, TAB(7); z3$(0, 0)
PRINT #1, TAB(40); z4$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, z3$(0, 1), z3$(0, 2);
PRINT #1, TAB(33); z4$(0, 1); TAB(49); z4$(0, 2)
PRINT #1, z3$(1, 1), z3$(1, 2)
PRINT #1, CHR$(10), CHR$(10), CHR$(10), CHR$(10), CHR$(10)
PRINT #1, TAB(7); z5$(0, 0)
PRINT #1, TAB(40); z5$(0, 0)
PRINT #1, TAB(4); Z$(0, 1),
PRINT #1, Z$(0, 2), TAB(36); Z$(0, 1); TAB(51); Z$(0, 2)
PRINT #1, CHR$(12);
CLOSE
RETURN

allapt:
LOCATE 3, 62: PRINT z4$(0, 1)
LOCATE 3, 72: PRINT z4$(0, 2)
RETURN


Posted on Jan 15, 2013, 4:34 PM

Respond to this message   

Return to Index


Of course...

by (Login qb432l)
R

Change your DIM statements as follows. I added Z$(20, 2) since it is also used:

DIM Z$(20, 2)
DIM z1$(20, 2): 'zone 1 is Basement data array all arrays are 20 rows
DIM z2$(20, 2): 'zone 2 is Shop data array 2 col
DIM z3$(20, 2): 'zone 3 is main floor data array
DIM z4$(20, 2): 'zone 4 is Guest apt data array
DIM z5$(20, 2): 'zone 5 is 2nd Flooe data array
DIM z6$(20, 2): 'zone 6 is Hot water data array

Now the arrays you are actually using have been DIM'd You never use zone1$() or zone2$(), etc.. Only z1$(), z2$(), etc..

In one group of assignment statements, you use variables named zone1$, zone2$, etc., but they are not arrays. Very confusing.

-Bob

Posted on Jan 15, 2013, 6:13 PM

Respond to this message   

Return to Index


Thank You

by Leon Schrecengost (no login)

Bob, I cleaned up my pgm using your suggestions. It works great. Thanks so much for your help. I don't even know why I did what I did. Is there any chance you could look at the PRINTER sub routine. There must be a better way to print the data in the arrays. Also is there a way to take the time data from the array address and calulate the time. This would be real nice rather than print it then calulate the zone run time by hand.
Thanks again
Leon

Posted on Jan 17, 2013, 8:28 AM

Respond to this message   

Return to Index


LOL@"I don't even know why I did what I did"...

by (Login qb432l)
R

That's often the case. We go over code again and again, and the same errors keep eluding us. It often takes an objective eye to spot it. I also failed to mention that when you DIM'd zone2$() you DIM'd it as zone2%() - a simple typo, "%" instead of "$". I didn't mention it because it wasn't the real problem and would only have confused things even more.

Does your print routine even work? OPEN "lpt1" shouldn't work on anything but older computers/printers. What computer/printer are you working with?

In any event, printing from arrays can be simplified by using loops, and letting the loop counter do the work, but only when all the data is in the same array, for example:

FOR n = 1 to 5
PRINT TAB(5); Array(n);
NEXT n

In your case I don't think it would help, although admittedly, I haven't gone over your code in depth.

Not sure what the TIME$ question is all about, but calculations based on TIME$ requires distinguishing between hours/minutes/seconds (lots of math), not to mention converting from a string, first. The simpler way is to use the TIMER function, which returns the number of seconds since midnight. After you've done your calculation, convert the answer to hours/minutes/seconds, and then build a string: "##:##:##" -- much easier than starting with TIME$.

Hours = TIMER \ 3600 'Note: Integer division (backslash)
Minutes = (TIMER - (Hours * 3600)) \ 60
Seconds = FIX(TIMER - (Hours * 3600) - (Minutes * 60))

FIX elminates the decimal fraction from "Seconds".

Check it out: PRINT TIMER

-Bob



    
This message has been edited by qb432l on Jan 17, 2013 12:31 PM
This message has been edited by qb432l on Jan 17, 2013 12:28 PM
This message has been edited by qb432l on Jan 17, 2013 12:23 PM
This message has been edited by qb432l on Jan 17, 2013 12:20 PM
This message has been edited by qb432l on Jan 17, 2013 12:18 PM

Posted on Jan 17, 2013, 12:13 PM

Respond to this message   

Return to Index


printer

by Leon (no login)

Yes this does work. I'm using a program called DOS print and I redirect the LPT1 port to the local USB printer. It also allows me to print the program listing from qbasic.
Leon

Posted on Jan 17, 2013, 2:33 PM

Respond to this message   

Return to Index


*Hey, that's great to know (will check out DOS print). Thanks!

by (Login qb432l)
R

*

Posted on Jan 17, 2013, 4:57 PM

Respond to this message   

Return to Index


Show Time

by Solitaire (Login Solitaire1)
S

Thank you, BOB. I was inspired to write this little program:

'equations by theBOB
DIM hours AS SINGLE, minutes AS SINGLE, seconds AS SINGLE
DIM hrs AS STRING, min AS STRING, sec AS STRING, ap AS STRING
DIM mytime AS STRING, K AS STRING
CLS
DO
    LOCATE 1, 1
    PRINT "TIMER is now:  "; TIMER
    PRINT : PRINT "Press Enter to stop..."
    hours = TIMER \ 3600
    minutes = (TIMER - (hours * 3600)) \ 60
    seconds = FIX(TIMER - (hours * 3600) - (minutes * 60))
    IF hours <= 12 THEN
        ap$ = " AM "
    ELSE
        ap$ = " PM "
        hours = hours - 12
    END IF
    hrs$ = LTRIM$(RTRIM$(STR$(hours)))
    IF hours < 10 THEN hrs$ = " " + hrs$
    min$ = LTRIM$(RTRIM$(STR$(minutes)))
    IF minutes < 10 THEN min$ = "0" + min$
    sec$ = LTRIM$(RTRIM$(STR$(seconds)))
    IF seconds < 10 THEN sec$ = "0" + sec$
    mytime$ = hrs$ + ":" + min$ + ":" + sec$ + ap
    LOCATE 8, 1
    PRINT "Time is now:  "; mytime$
    K$ = INKEY$
LOOP UNTIL K$ = CHR$(13)
END

Posted on Jan 17, 2013, 7:09 PM

Respond to this message   

Return to Index


*Great job -- and a good example of the programming practices I attributed to you.

by (Login qb432l)
R

*

Posted on Jan 17, 2013, 7:18 PM

Respond to this message   

Return to Index


Similar program using TIME$

by Solitaire (Login Solitaire1)
S

Here is an older program I wrote years ago which uses TIME$ instead of TIMER. I updated the loop for a continuous display, similar to the above post:


DIM mytime AS STRING, hr AS STRING, mer AS STRING, minsec AS STRING
DIM clock AS STRING, K AS STRING, hour AS SINGLE
CLS
PRINT "Display clock time based on system clock."
PRINT "Press Enter to stop."
DO
  LOCATE 5
  PRINT "System clock time is: "; TIME$;
  mytime$ = TIME$
  hr$ = LEFT$(mytime$, 2)
  hour = VAL(hr$)
  IF hour = 0 THEN hour = 12    'midnight
  IF hour <= 12 THEN
    mer$ = "AM"
  ELSE
    hour = hour - 12
    mer$ = "PM"
  END IF
  hr$ = STR$(hour)
  minsec$ = RIGHT$(mytime$, 6)
  clock$ = hr$ + minsec$ + " " + mer$
  LOCATE 10, 1
  PRINT "Adjusted clock time is: "; clock$
  K$ = INKEY$
LOOP UNTIL K$ = CHR$(13)
END

Posted on Jan 17, 2013, 7:32 PM

Respond to this message   

Return to Index


Nice one...

by (Login qb432l)
R

I've written similar programs (though not as "tight") for AM/PM clock displays. The above was my first attempt to convert TIMER to HH:MM:SS (btw, thanks for the string conversions).

Good stuff!
-Bob

Posted on Jan 17, 2013, 7:51 PM

Respond to this message   

Return to Index


I wrote a Visual Basic version of the ShowTime program.

by Solitaire (no login)

It's posted in the Visual Basic subforum:

http://www.network54.com/Forum/613144/message/1358560032/Show+current+time++based+on+the+Timer+property

Note the similarities and differences in the code between the 2 versions. The output is nearly identical when you compare them side by side. The VB version is done as a Console application


Posted on Jan 18, 2013, 5:50 PM

Respond to this message   

Return to Index


Looks good...

by (Login qb432l)
R

I'm afraid I can't run it since I haven't installed VB on my current computer (I never used it, and with QB64 it became unnecessary -- for my purposes, at any rate). Still and all, your program looks like it would work well (of course).

-Bob

Posted on Jan 18, 2013, 9:10 PM

Respond to this message   

Return to Index


Re: Posting code

by (Login MCalkins)
Moderator

What are you copying from? Notepad? Wordpad? QB64 IDE?

Don't copy from the QBASIC 1.1 editor, because it does not interface with the Windows clipboard.

Regards,
Michael

Posted on Jan 14, 2013, 2:23 PM

Respond to this message   

Return to Index

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