Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two-dimensional array
#1
Is there an interest for the wiki in a program for filling a two-dimensional array? As an an example.
Reply
#2
(12-28-2022, 09:55 PM)Kernelpanic Wrote: Is there an interest for the wiki in a program for filling a two-dimensional array? As an an example.

Sure! (Also maybe include an example function like the one they talked about the other day, on initializing an array.)
Reply
#3
Ok, here is the whole program, the whole attempt:

Code: (Select All)
$Console:Only
Option _Explicit

Option Base 1
Dim As Integer zahlenFeld(4, 3), feld(12)

Dim As Integer a, i, j, z
Dim As Integer zeile, spalte

Locate 2, 2
For a = 1 To 12
  feld(a) = a
  Print Using "## "; feld(a),
Next

Locate 4, 2

'Muss natuerlich mit etwas gefuellt werden!
'i + j sind nur fuer die Schleifensteuerung da.
z = 1
For i = 1 To 4
  For j = 1 To 3
    zahlenFeld(i, j) = z
    Print Using "## "; zahlenFeld(i, j),
    z = z + 1
  Next
  Print: Locate , 2
Next

Locate CsrLin + 2, 2
Input "Zeige Wert in Zeile # : ", zeile
Locate CsrLin + 0, 2
Input "Und in Spalte       # : ", spalte

Locate CsrLin + 1, 2

'Fehler bei falscher Eingabe abfangen - aber nur hier
If zeile > 4 Or spalte > 3 Then
  Print "Falsche Eingabe!"
  Sleep 2
  'Kehrt zum System zuruek
  System
Else
  Print Using "Wert in Zeile # und in Spalte # ist: ## "; zeile, spalte, zahlenFeld(zeile, spalte)
End If


'Aktuelle Zeilenkoordinate plus 3 als Argument von Locate.
'Das "Druecken Sie eine Taste" steht dann 3 Zeilen
'unter der letzten Position.
Locate CsrLin + 3, 2

End

Example:

[Image: Zweidim-Feld.jpg]
Reply
#4
The extension: Determining a two-dimensional field and resize it.

Code: (Select All)
$Console:Only
Option _Explicit

Option Base 1

Dim As Integer neuDimensionZeile, neuDimensionSpalte
Dim As Integer zeilenDim, spaltenDim
Dim As Integer a, b, i, j, y, z

Locate 2, 2
Input "Feldimension Zeilen  : ", zeilenDim
Locate 3, 2
Input "Felddimension Spalten: ", spaltenDim
Dim As Integer zweiDimfeld(zeilenDim, spaltenDim)

Locate CsrLin + 2, 2
z = 1
For i = 1 To zeilenDim
  For j = 1 To spaltenDim
    zweiDimfeld(i, j) = z
    Print Using "## "; zweiDimfeld(i, j),
    z = z + 1
  Next
  Print: Locate , 2
Next

Locate CsrLin + 2, 2
Input "Neue Feldimension Zeile : ", neuDimensionZeile
Locate CsrLin + 0, 2
Input "Neue Feldimension Spalte: ", neuDimensionSpalte

ReDim zweiDimfeld(neuDimensionZeile, neuDimensionSpalte)

Locate CsrLin + 2, 2
y = 1
For a = 1 To neuDimensionZeile
  For b = 1 To neuDimensionSpalte
    zweiDimfeld(a, b) = y
    Print Using "## "; zweiDimfeld(a, b),
    y = y + 1
  Next
  Print: Locate , 2
Next

Locate CsrLin + 3, 2

End

[Image: Zweidim-Feld-Neu-Dim.jpg]
Reply
#5
For the wiki I think it should be shorter, more to the point.
And of course in english  Wink
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply
#6
(12-30-2022, 01:04 PM)mdijkens Wrote: For the wiki I think it should be shorter, more to the point.
And of course in english  Wink

Two words:

Google Translate

Big Grin
Reply
#7
(01-05-2023, 02:26 AM)bobalooie Wrote:
(12-30-2022, 01:04 PM)mdijkens Wrote: For the wiki I think it should be shorter, more to the point.
And of course in english  Wink

Two words:

Google Translate

Big Grin

Speaking of, have we got HTTP functions built into QB64PE yet? 
Because it would be cool to make a QB64PE program that can make REST calls to Google translate and autotranslate a text file (or QB code) word for word...
Reply
#8
(12-30-2022, 01:04 PM)mdijkens Wrote: For the wiki I think it should be shorter, more to the point.
And of course in english  Wink

This is something coming out of an European whose first language isn't English...

I shake your hand and that of anybody else with those qualifications. Otherwise, QB64PE and many other apps would start looking like Libreoffice LOL. It seems everyday somebody volunteers to translate something in a certain language. I would too but don't want to be a package maintainer and I'm not going to have Internet for much longer...



ON TOPIC: coming to my mind readily as an example for double-dimensional arrays would be a text screen. Provide a way to print to the array before it is dumped to the screen, not having to turn to the fancy functions we have now to do that sort of thing.

Code: (Select All)
DIM myscreen(1 TO 25, 1 TO 80) AS STRING * 1

It opens some possibilities for how to interpret the information in the array to show the screen. Such as the twice-as-large wacky mode of TRS-80 Model III which required pressing [CLEAR] or entering "CLS" to cancel back to 64-character line. The 32x16 was standard on the Color Computer though.

Instead of one-byte string, could use "_BYTE" type for a way to interpret the high-bit characters, especially to print into a graphics screen and draw them instead of an unreliable Unicode font.
Reply
#9
(01-05-2023, 03:00 AM)madscijr Wrote: Speaking of, have we got HTTP functions built into QB64PE yet? 
Because it would be cool to make a QB64PE program that can make REST calls to Google translate and autotranslate a text file (or QB code) word for word...

For somebody who knows English, this method might be unacceptably slow, depending very much on Internet speeds. Not everybody has "1000 MEGAS" and not even 100. Also there are people trying to leech off Wifi from restaurants, schools and community houses...

There are people who don't live in the capital of an African or Asian country with Internet access which could be slower than the "basic" plan for a given ISP in the States. Think about the people of a certain eastern European country. But what do I really know?

The upcoming "HTTP(S)" functionality could be a mixed blessing. It's something I'm not going to be waiting for as much as the sound counterpart to "_NEWIMAGE" and related stuff.

Translating code is even less desireable; allow an user to use variable and function names in the language he/she knows best. But to be kind please comment in English, in my case because otherwise I know Spanish, would have to depend on that to know what is in Portuguese, would have to depend on my high-school Italian, could barely make out French and that's it.

To say it another way, for example Kernelpanic almost doesn't comment what program he offers which has me trying to figure out what a variable does. But it could go two ways: I'm lazy and don't like long variable names, have to really sit down and comment my programs before sharing them. Smile
Reply
#10
(01-05-2023, 03:53 AM)mnrvovrfc Wrote:
(01-05-2023, 03:00 AM)madscijr Wrote: Speaking of, have we got HTTP functions built into QB64PE yet? 
Because it would be cool to make a QB64PE program that can make REST calls to Google translate and autotranslate a text file (or QB code) word for word...

For somebody who knows English, this method might be unacceptably slow, depending very much on Internet speeds. Not everybody has "1000 MEGAS" and not even 100. Also there are people trying to leech off Wifi from restaurants, schools and community houses...

There are people who don't live in the capital of an African or Asian country with Internet access which could be slower than the "basic" plan for a given ISP in the States. Think about the people of a certain eastern European country. But what do I really know?

The upcoming "HTTP(S)" functionality could be a mixed blessing. It's something I'm not going to be waiting for as much as the sound counterpart to "_NEWIMAGE" and related stuff.

Translating code is even less desireable; allow an user to use variable and function names in the language he/she knows best. But to be kind please comment in English, in my case because otherwise I know Spanish, would have to depend on that to know what is in Portuguese, would have to depend on my high-school Italian, could barely make out French and that's it.

To say it another way, for example Kernelpanic almost doesn't comment what program he offers which has me trying to figure out what a variable does. But it could go two ways: I'm lazy and don't like long variable names, have to really sit down and comment my programs before sharing them. Smile

I think the more important & useful part would be the ability to call REST services from QB64PE. That opens up a lot of doors. Translating is just an exercise. (I'll leave the arguments for & against SOA and considerations for people's Internet speeds in other parts of the world for someone else to argue.)
I'll take more sound commands, too!
Reply




Users browsing this thread: 1 Guest(s)