Forum poświęcone PHP
Zdaje sobie sprawę z tego że mój problem jest zapewne trywialny ale proszę o pomoc bo naprawde skonczyły mi się pomysly gdzie moge miec błąd: [błąd-podczas zapisu "program wykonuje nieprawidlową operacje"] [???] [całość jest w klasie,kompilator DevC++] Defincje: struct Point2d{ int x,y; }; struct sPoint{ Point2d pos; bool marked; }sPoint points[100]; struct sWall{ int pt[2]; DWORD size; }sWall walls[100];//sciany Funkcja zapisu: bool Save(char *filename) { FILE* plik = fopen(filename,"wb"); if(!plik) return false; fwrite(&num_pts, sizeof(int), 1, plik); fwrite(points, sizeof(sPoint), num_pts, plik); fwrite(&num_walls,sizeof(int), 1, plik); fwrite(walls, sizeof(sWall), num_walls, plik); fclose(plik); return true; } Analogiczna Funkcja odczytu: bool Open(char *filename) { FILE* plik = fopen(filename,"rb"); if(!plik) return false; fread(&num_pts, sizeof(int), 1, plik); fread(points, sizeof(sPoint), num_pts, plik); fread(&num_walls,sizeof(int), 1, plik); fread(walls, sizeof(sWall), num_walls, plik); fclose(plik); return true; } bardzo proszę o pomoc i ewentualną lekturę
Wed,19 Nov 2008 02:28:05 +0100
Witam wszystkich forumowiczow. Mam taki problem z zadaniem. Dopiero ucze sie JAVY i mam do zrobienia pewien program. W sumie wiekszosc juz mam, ale nie wiem jak zrobic jedna rzecz. A mianowicie jak w ponizszym fragmencie kodu zrobic tak, aby wybor case2 realizowal funkcje UstawMiasto(). Chodzi mi o to, aby wybierajac case2 (auto w drodze) byla realizowana metoda wyboru miasta, do ktorego toretycznie jedzie auto. void RuchSamochod() { String m_polozenie; System.out.println("Czy Samochod aktualnie jest:n"); System.out.println("1- zaparkowanyn"); System.out.println("2- w drodzen"); switch(m_polozenie) { case 1: System.out.println("Samochod odpoczywa na parkingu.n"); case 2: void UstamMiasto(); } void UstamMiasto() { InputStreamReader czytacz_strumienia = new InputStreamReader(System.in); BufferedReader czytacz = new BufferedReader(czytacz_strumienia); try { System.out.println("Podaj gdzie jedzie samochod: "); String polozenie = czytacz.readLine(); m_polozenie = polozenie; } catch(IOException e) { System.out.println("Blad podczas odczytu danych"); } } } Po realizacji tej funkcji tworzone sa obiekty, gdzie na ekranie beda podawane ich parametry, a takze info o polozeniu samochodu. Z góry dziękuję. Pozdro
Wed,19 Nov 2008 02:01:45 +0100
Witam wszystkich Moglby ktos w latwy i przejrzysty sposob wytlomaczyc na czym polega przeciążanie operatorów. Podac kilka latwych przykladów!!! Z góry
Wed,19 Nov 2008 01:53:27 +0100
Witam Mam taki problem, w moim programie chciałbym aby przy zmianie zakladki w JTabbedPane zostało wysłane zapytanie SQL do bazy a rezultat pokazany np w jtable znajdującym sie w tej zakladce. W klasie obslugujacej baze jest funkcja: public boolean pokazZajeciaPoDniach(int dzien) { try { PreparedStatement pstmt = con.prepareStatement("SELECT * FROM lista_zajec WHERE dzien = ?"); pstmt.setInt(1, dzien); ResultSet rs = pstmt.executeQuery(); while (rs.next()){ int rok = rs.getInt("rocznik"); int przedmiot = rs.getInt("przedmiot"); int rodz_zajec = rs.getInt("rodz_zajec"); int grupa = rs.getInt("grupa"); int sala = rs.getInt("sala"); String czas_rozp = rs.getString("czas_rozp"); String czas_zak = rs.getString("czas_zak"); int _dzien = rs.getInt("dzien"); System.out.println(rok + " " + przedmiot + " " + rodz_zajec + " " +grupa+ " "+sala+" "+czas_rozp+" "+czas_zak+" "+ _dzien ); } } catch(SQLException e) { System.out.println("Błąd SQL: "+ e.getMessage()); return false; } return true; } Chciałbym ją wywołać z klasy głównej tak aby została wywolana przy zmianie zakladki jtabbedpane: ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource(); int index = sourceTabbedPane.getSelectedIndex(); System.out.println("Tab changed to: " + sourceTabbedPane.getSelectedIndex()); int i =sourceTabbedPane.getSelectedIndex(); i++; System.out.println("Index odpowiadający w bazie to " + i); baza.pokazZajeciaPoDniach(i); } }; próba wywyłania metody dla obiektu baza kończy się Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Dlaczego? Pozdrawiam
Wed,19 Nov 2008 00:37:24 +0100
Tak powiem krótko i na temat :P. Mianowicie robię gierke, w której odtwarzana jest muzyka w komponencie TMediaPlayer. I jest opcja, że muzyka jest odtwarzana losowo. Ale gdy wylosowal następną piosenke jak ją puszcza to jest takie jakby 'zacięcie programu' na chwile. dzieje się to przez funkcje MediaPlayer->Open(); A jeżeli jej nie użyje, to nie odczyta nastepnej piosenki, tylko bedzie powtarzał tą co byla wczytana na początku. I czy jest jakiś sposób, aby te takie zacięcie programu zlikwidowac? bo bardzo przeszkadza w grze... I SZUKALEM JUZ NA GOOGLE.! Prosze o pomoc....
Wed,19 Nov 2008 00:27:57 +0100
VIII. PHP bytecode Compiler
Wstęp
| Ostrzeżenie |
Ten moduł jest w stadium EKSPERYMENTALNYM. Oznacza to, że zachowanie tych funkcji, ich nazwy, w zasadzie wszystko udokumentowane tutaj może zostać zmienione w przyszłych wersjach PHP bez wcześniejszego uprzedzenia. Używaj tego modułu na własne ryzyko. |
Bcompiler was written for several reasons:
| To encode entire script in a proprietary PHP application |
| To encode some classes and/or functions in a proprietary PHP application |
| To enable the production of php-gtk applications that could be used on client desktops, without the need for a php.exe. |
| To do the feasibility study for a PHP to C converter |
The second of these goals is achieved using the bcompiler_write_header(), bcompiler_write_class(), bcompiler_write_footer(), bcompiler_read(), and bcompiler_load() functions. The bytecode files can be written as either uncompressed or plain. The bcompiler_load() reads a bzip compressed bytecode file, which tends to be 1/3 of the size of the original file.
To create EXE type files, bcompiler has to be used with a modified sapi file or a version of PHP which has been compiled as a shared library. In this scenario, bcompiler reads the compressed bytecode from the end of the exe file.
bcompiler can improve performance by about 30% when used with uncompressed bytecodes only. But keep in mind that uncompressed bytecode can be up to 5 times larger than the original source code. Using bytecode compression can save your space, but decompression requires much more time than parsing a source. bcompiler also does not do any bytecode optimization, this could be added in the future...
In terms of code protection, it is safe to say that it would be impossible to recreate the exact source code that it was built from, and without the accompanying source code comments. It would effectively be useless to use the bcompiler bytecodes to recreate and modify a class. However it is possible to retrieve data from a bcompiled bytecode file - so don't put your private passwords or anything in it.
Instalacja
short installation note:
You need at least PHP 4.3.0 for the compression to work
To install on PHP 4.3.0 and later at the Unix command prompt type pear install bcompiler
To install on Windows, until the binary package distribution mechanism is finished please search the archives of the pear-general mailing list for pre-built packages. (or send an email to it if you could not find a reference)
To install on older versions you need to make some slight changes to the build.
untar the bcompiler.tgz archive into php4/ext.(Get it directly from PECL http://pecl.php.net/get/bcompiler)
If the new directory is now called something like bcompiler-0.x, then you should rename it to bcompiler (except you only want to build it as self-contained php-module).
If you are using versions before PHP 4.3.0, the you will need to copy the Makefile.in.old to Makefile.in and config.m4.old to config.m4.
run phpize in ext/bcompiler
run ./buildconf in php4
run configure with
--enable-bcompiler(and your other options)make; make install
that's it.
Contact Information
If you have comments, bugfixes, enhancements or want to help developing this beast, you can drop me a mail at alan_k@php.net. Any help is very welcome.
- Spis treści
- bcompiler_load_exe -- Reads and creates classes from a bcompiler exe file
- bcompiler_load -- Reads and creates classes from a bz compressed file
- bcompiler_parse_class -- Reads the bytecodes of a class and calls back to a user function
- bcompiler_read -- Reads and creates classes from a filehandle
- bcompiler_write_class -- Writes an defined class as bytecodes
- bcompiler_write_constant -- Writes a defined constant as bytecodes
- bcompiler_write_exe_footer -- Writes the start pos, and sig to the end of a exe type file
- bcompiler_write_file -- Writes a php source file as bytecodes
- bcompiler_write_footer -- Writes the single character \x00 to indicate End of compiled data
- bcompiler_write_function -- Writes an defined function as bytecodes
- bcompiler_write_functions_from_file -- Writes all functions defined in a file as bytecodes
- bcompiler_write_header -- Writes the bcompiler header
- bcompiler_write_included_filename -- Writes an included file as bytecodes
| Poprzedni | Spis treści | Następny |
| bcsub | Początek rozdziału | bcompiler_load_exe |