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
XIV. ClibPDF Functions
Wstęp
ClibPDF lets you create PDF documents with PHP. ClibPDF functionality and API are similar to PDFlib. This documentation should be read alongside the ClibPDF manual since it explains the library in much greater detail.
Many functions in the native ClibPDF and the PHP module, as well as in PDFlib, have the same name. All functions except for cpdf_open() take the handle for the document as their first parameter.
Currently this handle is not used internally since ClibPDF does not support the creation of several PDF documents at the same time. Actually, you should not even try it, the results are unpredictable. I can't oversee what the consequences in a multi threaded environment are. According to the author of ClibPDF this will change in one of the next releases (current version when this was written is 1.10). If you need this functionality use the pdflib module.
A nice feature of ClibPDF (and PDFlib) is the ability to create the pdf document completely in memory without using temporary files. It also provides the ability to pass coordinates in a predefined unit length. (This feature can also be simulated by pdf_translate() when using the PDFlib functions.)
Another nice feature of ClibPDF is the fact that any page can be modified at any time even if a new page has been already opened. The function cpdf_set_current_page() allows to leave the current page and presume modifying an other page.
Most of the functions are fairly easy to use. The most difficult part is probably creating a very simple PDF document at all. The following example should help you to get started. It creates a document with one page. The page contains the text "Times-Roman" in an outlined 30pt font. The text is underlined.
Notatka: To rozszerzenie zostało przeniesione do repozytorium PECL i nie jest rozprowadzane z PHP od wersji 5.1.0.
Notatka: If you're interested in alternative free PDF generators that do not utilize external PDF libraries, see this related FAQ.
Wymagania
In order to use the ClibPDF functions you need to install the ClibPDF package. It is available for download from FastIO, but requires that you purchase a license for commercial use. PHP requires that you use cpdflib >= 2.
Instalacja
To get these functions to work, you have to compile PHP with
--with-cpdflib[=DIR]. DIR is the cpdflib
install directory, defaults to /usr. In addition you
can specify the jpeg library and the tiff library for ClibPDF to use. To do
so add to your configure line the options
--with-jpeg-dir[=DIR]
--with-tiff-dir[=DIR].
Konfiguracja uruchomieniowa
To rozszerzenie nie definiuje posiada żadnych dyrektyw konfiguracyjnych w pliku php.ini.
Stałe predefiniowane
Poniższe stałe są zdefiniowane w tym rozszerzeniu i stają się dostępne, gdy rozszerzenie jest dokompilowane do PHP, lub załadowane dynamicznie przy starcie.
Przykłady
The pdflib distribution contains a more complex example which creates a series of pages with an analog clock. Here is that example converted into PHP using the ClibPDF extension:
Przykład 2. pdfclock example from pdflib 2.0 distribution
|
Patrz także
See also the PDFlib extension documentation.
- Spis treści
- cpdf_add_annotation -- Adds annotation
- cpdf_add_outline -- Adds bookmark for current page
- cpdf_arc -- Draws an arc
- cpdf_begin_text -- Starts text section
- cpdf_circle -- Draw a circle
- cpdf_clip -- Clips to current path
- cpdf_close -- Closes the pdf document
- cpdf_closepath_fill_stroke -- Close, fill and stroke current path
- cpdf_closepath_stroke -- Close path and draw line along path
- cpdf_closepath -- Close path
- cpdf_continue_text -- Output text in next line
- cpdf_curveto -- Draws a curve
- cpdf_end_text -- Ends text section
- cpdf_fill_stroke -- Fill and stroke current path
- cpdf_fill -- Fill current path
- cpdf_finalize_page -- Ends page
- cpdf_finalize -- Ends document
- cpdf_global_set_document_limits -- Sets document limits for any pdf document
- cpdf_import_jpeg -- Opens a JPEG image
- cpdf_lineto -- Draws a line
- cpdf_moveto -- Sets current point
- cpdf_newpath -- Starts a new path
- cpdf_open -- Opens a new pdf document
- cpdf_output_buffer -- Outputs the pdf document in memory buffer
- cpdf_page_init -- Starts new page
- cpdf_place_inline_image -- Places an image on the page
- cpdf_rect -- Draw a rectangle
- cpdf_restore -- Restores formerly saved environment
- cpdf_rlineto -- Draws a line
- cpdf_rmoveto -- Sets current point
- cpdf_rotate_text -- Sets text rotation angle
- cpdf_rotate -- Sets rotation
- cpdf_save_to_file -- Writes the pdf document into a file
- cpdf_save -- Saves current environment
- cpdf_scale -- Sets scaling
- cpdf_set_action_url -- Sets hyperlink
- cpdf_set_char_spacing -- Sets character spacing
- cpdf_set_creator -- Sets the creator field in the pdf document
- cpdf_set_current_page -- Sets current page
- cpdf_set_font_directories -- Sets directories to search when using external fonts
- cpdf_set_font_map_file -- Sets fontname to filename translation map when using external fonts
- cpdf_set_font -- Select the current font face and size
- cpdf_set_horiz_scaling -- Sets horizontal scaling of text
- cpdf_set_keywords -- Sets the keywords field of the pdf document
- cpdf_set_leading -- Sets distance between text lines
- cpdf_set_page_animation -- Sets duration between pages
- cpdf_set_subject -- Sets the subject field of the pdf document
- cpdf_set_text_matrix -- Sets the text matrix
- cpdf_set_text_pos -- Sets text position
- cpdf_set_text_rendering -- Determines how text is rendered
- cpdf_set_text_rise -- Sets the text rise
- cpdf_set_title -- Sets the title field of the pdf document
- cpdf_set_viewer_preferences -- How to show the document in the viewer
- cpdf_set_word_spacing -- Sets spacing between words
- cpdf_setdash -- Sets dash pattern
- cpdf_setflat -- Sets flatness
- cpdf_setgray_fill -- Sets filling color to gray value
- cpdf_setgray_stroke -- Sets drawing color to gray value
- cpdf_setgray -- Sets drawing and filling color to gray value
- cpdf_setlinecap -- Sets linecap parameter
- cpdf_setlinejoin -- Sets linejoin parameter
- cpdf_setlinewidth -- Sets line width
- cpdf_setmiterlimit -- Sets miter limit
- cpdf_setrgbcolor_fill -- Sets filling color to rgb color value
- cpdf_setrgbcolor_stroke -- Sets drawing color to rgb color value
- cpdf_setrgbcolor -- Sets drawing and filling color to rgb color value
- cpdf_show_xy -- Output text at position
- cpdf_show -- Output text at current position
- cpdf_stringwidth -- Returns width of text in current font
- cpdf_stroke -- Draw line along path
- cpdf_text -- Output text with parameters
- cpdf_translate -- Sets origin of coordinate system
| Poprzedni | Spis treści | Następny |
| classkit_method_rename | Początek rozdziału | cpdf_add_annotation |