Author Topic: Old programs run too small  (Read 3939 times)

0 Members and 1 Guest are viewing this topic.

Offline jeffjeff

  • Newbie
  • Posts: 4
    • View Profile
Old programs run too small
« on: October 01, 2020, 01:48:11 am »
Was glad to find qb64 and that it is able to run old programs I had.

But they run in a small window that can not be stretched out.

The text is tiny and the graphics are vertically compressed. Whats the best way to fix that?  Is there any way to have the display window stretchable?
  [ You are not allowed to view this attachment ]  


Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Old programs run too small
« Reply #1 on: October 01, 2020, 01:49:43 am »
Not sure if this will fix it but take a look at this:
https://www.qb64.org/wiki/$RESIZE
Shuwatch!

Offline jeffjeff

  • Newbie
  • Posts: 4
    • View Profile
Re: Old programs run too small
« Reply #2 on: October 01, 2020, 02:14:29 am »
Wow!
That was quick!
Thank you!

$RESIZE:SMOOTH

Worked great to get it resizeable.

But if I try to stretch the graphics screen window vertically, when I "let go", the width jumps out so it is still vertically squashed.

Actually even the text screen maintains the ratio.

I'm guessing that there's something with the screen  choices

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Old programs run too small
« Reply #3 on: October 01, 2020, 02:18:15 am »
It could be. Can you attach the source and I'll try to see if I can make it scale better for you?
Shuwatch!

Offline jeffjeff

  • Newbie
  • Posts: 4
    • View Profile
Re: Old programs run too small
« Reply #4 on: October 01, 2020, 04:18:46 am »
I discovered that I had version 1.3 of qb64 so have updated to 1.4, didn't see any changes in this case.

I made 2 qbasic programs in English for physics students in Tanzania that we ran och CGA and EGA (woohoo!) displays.
One is for learning to interpret a vernier scale (like on a caliper) and the other for interpreting analog electric meters.

Later I tried to make them (at least the verier one) give more guidance , when I translated to Swedish.

I intend to include the Swedish nonieEGA.bas file  (which is most complex).

If I can include 2 I will also include the English one vernier4.bas so you can see what it's about 

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Old programs run too small
« Reply #5 on: October 01, 2020, 07:33:20 am »
I took the liberty of putting your vernier reader in a 32 bit screen, although it may need some additional tweaking. Sized 640x480, it approximates an 80x30 text space. In QB64 it is possible to mix text position and graphics commands in a 32 bit screen; which can be made any size your monitor will accomodate, although _PRINTSTRING would allow more fine control of text positions than LOCATE does. I opted to do the minimum changes and just set up the SCREEN and tweaked the locate statements for a proper fit. It was also necessary to reference the vernier scale color in an unsigned long value (&HFFA800A8 is roughly COLOR 5) in keeping with the 32 bit scheme. I did take out the sub declarations and calls, as QB64 no longer requires them, it automatically recognizes subs and functions and just the name reference executes the "call".

This seems to open things up a bit.

Code: QB64: [Select]
  1. 'OldMoses' 32 bit modification of jeffjeff's vernier reader
  2.  
  3. DEFSNG A-Z
  4. DIM SHARED ansNum, ansUnit$, indelning, enhet$, faktor
  5. 'this program is to create a vernier reading practice game'
  6. 'ge information om programmet
  7. info
  8. SCREEN _NEWIMAGE(640, 480, 32)
  9. CONST PI = 3.141593
  10.     CLS
  11.     ChooseMeter
  12.     LINE (0, 100)-(600, 100)
  13.     max = 20 'greatest value of reading in cm
  14.     L1 = 40 ' longer scale line
  15.     L2 = 10 'shorter scale line
  16.     space = 20 'spacing of main scale
  17.     tolerance = .008 'cm error allowed
  18.     FOR I% = 0 TO 10
  19.         x1 = 200 + I% * space * 1.9 '0.9 or1.9 for different vern widths
  20.         y1 = 100
  21.         IF I% = 0 OR I% = 10 THEN
  22.             y2 = y1 + L1
  23.         ELSEIF I% = 5 THEN
  24.             y2 = y1 + (L1 + L2) / 2
  25.         ELSE y2 = y1 + L2
  26.         END IF
  27.         LINE (x1, y1)-(x1, y2), &HFFA800A8
  28.     NEXT I%
  29.     LOCATE 11, 27
  30.     PRINT "0                  10"
  31.     del = RND
  32.     reading = del * max
  33.     rcm = INT(reading)
  34.     Rmm = INT(reading * 10)
  35.     Rmm10 = INT(reading * 100)
  36.     maincm = 200 - (reading - rcm) * space * 10
  37.     FOR I% = 0 TO 30
  38.         xm1 = maincm + I% * space
  39.         ym1 = 100
  40.         IF I% = 0 OR I% = 10 OR I% = 20 THEN
  41.             ym2 = ym1 - L1
  42.         ELSEIF I% = 5 OR I% = 15 THEN
  43.             ym2 = ym1 - (L1 + L2) / 2
  44.         ELSE ym2 = ym1 - L2
  45.         END IF
  46.         LINE (xm1, ym1)-(xm1, ym2)
  47.     NEXT I%
  48.     LOCATE 3, 26 - (reading - rcm) * 25
  49.     PRINT rcm
  50.     LOCATE 3, 50 - (reading - rcm) * 25
  51.     PRINT rcm + 1
  52.     LOCATE 3, 75 - (reading - rcm) * 25
  53.     PRINT rcm + 2
  54.     LOCATE 20, 2
  55.     NumDec (ans$)
  56.     PRINT
  57.     IF ABS(ansNum - reading) < tolerance AND ansUnit$ = "cm" OR ABS(ansNum / 10 - reading) < tolerance AND ansUnit$ = "mm" THEN
  58.         rightRow = rightRow + 1
  59.         PRINT "Good!  You've done "; rightRow; " right in a row!"
  60.     ELSE
  61.         PRINT "Try to see what you did wrong!"
  62.         rightRow = 0
  63.     END IF
  64.     PRINT "  Right value = ";
  65.     PRINT USING "##.##"; del * max;
  66.     PRINT " cm or  ";
  67.     PRINT USING "###.#"; del * max * 10;
  68.     PRINT "mm     Exact value: "; reading; " cm"
  69.     INPUT "Ready to continue? y/n (y)", r$
  70. LOOP WHILE r$ = "j" OR r$ = "J" OR r$ = "Y" OR r$ = "y" OR r$ = ""
  71.  
  72. SUB ChooseEnhet
  73.     SELECT CASE INT(2 * RND)
  74.         CASE 0
  75.             enhet$ = "mm"
  76.         CASE 1
  77.             enhet$ = "cm"
  78.     END SELECT
  79.  
  80. SUB ChooseMeter
  81.     'denna subrutin skall slumpa fram skala m„tomr†de mm
  82.     'v„lj enhet
  83.     'this sub creates a random scale and markings w unit
  84.     ChooseEnhet
  85.     'v„lj factor
  86.     ChoseFaktor
  87.  
  88. SUB ChoseFaktor
  89.     SELECT CASE INT(4 * RND)
  90.         CASE 0
  91.             faktor = 1
  92.         CASE 1
  93.             faktor = 2
  94.         CASE 2
  95.             faktor = 10
  96.         CASE 3
  97.             faktor = 10
  98.     END SELECT
  99.  
  100. SUB info
  101.     CLS
  102.     PRINT
  103.     PRINT "  VERNIER3.BAS    PRACTICE PROGRAM FOR READING VERNIER SCALE"
  104.     PRINT
  105.     PRINT " English Version 1995 Apr 10 Jeff Forssell www.TupoMedia.se "
  106.     PRINT
  107.     PRINT "    The first step is to see what is the number of whole units on"
  108.     PRINT " the main scale. In the case of the VERNIER CALIPER this would be"
  109.     PRINT " millimeters (mm). This you read by looking at the main scale just"
  110.     PRINT " above the first (=zero) line of the vernier scale. Then to get the"
  111.     PRINT " tenths of mm (1/10 mm) we look at the vernier scale and use the value"
  112.     PRINT " corresponding to the line which best matches (aligns with) the lines "
  113.     PRINT " on the main scale above it. (If two lines match equally try XX.X5mm.)"
  114.     PRINT "    You should answer to 1/10mm like this:  34.5mm or 3.45cm "
  115.     PRINT " You can use either  .   or   ,  as decimal separator. You can also "
  116.     PRINT " have a space(s) between 34,5 mm if you want. But you may not have "
  117.     PRINT " CM or MM as units. This program is not prepared yet for other"
  118.     PRINT " correct forms like 0.0345m or 3.45e-2m."
  119.     PRINT " If the program doesn't say GOOD about you answer, try to find"
  120.     PRINT " your mistake. If you don't, make a screen shot [PrtScr] and send to"
  121.     PRINT " jeff.forssell@gmail.com  .   There might be a program error or"
  122.     PRINT " something you don't understand yet."
  123.     PRINT "    If you want to LEAVE the program now, Press <L> and <ENTER>"
  124.     PRINT " Otherwise press <ENTER> to continue."
  125.     LINE INPUT L$
  126.     IF UCASE$(L$) = "L" THEN SYSTEM
  127.  
  128. SUB NumDec (ans$)
  129.     'denna program h„mtar in en storlek med sifferv„rde och enhet
  130.     'och delar upp det i ett m„tetal och en enhetsstr„ng
  131.     'this program gets input and divides it into a number and unit string
  132.     LINE INPUT "Read caliper! (L for Leave) ", ans$
  133.     IF UCASE$(ans$) = "L" THEN SYSTEM
  134.     '„ndrar komma till decimalpunkt och tar bort mellanslag
  135.     'changes comma to decimal point and removes SPACEs
  136.     NyDec$ = ""
  137.     FOR num = 1 TO LEN(ans$)
  138.         char$ = MID$(ans$, num, 1)
  139.         IF char$ = "," THEN char$ = "."
  140.         IF char$ = " " THEN char$ = ""
  141.         NyDec$ = NyDec$ + char$
  142.     NEXT num
  143.     ansNum = VAL(NyDec$)
  144.     ansUnit$ = ""
  145.     DO
  146.         FOR num = 1 TO LEN(NyDec$)
  147.             IF ASC(MID$(NyDec$, num, 1)) < 58 AND ASC(MID$(NyDec$, num, 1)) > 47 THEN
  148.                 char$ = ""
  149.             ELSEIF MID$(NyDec$, num, 1) = "." THEN
  150.                 char$ = ""
  151.             ELSE char$ = MID$(NyDec$, num, 1)
  152.             END IF
  153.             ansUnit$ = ansUnit$ + char$
  154.         NEXT num
  155.         IF ansUnit$ = "" THEN
  156.             PRINT "A reading must have a unit to be meaningful!"
  157.             LINE INPUT "Which unit ? ", NyDec$
  158.         END IF
  159.     LOOP UNTIL ansUnit$ <> ""
  160.     PRINT "Your answer =  "; ansNum; " "; ansUnit$;
  161.  
  162.  

Offline jeffjeff

  • Newbie
  • Posts: 4
    • View Profile
Re: Old programs run too small
« Reply #6 on: October 01, 2020, 09:04:29 am »
I put in $RESIZE:SMOOTH

and your changes made it able to keep reasonable ratios.

Thank you!

Next step to implement that in the more complicated Swedish one!