Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QB45 - ASCII 31 (downward pointing triangle)

Status
Not open for further replies.

joewillerols

Programmer
Dec 29, 2020
20
US
I'm writing a program that will allow one to look up US/Canadian phone area codes. This will be done by either entering a state/province abbreviation or area code. That part is easy enough.

The problem I am having is with the ASCII 31 character. Since it is a non printing character I must use CHR$(31) in order to display it on the screen. The problem is that it won't. When I go into the help and view the characters, it does show up. However, when I run the program it doesn't. I simply get nothing on the screen. dBase iii+ and Turbo C 2.0 will display this character.

I did some searching and found that QB 4.00, QB 4.00b, and QB 4.5 will not display this character. Okay, I can believe that if it weren't for the fact that it displays in the Help. Because QB is a micro$haft product, I'm not surprised that m$ says it will do something and then not do it.

How do I get this character to display?

Thanks,
Joe
 
Have you tried to print the character as string, like this ?
Screenshot_at_2022-06-26_05-03-22_utdzsr.png
 
No. I haven't. I'll give that a try and let you know.

Tks,
Joe
 
mikron, I like the way you think. But... it didn't work.
Using flash drives, I booted up into Windows Millennium [Version 4.90.3000] which came from Rufus and MSDOS 6.22. The downward triangle still did not appear.
I attached the Help screen that shows it can be printed. This is frustrating.

Joe
 
 https://files.engineering.com/getfile.aspx?folder=728777b2-cba0-4773-b931-2b91203d0f26&file=QB45_ASCII_Chart.PNG
I thought, I would write a C program which prints the character 31, for example ascii_char_31.c, then compile it and run it redirecting output into the text file: ascii_char_31.exe > ascii_char_31.txt
Then I would open the text file and copy from it the resulting string into a string variable in BASIC source code. But, I didn't try it, because I don't have a DOS machine with QB45 and Turbo C. To try it I would need to install DosBox and get from somewhere QB45 and Turbo C - if it's still possible at all.

But when you tried it and it doesn't work, I would suggest you to upgrade from the obsolete unsupported QB45 to the up to date supported and back compatible compiler QB64 (
In QB64 it works for me without problems - see the screenshot:
Screenshot_at_2022-07-10_12-10-49_j05a0w.png
 
@mikrom
I had QB64win v0.953 and am going to check out this v2.0.2 after all 16,200+ files have extracted. Thanks for the reminder and possible upgrade. [thumbsup]


@joewillerols
If memory serves correctly characters 0 through 31 were primarily for printer controls...especially for CANNON printers back in those days. As for EPSON printers, they required ESCape code BEfore the control sequence was passed on.

I vaguely remember using something like:

WRITE #[LPTPort],"underline this";
WRITE #[LPTPort],string$(asc(08), 5); 'backspace the printhead 5 times to start at the T
WRITE #[LPTPort];"____"
WRITE #[LPTPort]; asc(13)

It was something like that. The "BS" after ASC(8) in the pic reminded me of it--the backspacing that is--and "ASC 13 (cr)" well the "CR" was Carrage Return.

Anyways .....
IF you don't want to switch to QB64 then have you considered using Character #25 instead? It IS used by QB to scroll through the editing window...just look at the bottom right. You can give it a try.

"If a tree falls in the forest and no one is around, does it make a sound?" I finally got the REAL ANSWER and its deeper than either Yes or No.
 
Hi MiggyD,

I originally installed QB64 just to answer some questions in Qbasic forum, but since then I really like it as it runs well on Linux too.

Btw, in the meantime I tried to print the character 31 in QB45 with a C-routine, but I did not succeed.
I used QB45 with DosBox and I tried to use a C-routine like described here I tried for it two old C compilers for DOS: TurboC 3.0 and MS QuickC 2.51, but it was a waste of time, it did not work.
 
Hi mikrom,

Thanks again for reminding me to update QB64Win to v2.0.2. It IS a larger program than it used to be but the enhancements to RPD are kind of worth it, I MUST say. I know the stress of that something being just out of reach...its infuriating.
-----

Hi joewillerols,

I HIGHLY RECOMMEND (if you can) to switch to QB64Win as Mikrom indicated. I went through my old QB program codes and I found some of my notes. I then checked with QB64's help files--unfortunately some commands have depreciated or outright removed--and found some "newly reworked/enhanced" commands that may help.

I also RECOMMEND if it is a QuickBASIC question that you post it in the QBasic forum. It tends to have more people there.

Code:
Cls
Screen _NewImage(800, 600, 256)
Print "** The following code was created in QB64 for Windows ver 2.0.2."
Color 4
Print "** There is NO guarantee it will work on any other version of QB."
Color 15
Print "** I still recommend using ASCII #25... ( " + Chr$(25) + " ). It is viable."
Print "** Otherwise, please enjoy.  --MiggyD"
Locate 7, 15
Print "Press any key to continue"
MoveOn$ = Input$(1)
Cls 2
For code = 0 To 31
    chrstr$ = chrstr$ + Chr$(code) + Space$(1)
Next
_PrintString (1, 1), chrstr$
Color 11
_PrintString (9, 24), "A DownArrow like (" + Chr$(31) + ") should now be visible on this line when printed on screen."
Line (2, 20)-(644, 40), _RGB(200, 200, 0), B
End


Please keep in mind that it worked for me, my monitor is HD capable so the 800x600 screen resolution with greater than 256 colors were accessible to the emulated DOS/CMD screen. So don't use a monochromatic screen without altering ALL of the code appropriately.

If you find QB64Win helpful then click the "GREAT POST" STAR at the end of mikrom's post. By the same token; if you find the above code was help also then either just say thanks or click the star at the end of mine.

Hope this helps.
--MiggyD

"If a tree falls in the forest and no one is around, does it make a sound?" I finally got the REAL ANSWER.
 
I managed to write the ASCII character #31 in QB45 this way - using interrupt 21h to call DOS API function 02h (see:
intrpt.bas
Code:
'Writing Unit separator character, i.e ASCII char 31 (dec) = 1F (Hex)
'using Interrupt &H21 to call DOS API function 02h

'We need to start QB45 with the /L switch like this:
'C:\>QB /L
'to load the library QB.QLB, which contains the function INTERRUPTX

TYPE RegTypeX
    AX AS INTEGER
    BX AS INTEGER
    CX AS INTEGER
    DX AS INTEGER
    BP AS INTEGER
    SI AS INTEGER
    DI AS INTEGER
    FLAGS AS INTEGER
    DS AS INTEGER
    ES AS INTEGER
END TYPE

DIM inRegs AS RegTypeX, OutRegs AS RegTypeX

CLS

PRINT "ASCII character 31: ";

inRegs.DX = &H1F
GOSUB WRTCHR

END


WRTCHR:
  'AH = 02h -WRITE CHARACTER TO STANDARD OUTPUT
  inRegs.AX = &H200  'use the function AH = 02h
  'DL contains the ASCII value of the character to be written
  CALL INTERRUPTX(&H21, inRegs, OutRegs)
RETURN

then I started QB45 with the /L switch
[pre]C:\QB45>QB /RUN intrpt.bas /L[/pre]

and it seems to work:

2022-07-19_18h15_43_tyugga.png
 
Good job mikrom! I've totally forgotten about QB45's assembly link library for low memory stack manipulation. I can honestly say I'd used it only twice in my life. And both of those times were for experimental purposes, not for any rollouts. Back in those days RAM was extremely limited as I'm sure you well know.

Anyways ... joewillerols hasn't given us any updates. I guess it wasn't that important then.

I mean using QB45 to output "US/Canadian phone area codes" in this day and age?? Seriously?!? This sounds like homework...after all joewillerols stated he has dBASE3+ available to him. I've used dBASE3+ at least 7 years, made menus, input screens, report screens and printout options. Its far easier to use it for the project he's saying he's doing.

But I'm digressing ... Way to go! mikrom[thumbsup2]

Here's a star for you. See ya in the RT sometime.
APic_cwnmgi.jpg

--MiggyD

I close my eyes, only for a moment and the moment's gone.
 
Hi MiggyD,

Even if it were that feasible in QB45, if I were joewillerols I'd rather look at QB64 anyway. In my opinion the better time investment is to port the existing QB45 program to QB64 and continue developing there. MS DOS and MS QB45 are definitively dead. The way to go is to use a QB45-compatible and currently supported Basic compiler which runs on current operating systems, i.e. QB64 or FreeBasic.

If you mention dBASE - yes, I really liked the database system dBASE in the 1980's. As soon as I took the first steps with the PC and programming in Basic, I switched to dBASE II under CP/M, in which I also did my first major project as part of my university studies. At that time I thought that dBASE had a very big future and I couldn't imagine that such a good product could break at some point. Later I switched to Pascal, C and Fortran and today my work mainly involves SQL, COBOL, Java and Python.
 
Hey, everyone.

Tks for all the help and suggestions. I decided to give up on CHR$(31) and will use CHR$(17) on the left and CHR$(16) on the right.

As for using QB64, I have that and will compile my program there too. I'm using both so that everyone in the DOS/windoze world will be able to run my program. It has sound but sound with QB45 seems to only work up through XP. win7 will not do sound unless I use QB64. I haven't tried Vista yet. At some point I hope to export it to Mac and Linux.

I've attached the program with what I have done so far. There is sound but you may not hear it.

Joe
 
 https://files.engineering.com/getfile.aspx?folder=88b722b2-207c-423a-aec6-45795eddc8d1&file=AREACODE.EXE
Hi joewillerols,

QB64 or FreeBasic is definitely the way to go.

If I were you, I'd forget Vista , Win XP, and Windows 7. Windows Vista was the last Microsoft operating system I used at home. IMO, nowadays to write something for an old unsupported Basic running on DOS or an obsolete Windows version is waste of time.
The nice thing of the both compilers is that they are not MS Windows only, but multi platform. This fact is very important to me, because as hobbyist I'm using only Linux privately.

Of the two compilers mentioned above, I've only tried QB64 so far. It seems easier because it has a built-in IDE. But according to the reviews, FreeBasic is also said to be very good. But it doesn't have built-in IDE, so you have to use separate editor for program source editing and command line for compilation. However, this fact can also be an advantage for someone, e.g. I use one editor - namely Vim - for all source files in all programming languages I'm using.
 
@ joewillerols,
I know its been a while since I've been on ... glad you've figured something out for your dilemma. I hope you continue learning new things AND, hopefully at some point soon, you upgrade your version of QuickBASIC. [wink]

It may prove more fruitful than you know.

@ mikrom,
Ahh the good old (easier) days...

I was in 7th grade and a teacher brought in a crazy box called an APPLE and taught us how to stuff 2 floppy cardboard squares into it to make it work. She had us move a turtle that she called LOGO around the screen to draw triangles, squares, and other geometric shapes. It was kind-a fun. We were told it was called a "computer".

The next week the teacher brought in another "computer" called a TANDY with GWBasic and showed us how to create "commands" for input and output ... well I was hooked on the second computer.

My cousin got a Commadore. BUT I was gifted my own (LITERALLY PORTABLE) computer, a TI 99/4a which included internal BASIC. I quickly opted to spend nearly ALL of my Christmas money (all $90) to buy the "Extended Basic" plug-in cartridge! Yup! Not cardboard but CARTRIDGE like an Atari or Sega game.

With the extended basic module, I was able to use cassette tapes to save my programs and retrieve them and was able to access free ASCII TEXT BBSs (just needed phone number, parity, and duplexing) by using the phone's wall jack. Oh what simpler times the '80s were for me. [pc2]

--MiggyD

I close my eyes, only for a moment and the moment's gone.
 
Status
Not open for further replies.

Similar threads

Replies
1
Views
69

Part and Inventory Search

Sponsor

Back
Top