Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

RecordStoreManagement Java2 Micro Edition -> Problem!?

Empfohlene Antworten

Veröffentlicht

Halli Hallo,

moechte direkt mit einer fuer mich wichtigen Frage starten:

folgendes Problem: ich moechte einen Wert (temp_id -> nur als Bsp) in

einen Recordstore schreiben. Leider wird durch den u. g. Code dieser

Wert immer ueberschrieben. Die Ausgabe ist also immer "49". Alle

einzelnen Werte sollen aber ausgegeben werden. Wie kann ich das

Problem loesen?

schnipp----------------------------------

public void save() {

int temp_x, temp_y, temp_id = 0;

Lesson temp_lesson;

String temp_code = "";

openRMS(); // oeffnet den recordstore

for(temp_x = 0; temp_x < 5; temp_x++) { // hat einen sinn :)

for(temp_y = 0; temp_y < 10; temp_y++) { // ""

temp_code = String.valueOf(temp_id); // 0 - 49

byte[] rec = temp_code.getBytes(); //

try {

id = rs.addRecord(rec, 0, rec.length); // REcord hinzufuegen

}

catch (Exception e){}

temp_id++;

}

}

closeRMS(); // schliesst recorstore

}

Gelesen wird das ganze hiermit:

schnipp-----------------------------------------------------

public void load() {

int temp_x, temp_y, temp_id;

String temp_code = "";

temp_id = 0;

openRMS();

for(temp_x = 0; temp_x < 5; temp_x++) {

for(temp_y = 0; temp_y < 10; temp_y++) {

// ...

try {

byte holen[] = new byte[100];

int gelesen = rs.getRecord( id[temp_id], holen, 0 );

temp_code = new String( holen, 0, gelesen);

}catch (Exception e) {

e.toString();

}

temp_lesson.set_code(temp_code);

} catch(LessonUndefinedException e) {}

temp_id++;

}

}

closeRMS();

}

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

Was mache ich falsch?

Vielen Dank!!

lesezeichen

1. bei save ist temp_id immer 0, oder habe ich eine zuweisung übersehen?

2. bei load ist id (zumindest in dem ausschnitt) nicht definiert.

allgemein: nimm das nächste mal bitte CODE oder PHP, dann wird der quelltext min ordenlich formatiert. Danke.

OK, es geht sich erstmal um das speichern. temp_id ist nicht immer 0, sie wird nach jedem schleifendurchlauf inkrementiert.

nochmal der Code:



public void save() {

int temp_x, temp_y, temp_id = 0;
Lesson temp_lesson;
String temp_code = "";

openRMS(); // oeffnet den recordstore

for(temp_x = 0; temp_x < 5; temp_x++) { // hat einen sinn
for(temp_y = 0; temp_y < 10; temp_y++) { // ""

temp_code = String.valueOf(temp_id); // 0 - 49
byte[] rec = temp_code.getBytes(); //

try {
id = rs.addRecord(rec, 0, rec.length); // REcord hinzufuegen
}
catch (Exception e){}
temp_id++;
}
}
closeRMS(); // schliesst recorstore
}
[/PHP]

Workaround: Es muss eine Moeglichkeit geben das Byte-Array (steht ja fuer den String) wiederrum in ein Array zu packen, dass die einzelnen Byte-Array-Inhalte via direktem Zugriff verfuegbar macht.

es soll also so sein:

zugriff: [1] inhalt: 1

zugriff: [2] inhalt: 2

etc...

aber wie macht man das?

wie wuerde sowas aussehen? bsp plz! thx

hat sich erledigt

nein, geht auch ohne

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.