From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../source/text/sbasic/shared/00000002.xhp | 63 + .../source/text/sbasic/shared/00000003.xhp | 352 ++++ .../source/text/sbasic/shared/01/06130000.xhp | 80 + .../source/text/sbasic/shared/01/06130100.xhp | 42 + .../source/text/sbasic/shared/01/06130500.xhp | 49 + .../source/text/sbasic/shared/01000000.xhp | 44 + .../source/text/sbasic/shared/01010210.xhp | 58 + .../source/text/sbasic/shared/01020000.xhp | 44 + .../source/text/sbasic/shared/01020100.xhp | 266 +++ .../source/text/sbasic/shared/01020200.xhp | 46 + .../source/text/sbasic/shared/01020300.xhp | 169 ++ .../source/text/sbasic/shared/01020500.xhp | 49 + .../source/text/sbasic/shared/01030000.xhp | 46 + .../source/text/sbasic/shared/01030100.xhp | 45 + .../source/text/sbasic/shared/01030200.xhp | 83 + .../source/text/sbasic/shared/01030300.xhp | 63 + .../source/text/sbasic/shared/01030400.xhp | 211 ++ .../source/text/sbasic/shared/01040000.xhp | 255 +++ .../source/text/sbasic/shared/01050000.xhp | 65 + .../source/text/sbasic/shared/01050100.xhp | 60 + .../source/text/sbasic/shared/01050200.xhp | 39 + .../source/text/sbasic/shared/01050300.xhp | 58 + .../source/text/sbasic/shared/01170100.xhp | 104 + .../source/text/sbasic/shared/01170101.xhp | 440 +++++ .../source/text/sbasic/shared/01170103.xhp | 66 + .../source/text/sbasic/shared/02/11010000.xhp | 58 + .../source/text/sbasic/shared/02/11020000.xhp | 55 + .../source/text/sbasic/shared/02/11030000.xhp | 54 + .../source/text/sbasic/shared/02/11040000.xhp | 57 + .../source/text/sbasic/shared/02/11050000.xhp | 58 + .../source/text/sbasic/shared/02/11060000.xhp | 58 + .../source/text/sbasic/shared/02/11070000.xhp | 53 + .../source/text/sbasic/shared/02/11080000.xhp | 56 + .../source/text/sbasic/shared/02/11090000.xhp | 61 + .../source/text/sbasic/shared/02/11100000.xhp | 55 + .../source/text/sbasic/shared/02/11110000.xhp | 55 + .../source/text/sbasic/shared/02/11120000.xhp | 55 + .../source/text/sbasic/shared/02/11140000.xhp | 55 + .../source/text/sbasic/shared/02/11150000.xhp | 54 + .../source/text/sbasic/shared/02/11160000.xhp | 55 + .../source/text/sbasic/shared/02/11170000.xhp | 54 + .../source/text/sbasic/shared/02/11180000.xhp | 63 + .../source/text/sbasic/shared/02/11190000.xhp | 51 + .../source/text/sbasic/shared/02/20000000.xhp | 474 +++++ .../source/text/sbasic/shared/03/avail_release.xhp | 52 + .../text/sbasic/shared/03/lib_ScriptForge.xhp | 247 +++ .../source/text/sbasic/shared/03/lib_depot.xhp | 28 + .../source/text/sbasic/shared/03/lib_euro.xhp | 46 + .../text/sbasic/shared/03/lib_formwizard.xhp | 28 + .../source/text/sbasic/shared/03/lib_gimmicks.xhp | 51 + .../source/text/sbasic/shared/03/lib_importwiz.xhp | 44 + .../source/text/sbasic/shared/03/lib_schedule.xhp | 30 + .../source/text/sbasic/shared/03/lib_script.xhp | 35 + .../source/text/sbasic/shared/03/lib_template.xhp | 28 + .../source/text/sbasic/shared/03/lib_tools.xhp | 842 ++++++++ .../text/sbasic/shared/03/lib_wikieditor.xhp | 30 + .../source/text/sbasic/shared/03/sf_array.xhp | 968 ++++++++++ .../source/text/sbasic/shared/03/sf_base.xhp | 372 ++++ .../source/text/sbasic/shared/03/sf_basic.xhp | 659 +++++++ .../source/text/sbasic/shared/03/sf_calc.xhp | 2031 ++++++++++++++++++++ .../source/text/sbasic/shared/03/sf_chart.xhp | 504 +++++ .../source/text/sbasic/shared/03/sf_database.xhp | 404 ++++ .../source/text/sbasic/shared/03/sf_dialog.xhp | 681 +++++++ .../text/sbasic/shared/03/sf_dialogcontrol.xhp | 1273 ++++++++++++ .../source/text/sbasic/shared/03/sf_dictionary.xhp | 523 +++++ .../source/text/sbasic/shared/03/sf_document.xhp | 729 +++++++ .../source/text/sbasic/shared/03/sf_exception.xhp | 459 +++++ .../source/text/sbasic/shared/03/sf_filesystem.xhp | 1129 +++++++++++ .../source/text/sbasic/shared/03/sf_form.xhp | 841 ++++++++ .../text/sbasic/shared/03/sf_formcontrol.xhp | 1173 +++++++++++ .../source/text/sbasic/shared/03/sf_intro.xhp | 181 ++ .../source/text/sbasic/shared/03/sf_l10n.xhp | 375 ++++ .../source/text/sbasic/shared/03/sf_menu.xhp | 324 ++++ .../source/text/sbasic/shared/03/sf_methods.xhp | 211 ++ .../source/text/sbasic/shared/03/sf_platform.xhp | 412 ++++ .../source/text/sbasic/shared/03/sf_popupmenu.xhp | 348 ++++ .../source/text/sbasic/shared/03/sf_region.xhp | 605 ++++++ .../source/text/sbasic/shared/03/sf_services.xhp | 107 ++ .../source/text/sbasic/shared/03/sf_session.xhp | 693 +++++++ .../source/text/sbasic/shared/03/sf_string.xhp | 1501 +++++++++++++++ .../source/text/sbasic/shared/03/sf_textstream.xhp | 376 ++++ .../source/text/sbasic/shared/03/sf_timer.xhp | 315 +++ .../source/text/sbasic/shared/03/sf_ui.xhp | 704 +++++++ .../source/text/sbasic/shared/03/sf_unittest.xhp | 818 ++++++++ .../source/text/sbasic/shared/03/sf_writer.xhp | 189 ++ .../source/text/sbasic/shared/03000000.xhp | 50 + .../source/text/sbasic/shared/03010000.xhp | 41 + .../source/text/sbasic/shared/03010100.xhp | 43 + .../source/text/sbasic/shared/03010101.xhp | 227 +++ .../source/text/sbasic/shared/03010102.xhp | 156 ++ .../source/text/sbasic/shared/03010103.xhp | 97 + .../source/text/sbasic/shared/03010200.xhp | 41 + .../source/text/sbasic/shared/03010201.xhp | 69 + .../source/text/sbasic/shared/03010300.xhp | 43 + .../source/text/sbasic/shared/03010301.xhp | 69 + .../source/text/sbasic/shared/03010302.xhp | 68 + .../source/text/sbasic/shared/03010303.xhp | 72 + .../source/text/sbasic/shared/03010304.xhp | 80 + .../source/text/sbasic/shared/03010305.xhp | 81 + .../source/text/sbasic/shared/03010306.xhp | 68 + .../source/text/sbasic/shared/03020000.xhp | 47 + .../source/text/sbasic/shared/03020100.xhp | 41 + .../source/text/sbasic/shared/03020101.xhp | 60 + .../source/text/sbasic/shared/03020102.xhp | 64 + .../source/text/sbasic/shared/03020103.xhp | 128 ++ .../source/text/sbasic/shared/03020104.xhp | 81 + .../source/text/sbasic/shared/03020200.xhp | 46 + .../source/text/sbasic/shared/03020201.xhp | 125 ++ .../source/text/sbasic/shared/03020202.xhp | 90 + .../source/text/sbasic/shared/03020203.xhp | 61 + .../source/text/sbasic/shared/03020204.xhp | 66 + .../source/text/sbasic/shared/03020205.xhp | 103 + .../source/text/sbasic/shared/03020301.xhp | 66 + .../source/text/sbasic/shared/03020302.xhp | 54 + .../source/text/sbasic/shared/03020303.xhp | 63 + .../source/text/sbasic/shared/03020304.xhp | 52 + .../source/text/sbasic/shared/03020305.xhp | 61 + .../source/text/sbasic/shared/03020400.xhp | 56 + .../source/text/sbasic/shared/03020401.xhp | 77 + .../source/text/sbasic/shared/03020402.xhp | 66 + .../source/text/sbasic/shared/03020403.xhp | 78 + .../source/text/sbasic/shared/03020404.xhp | 85 + .../source/text/sbasic/shared/03020405.xhp | 89 + .../source/text/sbasic/shared/03020406.xhp | 62 + .../source/text/sbasic/shared/03020407.xhp | 61 + .../source/text/sbasic/shared/03020408.xhp | 64 + .../source/text/sbasic/shared/03020409.xhp | 171 ++ .../source/text/sbasic/shared/03020410.xhp | 63 + .../source/text/sbasic/shared/03020411.xhp | 104 + .../source/text/sbasic/shared/03020412.xhp | 65 + .../source/text/sbasic/shared/03020413.xhp | 71 + .../source/text/sbasic/shared/03020414.xhp | 122 ++ .../source/text/sbasic/shared/03020415.xhp | 64 + .../source/text/sbasic/shared/03030000.xhp | 44 + .../source/text/sbasic/shared/03030100.xhp | 53 + .../source/text/sbasic/shared/03030101.xhp | 69 + .../source/text/sbasic/shared/03030102.xhp | 73 + .../source/text/sbasic/shared/03030103.xhp | 62 + .../source/text/sbasic/shared/03030104.xhp | 62 + .../source/text/sbasic/shared/03030105.xhp | 194 ++ .../source/text/sbasic/shared/03030106.xhp | 62 + .../source/text/sbasic/shared/03030107.xhp | 62 + .../source/text/sbasic/shared/03030108.xhp | 60 + .../source/text/sbasic/shared/03030110.xhp | 157 ++ .../source/text/sbasic/shared/03030111.xhp | 63 + .../source/text/sbasic/shared/03030112.xhp | 63 + .../source/text/sbasic/shared/03030113.xhp | 63 + .../source/text/sbasic/shared/03030114.xhp | 63 + .../source/text/sbasic/shared/03030115.xhp | 62 + .../source/text/sbasic/shared/03030116.xhp | 62 + .../source/text/sbasic/shared/03030120.xhp | 186 ++ .../source/text/sbasic/shared/03030130.xhp | 63 + .../source/text/sbasic/shared/03030200.xhp | 49 + .../source/text/sbasic/shared/03030201.xhp | 56 + .../source/text/sbasic/shared/03030202.xhp | 58 + .../source/text/sbasic/shared/03030203.xhp | 62 + .../source/text/sbasic/shared/03030204.xhp | 65 + .../source/text/sbasic/shared/03030205.xhp | 76 + .../source/text/sbasic/shared/03030206.xhp | 78 + .../source/text/sbasic/shared/03030300.xhp | 44 + .../source/text/sbasic/shared/03030301.xhp | 54 + .../source/text/sbasic/shared/03030302.xhp | 53 + .../source/text/sbasic/shared/03030303.xhp | 69 + .../source/text/sbasic/shared/03040000.xhp | 618 ++++++ .../source/text/sbasic/shared/03050000.xhp | 45 + .../source/text/sbasic/shared/03050100.xhp | 70 + .../source/text/sbasic/shared/03050200.xhp | 66 + .../source/text/sbasic/shared/03050300.xhp | 55 + .../source/text/sbasic/shared/03050500.xhp | 86 + .../source/text/sbasic/shared/03060000.xhp | 53 + .../source/text/sbasic/shared/03060100.xhp | 68 + .../source/text/sbasic/shared/03060200.xhp | 67 + .../source/text/sbasic/shared/03060300.xhp | 67 + .../source/text/sbasic/shared/03060400.xhp | 66 + .../source/text/sbasic/shared/03060500.xhp | 67 + .../source/text/sbasic/shared/03060600.xhp | 67 + .../source/text/sbasic/shared/03070000.xhp | 53 + .../source/text/sbasic/shared/03070100.xhp | 66 + .../source/text/sbasic/shared/03070200.xhp | 66 + .../source/text/sbasic/shared/03070300.xhp | 66 + .../source/text/sbasic/shared/03070400.xhp | 66 + .../source/text/sbasic/shared/03070500.xhp | 60 + .../source/text/sbasic/shared/03070600.xhp | 83 + .../source/text/sbasic/shared/03070700.xhp | 53 + .../source/text/sbasic/shared/03080000.xhp | 48 + .../source/text/sbasic/shared/03080100.xhp | 44 + .../source/text/sbasic/shared/03080101.xhp | 76 + .../source/text/sbasic/shared/03080102.xhp | 79 + .../source/text/sbasic/shared/03080103.xhp | 81 + .../source/text/sbasic/shared/03080104.xhp | 81 + .../source/text/sbasic/shared/03080200.xhp | 42 + .../source/text/sbasic/shared/03080201.xhp | 64 + .../source/text/sbasic/shared/03080202.xhp | 66 + .../source/text/sbasic/shared/03080300.xhp | 42 + .../source/text/sbasic/shared/03080301.xhp | 74 + .../source/text/sbasic/shared/03080302.xhp | 76 + .../source/text/sbasic/shared/03080400.xhp | 41 + .../source/text/sbasic/shared/03080401.xhp | 65 + .../source/text/sbasic/shared/03080500.xhp | 43 + .../source/text/sbasic/shared/03080501.xhp | 64 + .../source/text/sbasic/shared/03080502.xhp | 66 + .../source/text/sbasic/shared/03080503.xhp | 47 + .../source/text/sbasic/shared/03080600.xhp | 41 + .../source/text/sbasic/shared/03080601.xhp | 67 + .../source/text/sbasic/shared/03080700.xhp | 41 + .../source/text/sbasic/shared/03080701.xhp | 100 + .../source/text/sbasic/shared/03080800.xhp | 42 + .../source/text/sbasic/shared/03080801.xhp | 78 + .../source/text/sbasic/shared/03080802.xhp | 62 + .../source/text/sbasic/shared/03090000.xhp | 45 + .../source/text/sbasic/shared/03090100.xhp | 43 + .../source/text/sbasic/shared/03090101.xhp | 98 + .../source/text/sbasic/shared/03090102.xhp | 85 + .../source/text/sbasic/shared/03090103.xhp | 67 + .../source/text/sbasic/shared/03090200.xhp | 43 + .../source/text/sbasic/shared/03090201.xhp | 102 + .../source/text/sbasic/shared/03090202.xhp | 123 ++ .../source/text/sbasic/shared/03090203.xhp | 72 + .../source/text/sbasic/shared/03090300.xhp | 43 + .../source/text/sbasic/shared/03090301.xhp | 91 + .../source/text/sbasic/shared/03090302.xhp | 71 + .../source/text/sbasic/shared/03090303.xhp | 84 + .../source/text/sbasic/shared/03090400.xhp | 50 + .../source/text/sbasic/shared/03090401.xhp | 69 + .../source/text/sbasic/shared/03090402.xhp | 81 + .../source/text/sbasic/shared/03090403.xhp | 71 + .../source/text/sbasic/shared/03090404.xhp | 77 + .../source/text/sbasic/shared/03090405.xhp | 64 + .../source/text/sbasic/shared/03090406.xhp | 93 + .../source/text/sbasic/shared/03090407.xhp | 61 + .../source/text/sbasic/shared/03090408.xhp | 58 + .../source/text/sbasic/shared/03090409.xhp | 68 + .../source/text/sbasic/shared/03090410.xhp | 72 + .../source/text/sbasic/shared/03090411.xhp | 56 + .../source/text/sbasic/shared/03090412.xhp | 87 + .../source/text/sbasic/shared/03090413.xhp | 69 + .../source/text/sbasic/shared/03100000.xhp | 91 + .../source/text/sbasic/shared/03100050.xhp | 77 + .../source/text/sbasic/shared/03100060.xhp | 48 + .../source/text/sbasic/shared/03100070.xhp | 48 + .../source/text/sbasic/shared/03100080.xhp | 50 + .../source/text/sbasic/shared/03100100.xhp | 88 + .../source/text/sbasic/shared/03100300.xhp | 62 + .../source/text/sbasic/shared/03100400.xhp | 56 + .../source/text/sbasic/shared/03100500.xhp | 71 + .../source/text/sbasic/shared/03100600.xhp | 58 + .../source/text/sbasic/shared/03100700.xhp | 75 + .../source/text/sbasic/shared/03100900.xhp | 73 + .../source/text/sbasic/shared/03101000.xhp | 115 ++ .../source/text/sbasic/shared/03101100.xhp | 79 + .../source/text/sbasic/shared/03101110.xhp | 50 + .../source/text/sbasic/shared/03101120.xhp | 50 + .../source/text/sbasic/shared/03101130.xhp | 50 + .../source/text/sbasic/shared/03101140.xhp | 51 + .../source/text/sbasic/shared/03101300.xhp | 50 + .../source/text/sbasic/shared/03101400.xhp | 50 + .../source/text/sbasic/shared/03101500.xhp | 50 + .../source/text/sbasic/shared/03101600.xhp | 50 + .../source/text/sbasic/shared/03101700.xhp | 49 + .../source/text/sbasic/shared/03102000.xhp | 51 + .../source/text/sbasic/shared/03102100.xhp | 163 ++ .../source/text/sbasic/shared/03102101.xhp | 67 + .../source/text/sbasic/shared/03102200.xhp | 63 + .../source/text/sbasic/shared/03102300.xhp | 66 + .../source/text/sbasic/shared/03102400.xhp | 64 + .../source/text/sbasic/shared/03102450.xhp | 50 + .../source/text/sbasic/shared/03102600.xhp | 65 + .../source/text/sbasic/shared/03102700.xhp | 66 + .../source/text/sbasic/shared/03102800.xhp | 72 + .../source/text/sbasic/shared/03102900.xhp | 70 + .../source/text/sbasic/shared/03103000.xhp | 73 + .../source/text/sbasic/shared/03103100.xhp | 63 + .../source/text/sbasic/shared/03103200.xhp | 54 + .../source/text/sbasic/shared/03103300.xhp | 57 + .../source/text/sbasic/shared/03103350.xhp | 67 + .../source/text/sbasic/shared/03103400.xhp | 56 + .../source/text/sbasic/shared/03103450.xhp | 56 + .../source/text/sbasic/shared/03103500.xhp | 71 + .../source/text/sbasic/shared/03103600.xhp | 275 +++ .../source/text/sbasic/shared/03103700.xhp | 75 + .../source/text/sbasic/shared/03103800.xhp | 68 + .../source/text/sbasic/shared/03103900.xhp | 56 + .../source/text/sbasic/shared/03104000.xhp | 52 + .../source/text/sbasic/shared/03104100.xhp | 50 + .../source/text/sbasic/shared/03104200.xhp | 58 + .../source/text/sbasic/shared/03104300.xhp | 54 + .../source/text/sbasic/shared/03104400.xhp | 53 + .../source/text/sbasic/shared/03104500.xhp | 63 + .../source/text/sbasic/shared/03104600.xhp | 70 + .../source/text/sbasic/shared/03104700.xhp | 64 + .../source/text/sbasic/shared/03110100.xhp | 85 + .../source/text/sbasic/shared/03120000.xhp | 45 + .../source/text/sbasic/shared/03120100.xhp | 45 + .../source/text/sbasic/shared/03120101.xhp | 69 + .../source/text/sbasic/shared/03120102.xhp | 74 + .../source/text/sbasic/shared/03120103.xhp | 85 + .../source/text/sbasic/shared/03120104.xhp | 65 + .../source/text/sbasic/shared/03120105.xhp | 75 + .../source/text/sbasic/shared/03120111.xhp | 68 + .../source/text/sbasic/shared/03120112.xhp | 67 + .../source/text/sbasic/shared/03120200.xhp | 42 + .../source/text/sbasic/shared/03120201.xhp | 67 + .../source/text/sbasic/shared/03120202.xhp | 68 + .../source/text/sbasic/shared/03120300.xhp | 54 + .../source/text/sbasic/shared/03120301.xhp | 108 ++ .../source/text/sbasic/shared/03120302.xhp | 67 + .../source/text/sbasic/shared/03120303.xhp | 74 + .../source/text/sbasic/shared/03120304.xhp | 84 + .../source/text/sbasic/shared/03120305.xhp | 75 + .../source/text/sbasic/shared/03120306.xhp | 78 + .../source/text/sbasic/shared/03120307.xhp | 76 + .../source/text/sbasic/shared/03120308.xhp | 86 + .../source/text/sbasic/shared/03120309.xhp | 75 + .../source/text/sbasic/shared/03120310.xhp | 65 + .../source/text/sbasic/shared/03120311.xhp | 74 + .../source/text/sbasic/shared/03120312.xhp | 60 + .../source/text/sbasic/shared/03120313.xhp | 51 + .../source/text/sbasic/shared/03120314.xhp | 104 + .../source/text/sbasic/shared/03120315.xhp | 51 + .../source/text/sbasic/shared/03120400.xhp | 43 + .../source/text/sbasic/shared/03120401.xhp | 71 + .../source/text/sbasic/shared/03120402.xhp | 59 + .../source/text/sbasic/shared/03120403.xhp | 81 + .../source/text/sbasic/shared/03120411.xhp | 76 + .../source/text/sbasic/shared/03120412.xhp | 57 + .../source/text/sbasic/shared/03130000.xhp | 50 + .../source/text/sbasic/shared/03130100.xhp | 59 + .../source/text/sbasic/shared/03130500.xhp | 137 ++ .../source/text/sbasic/shared/03130600.xhp | 60 + .../source/text/sbasic/shared/03130610.xhp | 51 + .../source/text/sbasic/shared/03130700.xhp | 65 + .../source/text/sbasic/shared/03130800.xhp | 65 + .../source/text/sbasic/shared/03131000.xhp | 57 + .../source/text/sbasic/shared/03131300.xhp | 55 + .../source/text/sbasic/shared/03131400.xhp | 55 + .../source/text/sbasic/shared/03131500.xhp | 49 + .../source/text/sbasic/shared/03131600.xhp | 76 + .../source/text/sbasic/shared/03131700.xhp | 50 + .../source/text/sbasic/shared/03131800.xhp | 54 + .../source/text/sbasic/shared/03131900.xhp | 64 + .../source/text/sbasic/shared/03132000.xhp | 131 ++ .../source/text/sbasic/shared/03132100.xhp | 56 + .../source/text/sbasic/shared/03132200.xhp | 67 + .../source/text/sbasic/shared/03132300.xhp | 47 + .../source/text/sbasic/shared/03132400.xhp | 59 + .../source/text/sbasic/shared/03132500.xhp | 41 + .../source/text/sbasic/shared/03140000.xhp | 71 + .../source/text/sbasic/shared/03140001.xhp | 72 + .../source/text/sbasic/shared/03140002.xhp | 73 + .../source/text/sbasic/shared/03140003.xhp | 73 + .../source/text/sbasic/shared/03140004.xhp | 74 + .../source/text/sbasic/shared/03140005.xhp | 74 + .../source/text/sbasic/shared/03140006.xhp | 77 + .../source/text/sbasic/shared/03140007.xhp | 76 + .../source/text/sbasic/shared/03140008.xhp | 82 + .../source/text/sbasic/shared/03140009.xhp | 76 + .../source/text/sbasic/shared/03140010.xhp | 77 + .../source/text/sbasic/shared/03140011.xhp | 72 + .../source/text/sbasic/shared/03140012.xhp | 74 + .../source/text/sbasic/shared/03150000.xhp | 142 ++ .../source/text/sbasic/shared/03150001.xhp | 173 ++ .../source/text/sbasic/shared/03150002.xhp | 66 + .../source/text/sbasic/shared/03160000.xhp | 73 + .../source/text/sbasic/shared/03170000.xhp | 84 + .../source/text/sbasic/shared/03170010.xhp | 118 ++ .../source/text/sbasic/shared/05060700.xhp | 372 ++++ .../source/text/sbasic/shared/CallByName.xhp | 125 ++ .../source/text/sbasic/shared/Compiler_options.xhp | 49 + helpcontent2/source/text/sbasic/shared/ErrVBA.xhp | 132 ++ .../source/text/sbasic/shared/GetPathSeparator.xhp | 64 + helpcontent2/source/text/sbasic/shared/Resume.xhp | 77 + .../source/text/sbasic/shared/calc_functions.xhp | 1037 ++++++++++ .../source/text/sbasic/shared/classmodule.xhp | 63 + .../source/text/sbasic/shared/code-stubs.xhp | 58 + .../source/text/sbasic/shared/collection.xhp | 191 ++ .../text/sbasic/shared/compatibilitymode.xhp | 92 + .../source/text/sbasic/shared/compatible.xhp | 63 + .../source/text/sbasic/shared/conventions.xhp | 70 + helpcontent2/source/text/sbasic/shared/enum.xhp | 70 + .../source/text/sbasic/shared/fragments.xhp | 70 + .../source/text/sbasic/shared/is_keyword.xhp | 71 + helpcontent2/source/text/sbasic/shared/keys.xhp | 110 ++ .../source/text/sbasic/shared/main0211.xhp | 76 + .../source/text/sbasic/shared/main0601.xhp | 79 + .../source/text/sbasic/shared/new_keyword.xhp | 78 + .../source/text/sbasic/shared/partition.xhp | 60 + .../source/text/sbasic/shared/property.xhp | 127 ++ helpcontent2/source/text/sbasic/shared/replace.xhp | 62 + .../source/text/sbasic/shared/special_vba_func.xhp | 121 ++ .../source/text/sbasic/shared/stardesktop.xhp | 38 + helpcontent2/source/text/sbasic/shared/strconv.xhp | 181 ++ .../source/text/sbasic/shared/thisdbdoc.xhp | 52 + .../source/text/sbasic/shared/uno_objects.xhp | 59 + .../source/text/sbasic/shared/vbasupport.xhp | 54 + 394 files changed, 48696 insertions(+) create mode 100644 helpcontent2/source/text/sbasic/shared/00000002.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/00000003.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01/06130000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01/06130100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01/06130500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01000000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01010210.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01020000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01020100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01020200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01020300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01020500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01030000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01030100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01030200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01030300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01030400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01040000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01050000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01050100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01050200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01050300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01170100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01170101.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/01170103.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11010000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11020000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11030000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11040000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11050000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11060000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11070000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11080000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11090000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11100000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11110000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11120000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11140000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11150000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11160000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11170000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11180000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/11190000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/02/20000000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/avail_release.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_ScriptForge.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_depot.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_euro.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_formwizard.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_gimmicks.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_importwiz.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_schedule.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_script.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_template.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_tools.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/lib_wikieditor.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_array.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_base.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_basic.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_calc.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_chart.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_database.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_dialog.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_dialogcontrol.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_dictionary.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_document.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_exception.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_form.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_formcontrol.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_intro.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_l10n.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_menu.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_methods.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_platform.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_popupmenu.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_region.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_services.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_session.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_string.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_textstream.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_timer.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_ui.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_unittest.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03/sf_writer.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03000000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010101.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010102.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010103.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010201.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010301.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010302.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010303.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010304.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010305.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03010306.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020101.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020102.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020103.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020104.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020201.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020202.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020203.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020204.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020205.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020301.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020302.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020303.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020304.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020305.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020401.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020402.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020403.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020404.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020405.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020406.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020407.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020408.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020409.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020410.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020411.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020412.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020413.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020414.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03020415.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030101.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030102.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030103.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030104.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030105.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030106.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030107.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030108.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030110.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030111.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030112.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030113.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030114.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030115.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030116.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030120.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030130.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030201.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030202.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030203.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030204.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030205.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030206.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030301.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030302.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03030303.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03040000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03050000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03050100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03050200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03050300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03050500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03060000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03060100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03060200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03060300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03060400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03060500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03060600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03070000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03070100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03070200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03070300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03070400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03070500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03070600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03070700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080101.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080102.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080103.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080104.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080201.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080202.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080301.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080302.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080401.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080501.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080502.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080503.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080601.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080701.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080800.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080801.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03080802.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090101.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090102.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090103.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090201.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090202.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090203.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090301.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090302.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090303.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090401.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090402.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090403.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090404.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090405.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090406.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090407.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090408.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090409.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090410.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090411.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090412.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03090413.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100050.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100060.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100070.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100080.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03100900.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101110.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101120.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101130.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101140.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03101700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102101.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102450.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102800.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03102900.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103350.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103450.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103800.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03103900.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03104000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03104100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03104200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03104300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03104400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03104500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03104600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03104700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03110100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120101.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120102.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120103.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120104.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120105.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120111.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120112.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120201.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120202.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120301.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120302.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120303.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120304.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120305.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120306.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120307.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120308.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120309.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120310.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120311.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120312.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120313.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120314.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120315.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120401.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120402.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120403.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120411.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03120412.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03130000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03130100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03130500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03130600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03130610.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03130700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03130800.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03131000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03131300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03131400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03131500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03131600.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03131700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03131800.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03131900.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03132000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03132100.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03132200.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03132300.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03132400.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03132500.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140001.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140002.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140003.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140004.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140005.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140006.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140007.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140008.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140009.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140010.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140011.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03140012.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03150000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03150001.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03150002.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03160000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03170000.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/03170010.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/05060700.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/CallByName.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/Compiler_options.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/ErrVBA.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/GetPathSeparator.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/Resume.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/calc_functions.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/classmodule.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/code-stubs.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/collection.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/compatibilitymode.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/compatible.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/conventions.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/enum.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/fragments.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/is_keyword.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/keys.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/main0211.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/main0601.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/new_keyword.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/partition.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/property.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/replace.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/special_vba_func.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/stardesktop.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/strconv.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/thisdbdoc.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/uno_objects.xhp create mode 100644 helpcontent2/source/text/sbasic/shared/vbasupport.xhp (limited to 'helpcontent2/source/text/sbasic/shared') diff --git a/helpcontent2/source/text/sbasic/shared/00000002.xhp b/helpcontent2/source/text/sbasic/shared/00000002.xhp new file mode 100644 index 000000000..295664a71 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/00000002.xhp @@ -0,0 +1,63 @@ + + + + + +$[officename] Basic Glossary +/text/sbasic/shared/00000002.xhp + + +Sun Microsystems, Inc. + + + +

$[officename] Basic Glossary

+This glossary explains some technical terms that you may come across when working with $[officename] Basic. + +
+

Decimal Point

+When converting numbers, $[officename] Basic uses the locale settings of the system for determining the type of decimal and thousand separator. +The behavior has an effect on both the implicit conversion ( 1 + "2.3" = 3.3 ) as well as the function IsNumeric. +
+
+

Colors

+In $[officename] Basic, colors are treated as long integer value. The return value of color queries is also always a long integer value. When defining properties, colors can be specified using their RGB code that is converted to a long integer value using the RGB function. +
+
+

Measurement Units

+In $[officename] Basic, a method parameter or a property expecting unit information can be specified either as integer or long integer expression without a unit, or as a character string containing a unit. If no unit is passed to the method the default unit defined for the active document type will be used. If the parameter is passed as a character string containing a measurement unit, the default setting will be ignored. The default measurement unit for a document type can be set under %PRODUCTNAME - PreferencesTools - Options - (Document Type) - General. +
+
+twips; definition + +

Twips

+A twip is a screen-independent unit which is used to define the uniform position and size of screen elements on all display systems. A twip is 1/1440th of an inch or 1/20 of a printer's point. There are 1440 twips to an inch or about 567 twips to a centimeter. +
+
+

URL Notation

+URLs (Uniform Resource Locators) are used to determine the location of a resource like a file in a file system, typically inside a network environment. A URL consists of a protocol specifier, a host specifier and a file and path specifier: + +protocol://host.name/path/to/the/file.html + +The most common usage of URLs is on the internet when specifying web pages. Example for protocols are http, ftp, or file. The file protocol specifier is used when referring to a file on the local file system. +URL notation does not allow certain special characters to be used. These are either replaced by other characters or encoded. A slash (/) is used as a path separator. For example, a file referred to as C:\Users\alice\Documents\My File.odt on the local host in "Windows notation" becomes file:///C:/Users/alice/Documents/My%20File.odt in URL notation. +
+
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/00000003.xhp b/helpcontent2/source/text/sbasic/shared/00000003.xhp new file mode 100644 index 000000000..05b579478 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/00000003.xhp @@ -0,0 +1,352 @@ + + + + + + Information + /text/sbasic/shared/00000003.xhp + + + +

Information

+
+You can set the locale used for controlling the formatting numbers, dates and currencies in $[officename] Basic in %PRODUCTNAME - Preferences +Tools - Options - Language Settings - Languages. In Basic format codes, the decimal point (.) is always used as placeholder for the decimal separator defined in your locale and will be replaced by the corresponding character. +The same applies to the locale settings for date, time and currency formats. The Basic format code will be interpreted and displayed according to your locale setting. +
+
+The color values of the 16 basic colors are as follows: + + + + Color Value + + + Color Name + + + + + 0 + + + Black + + + + + 128 + + + Blue + + + + + 32768 + + + Green + + + + + 32896 + + + Cyan + + + + + 8388608 + + + Red + + + + + 8388736 + + + Magenta + + + + + 8421376 + + + Yellow + + + + + 8421504 + + + White + + + + + 12632256 + + + Gray + + + + + 255 + + + Light blue + + + + + 65280 + + + Light green + + + + + 65535 + + + Light cyan + + + + + 16711680 + + + Light red + + + + + 16711935 + + + Light magenta + + + + + 16776960 + + + Light yellow + + + + + 16777215 + + + Transparent white + + +
+
+
+ Open Tools - Macros - Organize Dialogs and select %PRODUCTNAME Dialogs container. +
+
+ Open Tools - Macros - %PRODUCTNAME Basic - Edit and select Application Macros container. +
+
+ This library must be loaded before execution. Execute the following statement before running any macro that uses this library: +
+
+ This constant, function or object is enabled with the statement Option VBASupport 1 placed before the executable program code in a module. +
+
+ This statement must be added before the executable program code in a module. +
+
+

Syntax:

+
+
+

Return value:

+
+
+

Parameters:

+
+
+

Example:

+
+
+

In Basic

+
+
+

In Python

+
+
+This method is only available for Basic scripts. +
+
+This method is only available for Python scripts. +
+
+This method requires the installation of the APSO (Alternative Script Organizer for Python) extension. In turn APSO requires the presence of %PRODUCTNAME Python scripting framework. If APSO or Python are missing, an error occurs. +
+
+This service is fully supported in both Basic and Python languages. All examples are expressed using the Basic programming language and can be easily converted to Python. +
+String functions +VBA financial functions +VBA Time and Date functions +VBA I/O functions +VBA Mathematical functions +VBA Object functions +
+

Error codes:

+
+
+1 An exception occurred +2 Syntax error +3 Return without Gosub +4 Incorrect entry; please retry +5 Invalid procedure call +6 Overflow +7 Not enough memory +8 Array already dimensioned +9 Index out of defined range +10 Duplicate definition +11 Division by zero +12 Variable not defined +13 Data type mismatch +14 Invalid parameter +18 Process interrupted by user +20 Resume without error +28 Not enough stack memory +35 Sub-procedure or function procedure not defined +48 Error loading DLL file +49 Wrong DLL call convention +51 Internal error +52 Invalid file name or file number +53 File not found +54 Incorrect file mode +55 File already open +57 Device I/O error +58 File already exists +59 Incorrect record length +61 Disk or hard drive full +62 Reading exceeds EOF +63 Incorrect record number +67 Too many files +68 Device not available +70 Access denied +71 Disk not ready +73 Not implemented +74 Renaming on different drives impossible +75 Path/file access error +76 Path not found +91 Object variable not set +93 Invalid string pattern +94 Use of zero not permitted +250 DDE Error +280 Awaiting response to DDE connection +281 No DDE channels available +282 No application responded to DDE connect initiation +283 Too many applications responded to DDE connect initiation +284 DDE channel locked +285 External application cannot execute DDE operation +286 Timeout while waiting for DDE response +287 user pressed ESCAPE during DDE operation +288 External application busy +289 DDE operation without data +290 Data are in wrong format +291 External application has been terminated +292 DDE connection interrupted or modified +293 DDE method invoked with no channel open +294 Invalid DDE link format +295 DDE message has been lost +296 Paste link already performed +297 Link mode cannot be set due to invalid link topic +298 DDE requires the DDEML.DLL file +323 Module cannot be loaded; invalid format +341 Invalid object index +366 Object is not available +380 Incorrect property value +382 This property is read-only +394 This property is write-only +420 Invalid object reference +423 Property or method not found +424 Object required +425 Invalid use of an object +430 OLE Automation is not supported by this object +438 This property or method is not supported by the object +440 OLE automation error +445 This action is not supported by given object +446 Named arguments are not supported by given object +447 The current locale setting is not supported by the given object +448 Named argument not found +449 Argument is not optional +450 Invalid number of arguments +451 Object is not a list +452 Invalid ordinal number +453 Specified DLL function not found +460 Invalid clipboard format +951 Unexpected symbol: +952 Expected: +953 Symbol expected +954 Variable expected +955 Label expected +956 Value cannot be applied +957 Variable already defined +958 Sub procedure or function procedure already defined +959 Label already defined +960 Variable not found +961 Array or procedure not found +962 Procedure not found +963 Label undefined +964 Unknown data type +965 Exit expected +966 Statement block still open: missing +967 Parentheses do not match +968 Symbol already defined differently +969 Parameters do not correspond to procedure +970 Invalid character in number +971 Array must be dimensioned +972 Else/Endif without If +973 not allowed within a procedure +974 not allowed outside a procedure +975 Dimension specifications do not match +976 Unknown option: +977 Constant redefined +978 Program too large +979 Strings or arrays not permitted +1000 Object does not have this property +1001 Object does not have this method +1002 Required argument lacking +1003 Invalid number of arguments +1004 Error executing a method +1005 Unable to set property +1006 Unable to determine property +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/01/06130000.xhp b/helpcontent2/source/text/sbasic/shared/01/06130000.xhp new file mode 100644 index 000000000..5bf476bff --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01/06130000.xhp @@ -0,0 +1,80 @@ + + + + + + + + +Macro +/text/sbasic/shared/01/06130000.xhp + + +Sun Microsystems, Inc. + + + +macros; Basic IDE +Basic IDE; macros +this file needs more work, see i62546 +Macro +Opens the Macro dialog, where you can create, edit, organize, and run $[officename] Basic macros. +Macro name +Displays the name of the selected macro. To create or to change the name of a macro, enter a name here. +Macro from / Save macro in +Lists the libraries and the modules where you can open or save your macros. To save a macro with a particular document, open the document, and then open this dialog. +Run / Save +Runs or saves the current macro. +Assign +Opens the Customize dialog, where you can assign the selected macro to a menu command, a toolbar, or an event. +Edit +Starts the $[officename] Basic editor and opens the selected macro for editing. +New/Delete +Creates a new macro, or deletes the selected macro. +To create a new macro, select the "Standard" module in the Macro from list, and then click New. +To delete a macro, select it, and then click Delete. +Organizer +Opens the Macro Organizer dialog, where you can add, edit, or delete existing macro modules, dialogs, and libraries. +Module/Dialog +Lists the existing macros and dialogs. +You can drag-and-drop a module or a dialog between libraries. +To copy a dialog or a module, hold down the CommandCtrl key while you drag-and-drop. +Edit +Opens the selected macro or dialog for editing. +New +Creates a new module. +Creates a new dialog. +Libraries tab page +Lets you manage the macro libraries. +Location +Select the location containing the macro libraries that you want to organize. +Library +Lists the macro libraries in the chosen location. +Edit +Opens the $[officename] Basic editor so that you can modify the selected library. +Password +Assigns or edits the password for the selected library. "Standard" libraries cannot have a password. +New +Creates a new library. +Name +Enter a name for the new module, dialog, or library. +Append +Locate that $[officename] Basic library that you want to add to the current list, and then click Open. + + diff --git a/helpcontent2/source/text/sbasic/shared/01/06130100.xhp b/helpcontent2/source/text/sbasic/shared/01/06130100.xhp new file mode 100644 index 000000000..3ccfab746 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01/06130100.xhp @@ -0,0 +1,42 @@ + + + + + + + + + + +Change Password +/text/sbasic/shared/01/06130100.xhp + + +Change Password +Protects the selected library with a password. You can enter a new password, or change the current password. +Old password +Password +Enter the current password for the selected library. +New password +Password +Enter a new password for the selected library. +Confirm +Repeat the new password for the selected library.i66515 + + diff --git a/helpcontent2/source/text/sbasic/shared/01/06130500.xhp b/helpcontent2/source/text/sbasic/shared/01/06130500.xhp new file mode 100644 index 000000000..d7d978604 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01/06130500.xhp @@ -0,0 +1,49 @@ + + + + + + + + + + +Append libraries +/text/sbasic/shared/01/06130500.xhp + + + + + +libraries; adding +inserting;Basic libraries + + Append libraries + Locate that %PRODUCTNAME Basic library that you want to add to the current list, and then click Open. + + + File name: + Enter a name or the path to the library that you want to append. You can also select a library from the list. + Options + Insert as reference (read-only) + Adds the selected library as a read-only file. The library is reloaded each time you start %PRODUCTNAME. + Replace existing libraries + Replaces a library that has the same name with the current library. + + diff --git a/helpcontent2/source/text/sbasic/shared/01000000.xhp b/helpcontent2/source/text/sbasic/shared/01000000.xhp new file mode 100644 index 000000000..786937634 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01000000.xhp @@ -0,0 +1,44 @@ + + + + + + + + +Programming with $[officename] Basic +/text/sbasic/shared/01000000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Programming with $[officename] Basic + This is where you find general information about working with macros and $[officename] Basic. +
+ + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/01010210.xhp b/helpcontent2/source/text/sbasic/shared/01010210.xhp new file mode 100644 index 000000000..e60bdab22 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01010210.xhp @@ -0,0 +1,58 @@ + + + + + + + + + + +Basics +/text/sbasic/shared/01010210.xhp + + + +
+fundamentals +subroutines +variables;global and local +modules;subroutines and functions +Basics +This section provides the fundamentals for working with $[officename] Basic. +
+$[officename] Basic code is based on subroutines and functions that are specified between sub...end sub and function...end function sections. Each Sub or Function can call other Subs and Functions. If you take care to write generic code for a Sub or Function, you can probably re-use it in other programs. See also Procedures and Functions. + +Some restrictions apply for the names of your public variables, subs, and functions. You must not use the same name as one of the modules of the same library. + +What is a Sub? + +Sub is the short form of subroutine, that is used to handle a certain task within a program. Subs are used to split a task into individual procedures. Splitting a program into procedures and sub-procedures enhances readability and reduces the error-proneness. A sub possibly takes some arguments as parameters but does not return any values back to the calling sub or function, for example: +DoSomethingWithTheValues(MyFirstValue,MySecondValue) +What is a Function? +A function is essentially a sub, which returns a value. You may use a function at the right side of a variable declaration, or at other places where you normally use values, for example: +MySecondValue = myFunction(MyFirstValue) +Global and local variables +Global variables are valid for all subs and functions inside a module. They are declared at the beginning of a module before the first sub or function starts. +Variables that you declare within a sub or function are valid only inside this sub or function. These variables override global variables with the same name and local variables with the same name coming from superordinate subs or functions. +Structuring +After separating your program into procedures and functions (Subs and Functions), you can save these procedures and functions as files for reuse in other projects. $[officename] Basic supports Modules and Libraries. Subs and functions are always contained in modules. You can define modules to be global or part of a document. Multiple modules can be combined to a library. +You can copy or move subs, functions, modules and libraries from one file to another by using the Macro dialog. + +
diff --git a/helpcontent2/source/text/sbasic/shared/01020000.xhp b/helpcontent2/source/text/sbasic/shared/01020000.xhp new file mode 100644 index 000000000..ccec8f509 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01020000.xhp @@ -0,0 +1,44 @@ + + + + + + + + +Syntax +/text/sbasic/shared/01020000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Syntax + This section describes the basic syntax elements of $[officename] Basic. For a detailed description please refer to the $[officename] Basic Guide which is available separately. +
+ + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/01020100.xhp b/helpcontent2/source/text/sbasic/shared/01020100.xhp new file mode 100644 index 000000000..ed5ce1eaa --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01020100.xhp @@ -0,0 +1,266 @@ + + + + + + + Using Variables + /text/sbasic/shared/01020100.xhp + + + + + +
+ + names of variables + variables; using + types of variables + declaring variables + values;of variables + literals;date + literals;integer + literals;integer + literals;floating point + constants + arrays;declaring + defining;constants + + + +

Using Variables

+The following describes the basic use of variables in $[officename] Basic. +
+ +

Naming Conventions for Variable Identifiers

+A variable name can consist of a maximum of 255 characters. The first character of a variable name must be a letter A-Z or a-z. Numbers can also be used in a variable name, but punctuation symbols and special characters are not permitted, with exception of the underscore character ("_"). In $[officename] Basic variable identifiers are not case-sensitive. Variable names may contain spaces but must be enclosed in square brackets if they do. +Examples for variable identifiers: + + + MyNumber=5 'Correct' + MyNumber5=15 'Correct' + MyNumber_5=20 'Correct' + My Number=20 'Not valid, variable with space must be enclosed in square brackets' + [My Number]=12 'Correct' + DéjàVu=25 'Not valid, special characters are not allowed' + 5MyNumber=12 'Not valid, variable may not begin with a number' + Number,Mine=12 'Not valid, punctuation marks are not allowed' + + +

Declaring Variables

+In $[officename] Basic you don't need to declare variables explicitly. A variable declaration can be performed with the Dim statement. You can declare more than one variable at a time by separating the names with a comma. To define the variable type, use either a type-declaration sign after the name, or the appropriate key word. +Examples for variable declarations: + + + Dim a$ 'Declares the variable "a" as a String' + Dim a As String 'Declares the variable "a" as a String' + Dim a$, b As Integer 'Declares one variable as a String and one as an Integer' + Dim c As Boolean 'Declares c as a Boolean variable that can be TRUE or FALSE' + + +Once you have declared a variable as a certain type, you cannot declare the variable under the same name again as a different type! + +When you declare multiple variables in a single line of code you need to specify the type of each variable. If the type of a variable is not explicitly specified, then Basic will assume that the variable is of the Variant type. + + ' Both variables "a" and "b" are of the Integer type + Dim a As Integer, b As Integer + ' Variable "c" is a Variant and "d" is an Integer + Dim c, d As Integer + ' A variable can also be explicitly declared as a Variant + Dim e As Variant, f As Double + +The Variant type is a special data type that can store any kind of value. To learn more, refer to the section The Variant type below. + +

Forcing Variable Declarations

+To force declaration of variables, use the following command: + +Option Explicit + +The Option Explicit statement has to be the first line in the module, before the first SUB. Generally, only arrays need to be declared explicitly. All other variables are declared according to the type-declaration character, or - if omitted - as the default type Single. + +

Variable Types

+$[officename] Basic supports four variable classes: + + + + Numeric variables can contain number values. Some variables are used to store large or small numbers, and others are used for floating-point or fractional numbers. + + + String variables contain character strings. + + + Boolean variables contain either the TRUE or the FALSE value. + + + Object variables can store objects of various types, like tables and documents within a document. + + +

Integer Variables

+Integer variables range from -32768 to 32767. If you assign a floating-point value to an integer variable, the decimal places are rounded to the next integer. Integer variables are rapidly calculated in procedures and are suitable for counter variables in loops. An integer variable only requires two bytes of memory. "%" is the type-declaration character. + +Dim Variable% +Dim Variable As Integer + + +

Long Integer Variables

+Long integer variables range from -2147483648 to 2147483647. If you assign a floating-point value to a long integer variable, the decimal places are rounded to the next integer. Long integer variables are rapidly calculated in procedures and are suitable for counter variables in loops for large values. A long integer variable requires four bytes of memory. "&" is the type-declaration character. + +Dim Variable& +Dim Variable As Long + + +

Decimal Variablessee i64349

+Decimal variables can take positive or negative numbers or zero. Accuracy is up to 29 digits.i85284 +You can use plus (+) or minus (-) signs as prefixes for decimal numbers (with or without spaces). +If a decimal number is assigned to an integer variable, %PRODUCTNAME Basic rounds the figure up or down.information from "Programming Guide for BASIC" about decimal variables + +

Single Variables

+Single variables can take positive or negative values ranging from 3.402823 x 10E38 to 1.401298 x 10E-45. Single variables are floating-point variables, in which the decimal precision decreases as the non-decimal part of the number increases. Single variables are suitable for mathematical calculations of average precision. Calculations require more time than for Integer variables, but are faster than calculations with Double variables. A Single variable requires 4 bytes of memory. The type-declaration character is "!". + +Dim Variable! +Dim Variable As Single + + +

Double Variables

+Double variables can take positive or negative values ranging from 1.79769313486232 x 10E308 to 4.94065645841247 x 10E-324. Double variables are floating-point variables, in which the decimal precision decreases as the non-decimal part of the number increases. Double variables are suitable for precise calculations. Calculations require more time than for Single variables. A Double variable requires 8 bytes of memory. The type-declaration character is "#". + +Dim Variable# +Dim Variable As Double + + +

Currency Variables

+Currency variables are internally stored as 64-bit numbers (8 Bytes) and displayed as a fixed-decimal number with 15 non-decimal and 4 decimal places. The values range from -922337203685477.5808 to +922337203685477.5807. Currency variables are used to calculate currency values with a high precision. The type-declaration character is "@". + +Dim Variable@ +Dim Variable As Currency + + +

Literals for integers

+Numbers can be encoded using octal and hexadecimal forms. + + xi = &o13 ' 8 + 3 + ci = &h65 ' 6*16 + 5 + MAX_Integer = &o77777 ' 32767 = &h7FFF + MIN_Integer = &o100000 ' -32768 = &h8000 + MAX_Long = &h7fffffff ' 2147483647 = &o17777777777 + MIN_Long = &h80000000 ' -2147483648 = &o20000000000 + + +

String Variables

+String variables can hold character strings with up to 2,147,483,648 characters. Each character is stored as the corresponding Unicode value. String variables are suitable for word processing within programs and for temporary storage of any non-printable character up to a maximum length of 2 Gbytes. The memory required for storing string variables depends on the number of characters in the variable. The type-declaration character is "$". +In BASIC String functions, the first character of the string has index 1. + +Dim Variable$ +Dim Variable As String + + +

Boolean Variables

+Boolean variables store only one of two values: TRUE or FALSE. A number 0 evaluates to FALSE, every other value evaluates to TRUE. + +Dim Variable As Boolean + + +

Date Variables

+Date variables can only contain dates and time values stored in an internal format. Values assigned to Date variables with Dateserial, Datevalue, Timeserial or Timevalue are automatically converted to the internal format. Date-variables are converted to normal numbers by using the Day, Month, Year or the Hour, Minute, Second function. The internal format enables a comparison of date/time values by calculating the difference between two numbers. These variables can only be declared with the key word Date. + +Dim Variable As Date + + + + ampersand symbol; in literal notation + literals;hexadecimal + literals;octal + literals;&h notation + literals;&o notation + +

Literals for Dates

+
+Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are: + + + #yyyy-mm-dd# + + + #mm/dd/yyyy# + + +
+ + start_date = #12/30/1899# ' = 1 + dob = #2010-09-28# + + + + The Variant type + The Any type + +

The Variant type

+Variables declared as Variant can handle any data type. This means that the actual data type is defined during runtime as a value is assigned to the variable. +There are three main ways to create a Variant variable, as shown below: + + Dim varA ' The type is not specified, hence the variable is a Variant + Dim varB as Variant ' The variable is explicitly declared as a Variant + varC = "abc" ' Previously undeclared variables are treated as Variants + +The example below uses the TypeName function to show how the type of a Variant variable changes upon assignment. + + Dim myVar As Variant + MsgBox TypeName(myVar) ' Empty + myVar = "Hello!" + MsgBox TypeName(myVar) ' String + myVar = 10 + MsgBox TypeName(myVar) ' Integer + +A Variant variable is initialized with the Empty special data type. You can use the IsEmpty function to test if a variable is an Empty Variant. +You can also use the keyword Any to declare a variable as a Variant. However, Any is deprecated and is available for backward compatibility. +Arguments with type Variant or Any passed in function calls are not checked for their types. + + Dim myVar As Any ' Variable "myVar" is a Variant + + +

Initial Variable Values

+As soon as the variable has been declared, it is automatically set to the "Null" value. Note the following conventions: + Numeric variables are automatically assigned the value "0" as soon as they are declared. + Date variables are assigned the value 0 internally; equivalent to converting the value to "0" with the Day, Month, Year or the Hour, Minute, Second function. + String variables are assigned an empty-string ("") when they are declared. + +

Arrays

+$[officename] Basic knows one- or multi-dimensional arrays, defined by a specified variable type. Arrays are suitable for editing lists and tables in programs. Individual elements of an array can be addressed through a numeric index. +Arrays must be declared with the Dim statement. There are several ways to define the index range of an array: + + + Dim Text$(20) '21 elements numbered from 0 to 20' + Dim Text$(5,4) '30 elements (a matrix of 6 x 5 elements)' + Dim Text$(5 To 25) '21 elements numbered from 5 to 25' + Dim Text$(-15 To 5) '21 elements (including 0), numbered from -15 to 5' + + +The index range can include positive as well as negative numbers. i36558 + +

Constants

+Constants have a fixed value. They are only defined once in the program and cannot be redefined later: + +Const ConstName=Expression + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/01020200.xhp b/helpcontent2/source/text/sbasic/shared/01020200.xhp new file mode 100644 index 000000000..186a43f39 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01020200.xhp @@ -0,0 +1,46 @@ + + + + + + + + +Using Objects +/text/sbasic/shared/01020200.xhp + + +Sun Microsystems, Inc. + + + +
+Using the Object Catalog + +The object catalog provides an overview of all modules and dialogs you have created in $[officename]. +
+
+Click the Object Catalog icon +Icon + in the Macro toolbar to display the object catalog. +The dialog shows a list of all existing objects in a hierarchical representation. Double-clicking a list entry opens its subordinate objects. +To display a certain module in the Editor or to position the cursor in a selected SUB or FUNCTION, double click on the corresponding entry. +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/01020300.xhp b/helpcontent2/source/text/sbasic/shared/01020300.xhp new file mode 100644 index 000000000..b50699fe2 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01020300.xhp @@ -0,0 +1,169 @@ + + + + + + Using Procedures, Functions or Properties + /text/sbasic/shared/01020300.xhp + + + + + procedures + functions;using + variables;passing to procedures, functions, properties + parameters;for procedures, functions or properties + parameters;passing by reference or value + variables;scope + scope of variables + GLOBAL variables + PUBLIC variables + PRIVATE variables + functions;return value type + return value type of functions + +
+

Using Procedures, Functions and Properties

+The following describes the basic use of procedures, functions and properties in %PRODUCTNAME Basic. +
+When you create a new module, %PRODUCTNAME Basic automatically inserts a Sub called "Main". This default name has nothing to do with the order or the starting point of a %PRODUCTNAME Basic project. You can also safely rename this Subroutine. +Some restrictions apply for the names of your public variables, subroutines, functions and properties. You must not use the same name as one of the modules of the same library. +Procedures (Subroutines) functions (Function) and properties (Property) help you maintaining a structured overview by separating a program into logical pieces. +One benefit of procedures, functions and properties is that, once you have developed a program code containing task components, you can use this code in another project. +

Passing Variables to Procedures, Functions or Properties

+Variables can be passed to both procedures, functions or properties. The Sub Function or Property must be declared to expect parameters: + + Sub SubName(Parameter1 As TYPENAME, Parameter2 As TYPENAME,...) + ' your code goes here + End Sub + +The Sub is called using the following syntax: + + [Call] SubName( [Parameter1:=]Value1, [Parameter2:=]Value2, ...) + +The parameters passed to a Sub must fit to those specified in the Sub declaration. +The same process applies to a Function. In addition, functions always return a function result. The result of a function is defined by assigning the return value to the function name: + + Function FunctionName(Parameter1 As TYPENAME, Parameter2 As TYPENAME,...) As TYPENAME + ' your code goes here + FunctionName=Result + End Function + +The Function is called using the following syntax: + + Variable = FunctionName( [Parameter1:=]Value1, [Parameter2:=]Value2, ...) + +Properties combine the syntax of procedures and functions. A Property usually requires up to one parameter. + + Private _IsApproved As TYPENAME + Property Get IsApproved As TYPENAME + ' your code goes here + IsApproved = some_computation + End Property + Property Let IsApproved(value As TYPENAME) + ' your code goes here + _IsApproved = computed_value + End Property + +The Property is called using the following syntax: + + var = IsApproved + IsApproved = some_value + +You can also use the fully qualified name to call a procedure, function or property:
[Call] Library.Module.Macro(), where Call is optional.
For example, to call the Autotext macro from the Gimmicks library, use the following command:
Gimmicks.AutoText.Main()
+

Passing Variables by Value or Reference

+Parameters can be passed to a procedure, a function or a property either by reference or by value. Unless otherwise specified, a parameter is always passed by reference. That means that a Sub, a Function or a Property gets the parameter and can read and modify its value. +If you want to pass a parameter by value insert the key word ByVal in front of the parameter when you call a Sub, a Function or a Property, for example: + + Function ReadOnlyParms(ByVal p2, ByVal p2) + ' your code goes here + End Function + result = ReadOnlyParms(parm1, parm2) + +In this case, the original content of the parameter will not be modified by the Function since it only gets the value and not the parameter itself. +

Defining Optional Parameters

+Functions, procedures or properties can be defined with optional parameters, for example: + + Sub Rounding(number, Optional decimals, Optional format) + ' your code goes here + End Sub + +

Positional or Keyword Arguments

+When you call a function or a subroutine, you may pass its arguments by position or by name. Passing by position means just listing the arguments in the order in which the parameters are defined in the function or subroutine. Passing by name requires you to prefix the argument with the name of the corresponding parameter followed by a colon and an equal sign (:=). Keyword arguments may appear in any order. Refer to Basic Replace() function for such examples. +
+When needing to pass less parameters, use keywords arguments. Passing values for fewer parameters by position requires to supply values for all parameters before them, optional or not. This ensures that the values are in the correct positions. If you pass the parameters by name - using keyword arguments - you may omit all other intermediate arguments. +
+

Scope of Variables

+A variable defined within a Sub, a Function or a Property, only remains valid until the procedure is exited. This is known as a "local" variable. In many cases, you need a variable to be valid in all procedures, in every module of all libraries, or after a Sub, a Function or a Property is exited. +

Declaring Variables Outside a Sub a Function or a Property

+ +Global VarName As TYPENAME + +The variable is valid as long as the %PRODUCTNAME session lasts. + +Public VarName As TYPENAME + +The variable is valid in all modules. + +Private VarName As TYPENAME + +The variable is only valid in this module. + +Dim VarName As TYPENAME + +The variable is only valid in this module. +

Example for private variables

+Enforce private variables to be private across modules by setting CompatibilityMode(True).from i17948, see i54894 + + ' ***** Module1 ***** + Private myText As String + Sub initMyText + myText = "Hello" + Print "In module1 : ", myText + End Sub + + ' ***** Module2 ***** + 'Option Explicit + Sub demoBug + CompatibilityMode( True ) + initMyText + ' Now returns empty string + ' (or raises error for Option Explicit) + Print "Now in module2 : ", myText + End Sub + +

Saving Variable Content after Exiting a Sub a Function or a Property

+ + Static VarName As TYPENAME + +The variable retains its value until the next time the a Function, Sub or Property is entered. The declaration must exist inside a Sub, a Function or a Property. +

Specifying the Return Value Type of a Function or a Property

+As with variables, include a type-declaration character after the function name, or the type indicated by As and the corresponding data type at the end of the parameter list to define the type of the function or property's return value, for example: + + Function WordCount(WordText As String) As Integer + +
+ + + Optional keyword + Property Statement + Static Statement +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/01020500.xhp b/helpcontent2/source/text/sbasic/shared/01020500.xhp new file mode 100644 index 000000000..4be972c38 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01020500.xhp @@ -0,0 +1,49 @@ + + + + + + + + +Libraries, Modules and Dialogs +/text/sbasic/shared/01020500.xhp + + +Sun Microsystems, Inc. + + + +
+Libraries, Modules and Dialogs +The following describes the basic use of libraries, modules and dialogs in $[officename] Basic. +
+$[officename] Basic provides tools to help you structuring your projects. It supports various "units" which enable you to group individual SUBS and FUNCTIONS in a Basic project. +Libraries +Libraries serve as a tool for organizing modules, and can either be attached to a document or a template. When the document or a template is saved, all modules contained in the library are automatically saved as well. +A library can contain up to 16,000 modules. +Modules +A module contains SUBS and FUNCTIONS along with variable declarations. The length of the program that can be saved in a module is limited to 64 kB. If more space is required you can divide a $[officename] Basic project among several modules, and then save them in a single library. +Dialog Modules +Dialog modules contain dialog definitions, including the dialog box properties, the properties of each dialog element and the events assigned. Since a dialog module can only contain a single dialog, they are often referred to as "dialogs". +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/01030000.xhp b/helpcontent2/source/text/sbasic/shared/01030000.xhp new file mode 100644 index 000000000..da133db88 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01030000.xhp @@ -0,0 +1,46 @@ + + + + + + + + +Integrated Development Environment (IDE) +/text/sbasic/shared/01030000.xhp + + +Sun Microsystems, Inc. + + + +
+Basic IDE;Integrated Development Environment +IDE;Integrated Development Environment + +Integrated Development Environment (IDE) +This section describes the Integrated Development Environment for $[officename] Basic. +
+ + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/01030100.xhp b/helpcontent2/source/text/sbasic/shared/01030100.xhp new file mode 100644 index 000000000..027ee2806 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01030100.xhp @@ -0,0 +1,45 @@ + + + + + + + + +IDE Overview +/text/sbasic/shared/01030100.xhp + + +Sun Microsystems, Inc. + + + + +
+IDE Overview +
+The Macro Toolbar in the IDE provides various icons for editing and testing programs. +In the Editor window, directly below the Macro toolbar, you can edit the Basic program code. The column on the left side is used to set breakpoints in the program code. +The Watch window (observer) is located below the Editor window at the left, and displays the contents of variables or arrays during a single step process. +The Call Stack window to the right provides information about the call stack of SUBS and FUNCTIONS when a program runs. +
+Basic IDE +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/01030200.xhp b/helpcontent2/source/text/sbasic/shared/01030200.xhp new file mode 100644 index 000000000..bafdfa0ec --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01030200.xhp @@ -0,0 +1,83 @@ + + + + + +The Basic Editor +/text/sbasic/shared/01030200.xhp + + + + +
+saving;Basic code +loading;Basic code +Basic editor +navigating;in Basic projects +long lines;in Basic editor +lines of text;in Basic editor +continuation;long lines in editor + +

The Basic Editor

+
+The Basic Editor provides the standard editing functions you are familiar with when working in a text document. It supports the functions of the Edit menu (Cut, Delete, Paste), the ability to select text with the Shift key, as well as cursor positioning functions (for example, moving from word to word with CommandCtrl and the arrow keys). +Long lines can be split into several parts by inserting a space and an underline character _ as the last two characters of a line. This connects the line with the following line to one logical line. (If "Option Compatible" is used in the same Basic module, the line continuation feature is also valid for comment lines.) +If you press the Run BASIC icon on the Macro bar, program execution starts at the first line of the Basic editor. The program executes the first Sub or Function and then program execution stops. The "Sub Main" does not take precedence on program execution. +Insert your Basic code between the Sub Main and End Sub lines that you see when you first open the IDE. Alternatively, delete all lines and then enter your own Basic code. +

Navigating in a Project

+

The Library List

+Select a library from the Library list at the left of the toolbar to load the library in the editor. The first module of the selected library will be displayed. +

The Object Catalog

+ +

Saving and Loading Basic Source Code

+You can save Basic code in a text file for saving and importing in other programming systems. +You cannot save Basic dialogs to a text file. +

Saving Source Code to a Text File

+ + +Select the module that you want to export as text from the object catalog. + + +Click the Save Source As icon in the Macro toolbar. + + +Select a file name and click OK to save the file. + + +

Loading Source Code From a Text File

+ + +Select the module where you want to import the source code from the object catalog. + + +Position the cursor where you want to insert the program code. + + +Click the Insert Source Text icon in the Macro toolbar. + + +Select the text file containing the source code and click OK. + + +
+Basic IDE + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/01030300.xhp b/helpcontent2/source/text/sbasic/shared/01030300.xhp new file mode 100644 index 000000000..0345d9250 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01030300.xhp @@ -0,0 +1,63 @@ + + + + + + + + + + +Debugging a Basic Program +/text/sbasic/shared/01030300.xhp + + + +
+debugging Basic programs +variables; observing values +watching variables +run-time errors in Basic +error codes in Basic +breakpoints +Call Stack window +Debugging a Basic Program +
+Breakpoints and Single Step Execution +You can check each line in your Basic program for errors using single step execution. Errors are easily traced since you can immediately see the result of each step. A pointer in the breakpoint column of the Editor indicates the current line. You can also set a breakpoint if you want to force the program to be interrupted at a specific position. +Double-click in the breakpoint column at the left of the Editor window to toggle a breakpoint at the corresponding line. When the program reaches a breakpoint, the program execution is interrupted. +The single step execution using the Single Step icon causes the program to branch into procedures and functions. +The procedure step execution using the Procedure Step icon causes the program to skip over procedures and functions as a single step. +Properties of a Breakpoint +The properties of a breakpoint are available through its context menu by right-clicking the breakpoint in the breakpoint column. +You can activate and deactivate a breakpoint by selecting Active from its context menu. When a breakpoint is deactivated, it does not interrupt the program execution. +Select Properties from the context menu of a breakpoint or select Breakpoints from the context menu of the breakpoint column to call the Breakpoints dialog where you can specify other breakpoint options. +The list displays all breakpoints with the corresponding line number in the source code. You can activate or deactivate a selected breakpoint by checking or clearing the Active box. +The Pass Count specifies the number of times the breakpoint can be passed over before the program is interrupted. If you enter 0 (default setting) the program is always interrupted as soon as a breakpoint is encountered. +Click Delete to remove the breakpoint from the program. +Observing the Value of Variables +You can monitor the values of a variable by adding it to the Watch window. To add a variable to the list of watched variables, type the variable name in the Watch text box and press Enter. +The values of variables are only displayed if they are in scope. Variables that are not defined at the current source code location display ("Out of Scope") instead of a value. +You can also include arrays in the Watch window. If you enter the name of an array variable without an index value in the Watch text box, the content of the entire array is displayed. +If you rest the mouse over a predefined variable in the Editor at run-time, the content of the variable is displayed in a pop-up box.The Call Stack Window +Provides an overview of the call hierarchy of procedures and functions. You can determine which procedures and functions called which other procedures and functions at the current point in the source code. +List of Run-Time Errors + + +
diff --git a/helpcontent2/source/text/sbasic/shared/01030400.xhp b/helpcontent2/source/text/sbasic/shared/01030400.xhp new file mode 100644 index 000000000..71a53f428 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01030400.xhp @@ -0,0 +1,211 @@ + + + + + +Organizing Libraries and Modules +/text/sbasic/shared/01030400.xhp + + + +
+ +libraries;organizing +libraries;containers +modules;organizing +copying;modules +adding libraries +deleting;libraries/modules/dialogs +dialogs;organizing +moving;modules +organizing;modules/libraries/dialogs +renaming modules and dialogs +

Organizing Libraries and Modules +

+
+

Basic Libraries Containers

+%PRODUCTNAME Basic libraries can be stored in 3 different containers: + + + Application Macros: libraries stored in this container are available for all users of the computer and are managed by the computer administrator. The container is located in the %PRODUCTNAME installation directory. + + + My Macros: libraries stored in this container are available to all documents of your user. The container is located in the user profile area and is not accessible by another user. + + + Document: libraries stored in the document container are only available for the document and are accessible only when the document is open. You cannot access macros of a document from another document. + + +To access macros stored in libraries of Application Macros or My Macros from another container, including the document container, use the GlobalScope specifier. +

Organizing Libraries

+

Creating a New Library

+ + +Choose Tools - Macros - Organize Macros - %PRODUCTNAME Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog. + + +Click the Libraries tab. + + +Select to where you want to attach the library in the Location list. If you select Application Macros & Dialogs, the library will belong to the $[officename] application and will be available for all documents. If you select a document the library will be attached to this document and only available from there. + + +Click New and insert a name to create a new library. + + +

Import a Library

+ + +Choose Tools - Macros - Organize Macros - %PRODUCTNAME Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog. + + +Click the Libraries tab. + + +Select to where you want to import the library in the Location list. If you select Application Macros & Dialogs, the library will belong to the $[officename] application and will be available for all documents. If you select a document the library will be imported to this document and only available from there. + + +Click Import... and select an external library to import. + + +Select all libraries to be imported in the Import Libraries dialog. The dialog displays all libraries that are contained in the selected file. + + +If you want to insert the library as a reference only check the Insert as reference (read-only) box. Read-only libraries are fully functional but cannot be modified in the Basic IDE. + + +Check the Replace existing libraries box if you want existing libraries of the same name to be overwritten. + + +Click OK to import the library. + + +

Export a Library

+ + +Choose Tools - Macros - Organize Macros - %PRODUCTNAME Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog. + + +Click the Libraries tab. + + +In the Location list you specify where your library is stored. Select the library that you want to export. Note that you cannot export the Standard library. + + +Click Export... + + +Choose whether you want to export the library as an extension or as a BASIC library. + + +Click OK. + + +Select where you want your library exported. + + +Click Save to export the library. + + +

Deleting a Library

+ + +Choose Tools - Macros - Organize Macros - %PRODUCTNAME Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog. + + +Click the Libraries tab. + + +Select the library to be deleted from the list. + + +Click Delete. + + + + +Deleting a library permanently deletes all existing modules and corresponding procedures and functions. + + +You cannot delete the default library named "Standard". + + +If you delete a library that was inserted as reference only the reference is deleted but not the library itself. + + +

Organizing Modules and Dialogs

+

Creating a New Module or Dialog

+ + +Choose Tools - Macros - Organize Macros - %PRODUCTNAME Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog. + + +Click the Modules tab or the Dialogs tab. + + +Select the library where the module will be inserted and click New. + + +Enter a name for the module or the dialog and click OK. + + +

Renaming a Module or Dialog

+ + +Choose Tools - Macros - Organize Macros - %PRODUCTNAME Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog. + + +Click the module to be renamed twice, with a pause between the clicks. Enter the new name. +In the Basic IDE, right-click the name of the module or dialog in the tabs at the bottom of the screen, choose Rename and type in the new name. + + +Press Enter to confirm your changes. + + +

Deleting a Module or Dialog

+ + +Choose Tools - Macros - Organize Macros - %PRODUCTNAME Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog. + + +Click the Modules tab or the Dialogs tab. + + +Select the module or dialog to be deleted from the list. Double-click an entry to reveal sub-entries, if required. + + +Click Delete. + + +Deleting a module permanently deletes all existing procedures and functions in that module. +

Organizing Projects among Documents or Templates

+

Moving or copying modules between documents, templates and the application.

+ + +Open all documents or templates among which you want to move or copy the modules or dialogs. + + +Choose Tools - Macros - Organize Macros - %PRODUCTNAME Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog. + + +To move a module or dialog to another document, click the corresponding object in the list and drag it to the desired position. A horizontal line indicates the target position of the current object while dragging. Hold the CommandCtrl key while dragging to copy the object instead of moving it. + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/01040000.xhp b/helpcontent2/source/text/sbasic/shared/01040000.xhp new file mode 100644 index 000000000..942be5ce6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01040000.xhp @@ -0,0 +1,255 @@ + + + + + + + + Document Event-Driven Macros + /text/sbasic/shared/01040000.xhp + + + +
+ + deleting; macro assignments to events + macros; assigning to events + assigning macros to events + documents; events + events; assigning macros + events; in documents + API; XDocumentEventListener + +

Document Event-Driven Macros

+ This section describes how to assign scripts to application, document or form events. +
+ You can automatically execute a macro when a specified software event occurs by assigning the desired macro to the event. The following table provides an overview of document events and at what point an assigned macro is executed. + + + + Event + An assigned macro is executed... + routine + + + Start Application + ...after a $[officename] application is started. + OnStartApp + + + Close Application + ...before a $[officename] application is terminated. + OnCloseApp + + + Document created + ...New document created with File - New or with the New icon. Note that this event also fires when Basic IDE opens. + OnCreate + + + New Document + ...after a new document is created with File - New or with the New icon. + OnNew + + + Document loading finished + ...before a document is opened with File - Open or with the Open icon. + OnLoadFinished + + + Open Document + ...after a document is opened with File - Open or with the Open icon. + OnLoad + + + Document is going to be closed + ...before a document is closed. + OnPrepareUnload + + + Document closed + ...after a document was closed. Note that the "Save Document" event may also occur when the document is saved before closing. + OnUnload + + + -no UI- + + OnLayoutFinished + + + View created + Document is displayed. Note that this event also happens when a document is duplicated. + OnViewCreated + + + View is going to be closed + Document layout is getting removed. + OnPrepareViewClosing + + + View closed + Document layout is cleared prior to the document closure. + OnViewClosed + + + Activate Document + ...after a document is brought to the foreground. + OnFocus + + + Deactivate Document + ...after another document is brought to the foreground. + OnUnfocus + + + Save Document + ...before a document is saved with File - Save or the Save icon, provided that a document name has already been specified. + OnSaveAs + + + Document has been saved + ...after a document is saved with File - Save or the Save icon, provided that a document name has already been specified. + OnSaveDone + + + Saving of document failed + Document could not be saved. + OnSaveFailed + + + Save Document As + ...before a document is saved under a specified name (with File - Save As, or with File - Save or the Save icon, if a document name has not yet been specified). + OnSaveAs + + + Document has been saved as + ... after a document was saved under a specified name (with File - Save As, or with File - Save or with the Save icon, if a document name has not yet been specified). + OnSaveAsDone + + + 'Save As' has failed + Document could not be saved. + OnSaveAsFailed + + + -no UI- + When the document disk location has changed, for example after a File - Save As action. + OnStorageChanged + + + Storing or exporting copy of document + ...before a document is saved with File - Save a Copy, File - Export, File - Export as PDF or the Save icons. + OnCopyTo + + + Document copy has been created + ...after a document is saved with File - Save a Copy, File - Export, File - Export as PDF or the Save icons. + OnCopyToDone + + + Creating of document copy failed + Document could not be copied or exported. + OnCopyToFailed + + + Print document + ...after the Print dialog is closed, but before the actual print process begins. This event occurs for each copy printed. + OnPrint + + + -no UI- + ...after document security settings have changed. + OnModeChanged + + + 'Modified' status was changed + Modified state of a document has changed. + OnModifyChanged + + + Document title changed + When the document title gets updated. + OnTitleChanged + + + Loaded a sub component + ...after a database form has been opened. + OnSubComponentOpened + + + Closed a sub component + ...after a database form has been closed. + OnSubComponentClosed + + + Printing of form letters started + ...before printing form letters using File - Print or Tools - Mail Merge Wizard menus. + OnMailMerge + + + Printing of form letters finished + ...after printing of form letters using File - Print or Tools - Mail Merge Wizard menus. + OnMailMergeFinished + + + Printing of form fields started + ...before printing form fields. + OnFieldMerge + + + Printing of form fields finished + ...after printing form fields. + OnFieldMergeFinished + + + Change of the page count + When the page count changes. + OnPageCountChanged + +
+ + Most events relate to documents, except OnStartApp, OnCloseApp, OnCreate and OnLoadFinished that occur at application level. OnSubComponentOpened, and OnSubComponentClosed events are fired by database's forms. + + Writer documents are triggering those specific events: OnLayoutFinished, OnMailMerge, OnMailMergeFinished, OnFieldMerge, OnFieldMergeFinished and OnPageCountChanged. + +

Assigning a Macro to an Event

+ + Choose Tools - Customize and click the Events tab. + Select whether you want the assignment to be globally valid or just valid in the current document in the Save In listbox. + Select the event from the Event list. + Click Macro and select the macro to be assigned to the selected event. + Click OK to assign the macro. + Click OK to close the dialog. + + +

Removing the Assignment of a Macro to an Event

+ + Choose Tools - Customize and click the Events tab. + Select whether you want to remove a global assignment or an assignment that is just valid in the current document by selecting the option in the Save In listbox. + Select the event that contains the assignment to be removed from the Event list. + Click Remove. + Click OK to close the dialog. + + +
+ In addition to assigning macros to events, one can monitor events triggered in %PRODUCTNAME documents. +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/01050000.xhp b/helpcontent2/source/text/sbasic/shared/01050000.xhp new file mode 100644 index 000000000..d243b6102 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01050000.xhp @@ -0,0 +1,65 @@ + + + + + + + + +$[officename] Basic IDE +/text/sbasic/shared/01050000.xhp + + +Sun Microsystems, Inc. + + + +
+$[officename] Basic IDE + +This section describes the structure of the Basic IDE. + +Opens the Basic IDE where you can write and edit macros. +
+ + + + + +Commands From the Context menu of the Module Tabs +Insert + +Module +Inserts a new module into the current library. + +Dialog +Inserts a new dialog into the current library. + +Delete +Deletes the selected module. + +Rename +Renames the current module in place. + +Hide +Hides the current module. +Modules +Opens the Macro Organizer dialog. + +
diff --git a/helpcontent2/source/text/sbasic/shared/01050100.xhp b/helpcontent2/source/text/sbasic/shared/01050100.xhp new file mode 100644 index 000000000..572fa6619 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01050100.xhp @@ -0,0 +1,60 @@ + + + + + + + + +Watch Window +/text/sbasic/shared/01050100.xhp + + +Sun Microsystems, Inc. + + + +
+Watch Window +The Watch window allows you to observe the value of variables during the execution of a program. Define the variable in the Watch text box. Click on Enable Watch to add the variable to the list box and to display its values. +
+ +Watch +Enter the name of the variable whose value is to be monitored. + +Remove Watch +Removes the selected variable from the list of watched variables. + + + + +Icon + + + +Remove Watch + + +
+ + +Editing the Value of a Watched Variable +Displays the list of watched variables. Click twice with a short pause in between on an entry to edit its value. The new value will be taken as the variable's value for the program. + +
diff --git a/helpcontent2/source/text/sbasic/shared/01050200.xhp b/helpcontent2/source/text/sbasic/shared/01050200.xhp new file mode 100644 index 000000000..ef0810332 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01050200.xhp @@ -0,0 +1,39 @@ + + + + + + + + +Call Stack Window (Calls) +/text/sbasic/shared/01050200.xhp + + +Sun Microsystems, Inc. + + + +
+ +Call Stack Window (Calls) +Displays the sequence of procedures and functions during the execution of a program. The Call Stack allows you to monitor the sequence of procedures and functions during the execution of a program. The procedures are functions are displayed bottom to top with the most recent function or procedure call at the top of the list. +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/01050300.xhp b/helpcontent2/source/text/sbasic/shared/01050300.xhp new file mode 100644 index 000000000..15537dcce --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01050300.xhp @@ -0,0 +1,58 @@ + + + + + + + + +Manage Breakpoints +/text/sbasic/shared/01050300.xhp + + +Sun Microsystems, Inc. + + + +
+ + + + +Manage Breakpoints +Specifies the options for breakpoints. +
+ +Breakpoints +Enter the line number for a new breakpoint, then click New. + + +Active +Activates or deactivates the current breakpoint. + +Pass Count +Specify the number of loops to perform before the breakpoint takes effect. + +New +Creates a breakpoint on the line number specified. + +Delete +Deletes the selected breakpoint. + +
diff --git a/helpcontent2/source/text/sbasic/shared/01170100.xhp b/helpcontent2/source/text/sbasic/shared/01170100.xhp new file mode 100644 index 000000000..8a532491c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01170100.xhp @@ -0,0 +1,104 @@ + + + + + + + + +Control and Dialog Properties +/text/sbasic/shared/01170100.xhp + + +Sun Microsystems, Inc. + + + +
+controls; properties +properties; controls and dialogs +dialogs; properties + +Control and Dialog Properties +
+Specifies the properties of the selected dialog or control. You must be in the design mode to be able to use this command. +Entering Data in the Properties Dialog +The following key combinations apply to enter data in multiline fields or combo boxes of the Properties dialog: + + + +Keys + + +Effects + + + + +Alt+Down Arrow + + +Opens a combo box + + + + +Alt+Up Arrow + + +Closes a combo box + + + + +Shift+Enter + + +Inserts a line break in multiline fields. + + + + +(UpArrow) + + +Goes to the previous line. + + + + +(DownArrow) + + +Goes to the next line. + + + + +Enter + + +Applies the changes made to a field and places the cursor into the next field. + + +
+ + + +
diff --git a/helpcontent2/source/text/sbasic/shared/01170101.xhp b/helpcontent2/source/text/sbasic/shared/01170101.xhp new file mode 100644 index 000000000..35768089c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01170101.xhp @@ -0,0 +1,440 @@ + + + + + +General +/text/sbasic/shared/01170101.xhp + + + +
+

General

+Define the properties for the selected control or dialog. The available properties depend on the type of control selected. The following properties therefore are not available for every type of control. +
+ +
+

Alignment

+Specify the alignment option for the selected control. +
+
+

AutoFill

+Select "Yes" to enable the AutoFill function for the selected control. +
+

Background color

+Specify the background color for the current control. +
+
+

Large change

+Specify the number of units to scroll when a user clicks in the area between the slider and the arrows on a scrollbar. +
+

Border

+Specify the border type for the current control. +
+
+

Button type

+Select a button type. Button types determine what type of action is initiated. +
+

Character set

+Select the font to be used for displaying the contents of the current control. +
+
+

Currency symbol

+Enter the currency symbol to be used for currency controls. +
+
+

Date

+Specify the default date to be shown in the Date control. +
+
+

Date format

+Specify the desired format for a date control. A date control interprets the user input depending on this format setting. +
+
+

Date max.

+Specify the upper limit for a date control. +
+
+

Date min.

+Specify the lower limit for a date control. +
+
+

Decimal accuracy

+Specify the number of decimal places displayed for a numerical or currency control. +
+
+

Default button

+Select "Yes" to make the current button control the default selection. Pressing Return in the dialog activates the default button. +
+
+

Delay

+Specifies the delay in milliseconds between scrollbar trigger events. A trigger event occurs when you click a scrollbar arrow or click the background area in a scrollbar. Repeated trigger events occur if you keep the mouse button pressed when you click a scrollbar arrow or background area in a scrollbar. If you want, you can include valid time units with the number that you enter, for example, 2 s or 500 ms. +
+

Dropdown

+Select "Yes" to enable the dropdown option for list or combo box controls. A dropdown control field has an arrow button which you can click to open a list of the existing form entries. +
+
+

Enabled

+Select "Yes" to enable the control. If the control is disabled, it is grayed out in the dialog. +
+
+

Edit mask

+Specify the edit mask for a pattern control. This is a character code that defines the input format for the control. +You need to specify a masking character for each input character of the edit mask to restrict the input to the values that are listed in the following table: + + + + Character + + +Meaning + + + + +L + + +A text constant. This character cannot be modified by the user. + + + + +a + + +The characters a-z can be entered here. If a capital letter is entered, it is automatically converted to a lowercase letter. + + + + +A + + +The characters A-Z can be entered here. If a lowercase letter is entered, it is automatically converted to a capital letter + + + + +c + + +The characters a-z and 0-9 can be entered here. If a capital letter is entered, it is automatically converted to a lowercase letter. + + + + +C + + +The characters a-z and 0-9 can be entered here. If a lowercase letter is entered, it is automatically converted to a capital letter + + + + +N + + +Only the characters 0-9 can be entered. + + + + +x + + +All printable characters can be entered. + + + + +X + + +All printable characters can be entered. If a lowercase letter is used, it is automatically converted to a capital letter. + + +
+
+
+

Editable

+Specifies whether the nodes of the tree control are editable. +The default value is FALSE. +
+

Graphics

+Specify the source of the graphics for a button or an image control. Click "..." to select a file. +
+
+

Height

+Specify the height of the current control or the dialog. +
+
+

Help text

+Enter a help text that is displayed as a tip (bubble help) when the mouse rests over the control. +
+
+

Help URL

+Specify the help URL that is called when you press F1 while the focus is on a particular control. For example, use the format HID:1234 to call the Help-ID with the number 1234. +Set the environment variable HELP_DEBUG to 1 to view the Help-IDs as extended help tips. +
+
+

Incr./decrement value

+Specify the increment and decrement interval for spin button controls. +
+
+

Invokes stop mode editing

+Specifies what happens when editing is interrupted by selecting another node in the tree, a change in the tree's data, or by some other means. +Setting this property to TRUE causes the changes to be automatically saved when editing is interrupted. FALSE means that editing is canceled and changes are lost. +The default value is FALSE. +
+

Label

+Specifies the label of the current control. The label is displayed along with the control. +You can create multi-line labels by inserting manual line breaks in the label using Shift+Enter. +
+
+

Line Count

+Enter the number of lines to be displayed for a list control. For combo boxes, this setting is only active if the dropdown option is enabled. +
+
+

Scrollbar

+Adds the scrollbar type that you specify to a text box. +
+
+

Small change

+Specify the number of units to scroll when a user clicks an arrow on a scrollbar. +
+

List entries

+Specify the entries for a list control. One line takes one list entry. Press Shift+Enter to insert a new line. +
+
+

Literal mask

+Specify the initial values to be displayed in a pattern control. This helps the user to identify which values are allowed in a pattern control. The literal mask is restricted by the format specified by the edit mask. +
+
+

Manual line break

+Select "Yes" to allow manual line breaks inside multiline controls. +
+
+

Max. text length

+Specify the maximum number of characters that the user can enter. +
+

Multiline Input

+Select "Yes" to allow the input of multiple lines in the control. Press Enter to insert a manual line break in the control. +
+
+

Multiselection

+Select "Yes" to allow the selection of multiple entries in list controls. +
+

Name

+Insert a name for the current control. This name is used to identify the control. +
+

Order

+Specify the order in which the controls receive the focus when the Tab key is pressed in the dialog. On entering a dialog, the control with the lowest order (0) receives the focus. Pressing the Tab key the successively focuses the other controls as specified by their order number. +Initially, the controls receive numbers in the order they are added to the dialog. You can change the order numbers for controls. $[officename] Basic updates the order numbers automatically to avoid duplicate numbers. Controls that cannot be focused are also assigned a value but these controls are skipped when using the Tab key. +
+
+

Orientation

+Specify the orientation for a scrollbar control. +
+
+

Page (step)

+Specify the number of the dialog page to which the current control is assigned or the page number of the dialog you want to edit. If a dialog has only one page set its Page (Step) value to 0. +Select Page (Step) = 0 to make a control visible on every dialog page. +To switch between dialog pages at run time, you need to create a macro that changes the value of Page (Step). +
+
+

Password characters

+Enter a character to be displayed instead of the characters that are typed. This can be used for entering passwords in text controls. +
+
+

PositionX

Specify the distance of the current control from the left side of the dialog. +
+
+

PositionY

+Specify the distance of the current control from the top of the dialog. +
+
+

Prefix symbol

+Select "Yes" to display the currency symbol prefix in currency controls when a number was entered. +
+
+

Print

+Select "Yes" to include the current control in a document's printout. +
+
+

Progress value

+Specify a progress value for a progress bar control. +
+
+

Progress value max.

+Specify the maximum value of a progress bar control. +
+
+

Progress value min.

+Specify the minimum value of a progress bar control. +
+

Read-only

+Select "Yes" to prevent the user from editing the value of the current control. The control is enabled and can be focused but not modified. +
+
+

RepeatUFI: see spec spinbutton_form_control.sxw

+Repeats trigger events when you keep the mouse button pressed on a control such as a spin button. +
+
+

Root displayedsee http://specs.openoffice.org/appwide/dialog_ide/New_Tree_Control_in_IDE.odt

+Specifies if the root node of the tree control is displayed. +If Root displayed is set to FALSE, the root node of a model is no longer a valid node for the tree control and can't be used with any method of XTreeControl. +The default value is TRUE. +
+
+

Row height

+Specifies the height of each row of a tree control, in pixels. +If the specified value is less than or equal to zero, the row height is the maximum height of all rows. +The default value is 0. +
+
+

Scale

+Scales the image to fit the control size. +
+
+ + +

Scrollbar

+Adds the scrollbar type that you specify to a text box. +
+
+

Scroll value

+Specify the initial value of a scrollbar control. This determines the position of the scrollbar slider. +
+
+

Scroll value max.

+Specify the maximum value of a scrollbar control. +
+
+

Scroll value min.

+Specify the minimum value of a scrollbar control. +
+
+

Show handles

+Specifies whether the handles of the nodes should be displayed. +The handles are dotted lines that visualize the hierarchy of the tree control. +The default value is TRUE. +
+
+

Show root handles

+Specifies whether the handles of the nodes should also be displayed at root level. +The default value is TRUE. +
+
+

SelectionUFI: udk.features "New property and help ID for property browser in Basic IDE"

+Specifies the sequence of the selected items, where "0" corresponds to the first item. To select more than one item, Multiselection must be enabled. +Click the ... button to open the Selection dialog. +Click the item or items that you want to select. To select more than one item, ensure that the Multiselection option is selected. +
+
+

Selection typesee http://specs.openoffice.org/appwide/dialog_ide/New_Tree_Control_in_IDE.odt

+Specifies the selection mode that is enabled for this tree control. +
+

Spin Button

+Select "Yes" to add spin buttons to a numerical, currency, date, or time control to allow increasing and decreasing the input value using arrow buttons. +
+
+

State

+Select the selection state of the current control. +
+
+

Strict format

+Select "Yes" to only allow valid characters to be entered in a numerical, currency, date, or time control. +
+

Tabstop

+Select the focus behavior of the current control when using the Tab key. + + + +Default + + +Only input controls receive the focus when using the Tab key. Controls without input like caption controls are omitted. + + + + +No + + +When using the tab key focusing skips the control. + + + + +Yes + + +The control can be selected with the Tab key. + + +
+
+
+

Thousands Separator

+Select "Yes" to display thousands separator characters in numerical and currency controls. +
+
+

Time Format

+Select the format to be used for time controls. +
+
+

Time max.

+Specify the maximum time value for a time control. +
+
+

Time min.

+Specify the minimum time value for a time control. +
+
+

Title

+Specify the title of the dialog. Click the border of the dialog to select the dialog. + +Titles are only used for labeling a dialog and can only contain one line. Please note that if you work with macros, controls are only called through their Name property. +
+
+

Tristate

+Select "Yes" to allow a check box to have three states (checked, unchecked, and grayed out) instead of two (checked and unchecked). +
+
+

Value

+Specify the value for the current control. +
+
+

Value max.

+Specify the maximum value for the current control. +
+
+

Value min.

+Specify the minimum value for the current control. +
+
+

Visible size

+Specify the length of the slider of a scrollbar control. +
+

Width

+Specify the width of the current control or dialog. +
+
+
diff --git a/helpcontent2/source/text/sbasic/shared/01170103.xhp b/helpcontent2/source/text/sbasic/shared/01170103.xhp new file mode 100644 index 000000000..fd3d25ae8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/01170103.xhp @@ -0,0 +1,66 @@ + + + + + + + + +Events +/text/sbasic/shared/01170103.xhp + + +Sun Microsystems, Inc. + + + +
+Events +Define event assignments for the selected control or dialog. The available events depend on the type of control selected. +
+When receiving focus +This event takes place if a control receives the focus. +When losing focus +This event takes place if a control loses the focus. +Key pressed +This event occurs when the user presses any key while the control has the focus. +Key released +This event occurs when the user releases a key while the control has the focus. +Modified +This event takes place, when the control loses the focus and the contents of the control were changed since it lost the focus. +Text modified +This event takes place if you enter or modify a text in an input field. +Item status changed +This event takes place if the status of the control field is changed, for example, from checked to unchecked. +Mouse inside +This event takes place when the mouse enters the control. +Mouse moved while key pressed +This event takes place when the mouse is dragged while a key is pressed. +Mouse moved +This event takes place when the mouse moves over the control. +Mouse button pressed +This event takes place when the mouse button is pressed while the mouse pointer is on the control. +Mouse button released +This event takes place when the mouse button is released while the mouse pointer is on the control. +Mouse outside +This event takes place when the mouse leaves the control. +While adjusting +This event takes place when a scrollbar is being dragged. + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11010000.xhp b/helpcontent2/source/text/sbasic/shared/02/11010000.xhp new file mode 100644 index 000000000..ad5f0a5c1 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11010000.xhp @@ -0,0 +1,58 @@ + + + + + + + + +Library +/text/sbasic/shared/02/11010000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ +Library + Select the library that you want to edit. The first module of the library that you select is displayed in the Basic IDE. +
+
+ + + + + + + List box Library + + + Library List Box + + + +
+
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11020000.xhp b/helpcontent2/source/text/sbasic/shared/02/11020000.xhp new file mode 100644 index 000000000..ce53ee438 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11020000.xhp @@ -0,0 +1,55 @@ + + + + + +Compile +/text/sbasic/shared/02/11020000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ +

Compile

+ Compiles the Basic macro. You need to compile a macro after you make changes to it, or if the macro uses single or procedure steps. +
+
+ + + + + + + Icon Compile + + + Compile + + + +
+
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11030000.xhp b/helpcontent2/source/text/sbasic/shared/02/11030000.xhp new file mode 100644 index 000000000..91d2c92f4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11030000.xhp @@ -0,0 +1,54 @@ + + + + + + + + +Run +/text/sbasic/shared/02/11030000.xhp + + +Sun Microsystems, Inc. + + + +
+ +Run +Runs the first macro of the current module. +
+
+ + + + +Icon + + + +Run + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11040000.xhp b/helpcontent2/source/text/sbasic/shared/02/11040000.xhp new file mode 100644 index 000000000..a8a7aa415 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11040000.xhp @@ -0,0 +1,57 @@ + + + + + + + + + + +Stop +/text/sbasic/shared/02/11040000.xhp + + + +
+macros; stopping +program stops +stopping macros + + +Stop +Stops running the current macro. + You can also press Shift+Ctrl+Q. +
+
+ + + + +Icon + + + +Stop + + +
+
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11050000.xhp b/helpcontent2/source/text/sbasic/shared/02/11050000.xhp new file mode 100644 index 000000000..57a75a94e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11050000.xhp @@ -0,0 +1,58 @@ + + + + + + + + +Single Step +/text/sbasic/shared/02/11050000.xhp + + +Sun Microsystems, Inc. + + + +
+ +Single Step +Runs the macro and stops it after the next command. +
+You can use this command in conjunction with the Watch command to troubleshoot errors. +
+ + + + +Icon + + + +Single Step + + +
+ +
+
+Procedure Step function +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11060000.xhp b/helpcontent2/source/text/sbasic/shared/02/11060000.xhp new file mode 100644 index 000000000..dd497d144 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11060000.xhp @@ -0,0 +1,58 @@ + + + + + + + + +Procedure Step +/text/sbasic/shared/02/11060000.xhp + + +Sun Microsystems, Inc. + + + +
+ +Procedure Step +Runs the macro and stops it after the next procedure. +
+You can use this command in conjunction with the Watch command to troubleshoot errors. +
+ + + + +Icon + + + +Procedure Step + + +
+ +
+
+Single Step function +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11070000.xhp b/helpcontent2/source/text/sbasic/shared/02/11070000.xhp new file mode 100644 index 000000000..8382317d2 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11070000.xhp @@ -0,0 +1,53 @@ + + + + + + + + + + +Breakpoint +/text/sbasic/shared/02/11070000.xhp + + + +
+ +Breakpoint +Inserts a breakpoint in the program line. +
+The breakpoint is inserted at the cursor position. Use a breakpoint to interrupt a program just before an error occurs. You can then troubleshoot the program by running it in Single Step mode until the error occurs. You can also use the Watch icon to check the content of the relevant variables. +
+ + + + +Icon + + + +Breakpoint + + +
+
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11080000.xhp b/helpcontent2/source/text/sbasic/shared/02/11080000.xhp new file mode 100644 index 000000000..98643b7db --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11080000.xhp @@ -0,0 +1,56 @@ + + + + + + + + +Enable Watch +/text/sbasic/shared/02/11080000.xhp + + +Sun Microsystems, Inc. + + + +
+ +Enable Watch +Click this icon to view the variables in a macro. The contents of the variable are displayed in a separate window. +
+Click the name of a variable to select it, then click the Enable Watch icon. The value that is assigned to the variable is displayed next to its name. This value is constantly updated. +
+ + + + +Icon + + + +Enable Watch + + +
+ +
+To remove the variable watch, select the variable in the Watch window, and then click on the Remove Watch icon. + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11090000.xhp b/helpcontent2/source/text/sbasic/shared/02/11090000.xhp new file mode 100644 index 000000000..b4f68b8a9 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11090000.xhp @@ -0,0 +1,61 @@ + + + + + + + + + + +Object Catalog +/text/sbasic/shared/02/11090000.xhp + + +Sun Microsystems, Inc. + + + +
+ +Object Catalog +Opens the Objects pane, where you can view Basic objects. +
+Double click the name of a function or sub to load the module that contains that function or sub, and to position the cursor. Double click the name of a module or dialog to load and display that module or dialog. +
+ + + + +Icon + + + +Object Catalog + + +
+ +
+ + +Window Area +Displays a hierarchical view of the current $[officename] macro libraries, modules, and dialogs. To display the contents of an item in the window, double click its name. + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11100000.xhp b/helpcontent2/source/text/sbasic/shared/02/11100000.xhp new file mode 100644 index 000000000..1fe1f4955 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11100000.xhp @@ -0,0 +1,55 @@ + + + + + +Macros +/text/sbasic/shared/02/11100000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ +

Macros

+ Opens the Macro dialog. +
+
+ + + + + + + Icon Macros + + + Macros + + + +
+
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11110000.xhp b/helpcontent2/source/text/sbasic/shared/02/11110000.xhp new file mode 100644 index 000000000..9a982589e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11110000.xhp @@ -0,0 +1,55 @@ + + + + + +Modules +/text/sbasic/shared/02/11110000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ +

Modules

+ Click here to open the Macro Organizer dialog. +
+
+ + + + + + + Icon Modules + + + Modules + + + +
+
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11120000.xhp b/helpcontent2/source/text/sbasic/shared/02/11120000.xhp new file mode 100644 index 000000000..1a9ee3c26 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11120000.xhp @@ -0,0 +1,55 @@ + + + + + +Find Parentheses +/text/sbasic/shared/02/11120000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ +

Find Parentheses

+ Highlights the text that is enclosed by two corresponding brackets. Place the text cursor in front of an opening or closing bracket, and then click this icon. +
+
+ + + + + + + Icon Find Parentheses + + + Find Parentheses + + + +
+
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11140000.xhp b/helpcontent2/source/text/sbasic/shared/02/11140000.xhp new file mode 100644 index 000000000..a33237355 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11140000.xhp @@ -0,0 +1,55 @@ + + + + + + + + +Insert Source Text +/text/sbasic/shared/02/11140000.xhp + + +Sun Microsystems, Inc. + + + +
+ +Insert Source Text +Opens the Basic source text in the Basic IDE window. +
+Place the cursor in the code where you want to insert the source text, and then click the Insert source text icon. Locate the file that contains the Basic source text that you want to insert, and then click Open. +
+ + + + +Icon + + + +Insert source text + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11150000.xhp b/helpcontent2/source/text/sbasic/shared/02/11150000.xhp new file mode 100644 index 000000000..a08b9245b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11150000.xhp @@ -0,0 +1,54 @@ + + + + + + + + +Save Source As +/text/sbasic/shared/02/11150000.xhp + + +Sun Microsystems, Inc. + + + +
+ +Save Source As +Saves the source code of the selected Basic macro. +
+
+ + + + +Icon + + + +Save Source As + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11160000.xhp b/helpcontent2/source/text/sbasic/shared/02/11160000.xhp new file mode 100644 index 000000000..1345affde --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11160000.xhp @@ -0,0 +1,55 @@ + + + + + +Step Out +/text/sbasic/shared/02/11160000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ +

Step Out

+ Jumps back to the previous routine in the current macro. +
+
+ + + + + + + Icon Step Out + + + Step Out + + + +
+
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/02/11170000.xhp b/helpcontent2/source/text/sbasic/shared/02/11170000.xhp new file mode 100644 index 000000000..f944e2aba --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11170000.xhp @@ -0,0 +1,54 @@ + + + + + + + + + Manage Breakpoints + /text/sbasic/shared/02/11170000.xhp + + + +
+ +Manage Breakpoints + Calls a dialog to manage breakpoints. +
+
+ + + + +Icon + + + + Manage Breakpoints + + +
+ +
+
+ Manage Breakpoints dialog +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/02/11180000.xhp b/helpcontent2/source/text/sbasic/shared/02/11180000.xhp new file mode 100644 index 000000000..594c3cc16 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11180000.xhp @@ -0,0 +1,63 @@ + + + + + + + + + Import Dialog + /text/sbasic/shared/02/11180000.xhp + + + +
+ +Import Dialog + Calls an "Open" dialog to import a BASIC dialog file. + If the imported dialog has a name that already exists in the library, you see a message box where you can decide to rename the imported dialog. In this case the dialog will be renamed to the next free "automatic" name like when creating a new dialog. Or you can replace the existing dialog by the imported dialog. If you click Cancel the dialog is not imported. + Dialogs can contain localization data. When importing a dialog, a mismatch of the dialogs' localization status can occur. + If the library contains additional languages compared to the imported dialog, or if the imported dialog is not localized at all, then the additional languages will silently be added to the imported dialog using the strings of the dialog's default locale. + If the imported dialog contains additional languages compared to the library, or if the library is not localized at all, then you see a message box with Add, Omit, and Cancel buttons. + + + Add: The additional languages from the imported dialog will be added to the already existing dialog. The resources from the library's default language will be used for the new languages. This is the same as if you add these languages manually. + + + Omit: The library's language settings will stay unchanged. The imported dialog's resources for the omitted languages are not copied into the library, but they remain in the imported dialog's source files. + + +
+
+ + + + +Icon + + + + Import Dialog + + +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/02/11190000.xhp b/helpcontent2/source/text/sbasic/shared/02/11190000.xhp new file mode 100644 index 000000000..dc39139a6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/11190000.xhp @@ -0,0 +1,51 @@ + + + + + + + + + Export Dialog + /text/sbasic/shared/02/11190000.xhp + + + +
+ +Export Dialog + In the dialog editor, this command calls a "Save as" dialog to export the current BASIC dialog. +
+
+ + + + +Icon + + + + Export Dialog + + +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/02/20000000.xhp b/helpcontent2/source/text/sbasic/shared/02/20000000.xhp new file mode 100644 index 000000000..c6c9c97f8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/02/20000000.xhp @@ -0,0 +1,474 @@ + + + + + +Insert Controls +/text/sbasic/shared/02/20000000.xhp + + + +
+controls; in dialog editor +push button control in dialog editor +icon control +buttons; controls +image control +check box control +radio button control +option button control +fixed text control +label field control +editing; controls +text boxes; controls +list boxes; controls +combo box control +scroll bar control +horizontal scrollbar control +vertical scrollbar control +group box control +progress bar control +fixed line control +horizontal line control +line control +vertical line control +date field control +time field control +numerical field control +currency field control +formatted field control +pattern field control +masked field control +file selection control +selection options for controls +test mode control + + +

Insert Controls

+Opens the Toolbox bar.
+
+ + + + +Icon Choose Controls + + +Insert Controls + + +
+
+ + +In edit mode, double-click a control to open the properties dialog. + + +In edit mode, you can also right-click a control and choose the cut, copy, and paste command. + + + +
+

Button

+ + + + +Icon Button + + +Adds a command button. You can use a command button to execute a command for a defined event, such as a mouse click. +If you want, you can add text or a graphic to the button. + + +
+
+ +
+

Image Control

+ + + + +Icon Image Control + + +Adds a control that displays a graphic. + + +
+
+
+

Check Box

+ + + + +Icon Check Box + + +Adds a check box that you can use to turn a function on or off. + + +
+
+
+

Option Button

+ + + + +Icon Option Button + + +Adds a button that allows a user to select from a number of options. Grouped option buttons must have consecutive tab order. They are commonly encircled by a group box. If you have two groups of option buttons, you must insert a tab order between the tab orders of the two groups. For example, to the frame of the second group, or to any other control in the dialog, with the exception of another option button. + + +
+
+
+

Label Field

+ + + + +Icon Label Field + + +Adds a field for displaying text labels. These labels are only for displaying predefined text, and not for entering text. + + +
+
+
+

Text Box

+ + + + +Icon Text Box + + +Adds an input box where you can enter and edit text. + + +
+
+
+

List Box

+ + + + +Icon List Box + + +Adds a box where you can click an entry on a list. + + +
+
+
+

Combo Box

+ + + + +Icon Combo Box + + +Adds a combo box. A combo box is a one line list box that a user can click, and then choose an entry from the list. If you want, you can make the entries in the combo box "read only". + + +
+
+
+

Horizontal Scrollbar

+ + + + +Icon Horizontal Scrollbar + + +Adds a horizontal scrollbar to the dialog. + + +
+
+
+

Vertical Scrollbar

+ + + + +Icon Vertical Scrollbar + + +Adds a vertical scrollbar to the dialog. + + +
+
+
+

Group Box

+ + + + +Icon Group Box + + +Adds a frame that you can use to visually group similar controls, such as option buttons. + + +
+
+To define two different groups of option buttons, ensure that the tab index of the group frame is between the tab indices of the two groups. + +
+

Progress Bar

+ + + + +Icon Progress Bar + + +Adds a progress bar to the dialog. + + +
+
+
+

Horizontal Line

+ + + + +Icon Horizontal Line + + +Adds a horizontal line to the dialog. + + +
+
+
+

Vertical Line

+ + + + +Icon Vertical Line + + +Adds a vertical line to the dialog. + + +
+
+
+

Date Field

+ + + + +Icon Date Field + + +Adds a date field. + + +
+If you assign the "dropdown" property to the date field, a user can drop down a calendar to select a date. +
+
+ +

Time Field

+ + + + +Icon Time Field + + +Adds a time field. + + +
+
+
+

Numeric Field

+ + + + +Icon Numeric Field + + +Adds a numeric field. + + +
+
+
+

Currency Field

+ + + + +Icon Currency Field + + +Adds a currency field. + + +
+
+
+

Formatted Field

+ + + + +Icon Formatted Field + + +Adds a text box where you can define the formatting for text that is inputted or outputted as well as any limiting values. + + +
+
+
+

Pattern Field

+ + + + +Icon Pattern Field + + +Adds a masked field. A masked field consists of an input mask and a literal mask. The input mask determines which user data can be entered. The literal mask determines the state of the masked field when the form is loaded. + + +
+
+
+

File Selection

+ + + + +Icon File Selection + + +Adds a button that opens a file selection dialog. + + +
+
+

Select

+ + + + +Icon Select + + +Activates or deactivates the Selection mode. In this mode, you can select the controls in a dialog so that you can edit them. + + +
+

Properties

+ + + + +Icon Properties + + +Opens a dialog where you can edit the properties of the selected control. + + +
+

Activate Test Mode

+ + + + +Icon Activate Test Mode + + +Starts test mode. Click the dialog closer icon to end test mode. + + +
+

Manage Language

+ + + + +Manage Language icon + + +Opens a dialog to enable or manage multiple sets of dialog resources for multiple languages. + + +
+

Tree Control

+ + + + +Icon Tree Control + + +Adds a tree control that can show a hierarchical list. You can populate the list by your program, using API calls (XtreeControl). + + +
+ +

Table Control

+ + + + +Table control icon + + +Adds a table control that can show a table data. You can populate the data by your program, using API calls. + + +
+ +

Hyperlink Control

+ + + + +Insert hyperlink control icon + + +Adds a hyperlink control that can open an address in web browser. + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/avail_release.xhp b/helpcontent2/source/text/sbasic/shared/03/avail_release.xhp new file mode 100644 index 000000000..019363a95 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/avail_release.xhp @@ -0,0 +1,52 @@ + + + + + + (Un)Available since release + /text/sbasic/shared/03/avail_release.xhp + + + +
This method is not available in Basic.
+
This property is not available in Basic.
+
This method is not available in Python.
+
This property is not available in Python.
+ Tags for LibreOffice 7.3 +
+ This service is available from %PRODUCTNAME 7.3 onwards. +
+
+ This method is available from %PRODUCTNAME 7.3 onwards. +
+
+ This property is available from %PRODUCTNAME 7.3 onwards. +
+ Tags for LibreOffice 7.2 +
+ This service is available from %PRODUCTNAME 7.2 onwards. +
+
+ These methods are available from %PRODUCTNAME 7.2 onwards. +
+
+ This method is available from %PRODUCTNAME 7.2 onwards. +
+
+ This control is available from %PRODUCTNAME 7.2 onwards. +
+
+ These event properties are available from %PRODUCTNAME 7.2 onwards. +
+
+ This property is available from %PRODUCTNAME 7.2 onwards. +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_ScriptForge.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_ScriptForge.xhp new file mode 100644 index 000000000..946280ba4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_ScriptForge.xhp @@ -0,0 +1,247 @@ + + + + + + + ScriptForge Libraries + /text/sbasic/shared/03/lib_ScriptForge.xhp + + + +

The ScriptForge Library

+ + BASIC ScriptForge library + Python scriptforge module + +
+ +
+ ScriptForge libraries build up an extensible collection of macro scripting resources for %PRODUCTNAME to be invoked from Basic macros or Python scripts. +
+ • Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Python scripts require an import from scriptforge module:
from scriptforge import CreateScriptService +
+
+ To learn more about how to create and execute Python scripts using the ScriptForge library, read the help page Creating Python Scripts with ScriptForge. + +

Invoking ScriptForge services

+ The described modules and classes are invoked from user scripts as "Services". A generic constructor of those services has been designed for that purpose for each language. + The Dispose method is available in all services and should be called to free up resources after usage: + + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Set oSvc = CreateScriptService("servicename"[, arg0, arg1, ...]) + ' ... + oSvc.Dispose() + + + + from scriptforge import CreateScriptService + svc = CreateScriptService('servicename'[, arg0, arg1, ...]) + # ... + svc.Dispose() + + +

Services provided by the ScriptForge library

+ + + + + Category + + + Services + + + + + + %PRODUCTNAME Basic + + + + Array
+ Dictionary
+
+
+ + + Exception
+ FileSystem
+
+
+ + + String
+ TextStream
+
+
+
+ + + Document Content + + + + Base
+ Calc
+
+
+ + + Chart
+ Database
+
+
+ + + Document
+ Writer
+
+
+
+ + + User Interface + + + + Dialog
+ DialogControl
+ Form
+
+
+ + + FormControl
+ Menu

+
+
+ + + PopupMenu
+ UI

+
+
+
+ + + Utilities + + + + Basic
+ L10N
+ Platform
+
+
+ + + Region
+ Services
+ Session
+
+
+ + + Timer
+ UnitTest

+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ Restricted use for SF_Root, SF_Utils modules as well as internal methods + Note: Other ScriptForge undescribed modules are reserved for internal use. Their content is subject to change without notice. +
+ All ScriptForge Basic routines or identifiers that are prefixed with an underscore character "_" are reserved for internal use. They are not meant be used in Basic macros or Python scripts. +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_depot.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_depot.xhp new file mode 100644 index 000000000..2c4a01ba1 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_depot.xhp @@ -0,0 +1,28 @@ + + + + + + + DEPOT Library + /text/sbasic/shared/03/lib_depot.xhp + + + + The Depot Library + +
+ +
+
+ GlobalScope.BasicLibraries.LoadLibrary("Depot")
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_euro.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_euro.xhp new file mode 100644 index 000000000..d975c69d4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_euro.xhp @@ -0,0 +1,46 @@ + + + + + + + EURO Library + /text/sbasic/shared/03/lib_euro.xhp + + + +

The Euro Library

+ + BASIC Euro library + +
+ +
+ +

Description

+ The Euro library is used by the Euro converter… wizard. + Its entry points are: + + Euro.AutoPilotRun.StartAutoPilot + Euro.ConvertRun.Main + + Selecting the Euro Converter wizard loads the following libraries in memory: + + Euro + ImportWizard + Tools + + Basic routine name conflicts may exist when multiple Basic libraries are loaded in memory. +
+ ImportWizard and Tools Basic libraries + Euro Converter Wizard describes what the Euro library does. +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_formwizard.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_formwizard.xhp new file mode 100644 index 000000000..c3ff82a11 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_formwizard.xhp @@ -0,0 +1,28 @@ + + + + + + + FORMWIZARD Library + /text/sbasic/shared/03/lib_formwizard.xhp + + + + The FormWizard Library + +
+ +
+
+ GlobalScope.BasicLibraries.LoadLibrary("FormWizard")
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_gimmicks.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_gimmicks.xhp new file mode 100644 index 000000000..01c7d0171 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_gimmicks.xhp @@ -0,0 +1,51 @@ + + + + + + + GIMMICKS Library + /text/sbasic/shared/03/lib_gimmicks.xhp + + + + The Gimmicks Library + + BASIC Gimmicks library + +
+ +
+ + + +
+ GlobalScope.BasicLibraries.LoadLibrary("Gimmicks")
+ +

Description

+ The Gimmicks library is used by the AutoText wizard. + Its entry points are: + + Gimmicks.AutoText.Main + Gimmicks.GetTexts.Main + + + Selecting Tools - AutoText loads the following library in memory: + + Tools + + Basic routine name conflicts may exist when multiple Basic libraries are loaded in memory. + +
+ Tools Basic library + Using AutoText explains what the Gimmicks library does. +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_importwiz.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_importwiz.xhp new file mode 100644 index 000000000..20669ec99 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_importwiz.xhp @@ -0,0 +1,44 @@ + + + + + + ImportWizard Library + /text/sbasic/shared/03/lib_importwiz.xhp + + + +

The ImportWizard Library

+ + BASIC ImportWizard library + +
+ + +
+ +

Description

+ The ImportWizard library is used by the Document Converter wizard. + Its entry point is: + + ImportWizard.Main.Main + + Selecting the Document Converter wizard loads the following libraries in memory: + + ImportWizard + Tools + + Basic routine name conflicts may exist when multiple Basic libraries are loaded in memory. +
+ Tools Basic library + Document Converter describes what the ImportWizard library does. +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_schedule.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_schedule.xhp new file mode 100644 index 000000000..00cf3dcc8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_schedule.xhp @@ -0,0 +1,30 @@ + + + + + + + SCHEDULE Library + /text/sbasic/shared/03/lib_schedule.xhp + + + + The Schedule Library + + BASIC Schedule library + +
+ +
+
+ GlobalScope.BasicLibraries.LoadLibrary("Schedule")
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_script.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_script.xhp new file mode 100644 index 000000000..c2ef92b9b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_script.xhp @@ -0,0 +1,35 @@ + + + + + + + SCRIPTBINDINGLIBRARY Library + /text/sbasic/shared/03/lib_script.xhp + + + +

The ScriptBindingLibrary Library

+ + BASIC ScriptBindingLibrary library + +
+ +
+

Description

+ The ScriptBindingLibrary library only contains dialogs, it is used by Highlight %PRODUCTNAME example scripts. Its dialogs are shared by Beanshell, Java and JavaScript example scripts. + Running any Highlight example script loads the ScriptBindingLibrary library in memory. + This library is not used by %PRODUCTNAME Basic. +
+ Basic macro selector + Beanshell, Java and JavaScript Scripts +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_template.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_template.xhp new file mode 100644 index 000000000..f7e093fa0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_template.xhp @@ -0,0 +1,28 @@ + + + + + + + TEMPLATE Library + /text/sbasic/shared/03/lib_template.xhp + + + + The Template Library + +
+ +
+
+ GlobalScope.BasicLibraries.LoadLibrary("Template")
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_tools.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_tools.xhp new file mode 100644 index 000000000..2ed625b5a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_tools.xhp @@ -0,0 +1,842 @@ + + + + + + + Tools Library + /text/sbasic/shared/03/lib_tools.xhp + + + + The Tools Library + + BASIC Tools library + +
+ +
+
+ GlobalScope.BasicLibraries.LoadLibrary("Tools")
+ Debug Module + ListBox Module + Misc Module + ModuleControls Module + Strings Module + UCB Module + + BASIC Tools library;Debug module + +
+ Debug Module + Functions and subroutines for debugging Basic macros. +

ActivateReadOnlyFlag

+ + Sub ActivateReadOnlyFlag() + +

DeactivateReadOnlyFlag

+ + Sub DeactivateReadOnlyFlag() + +

SetBasicReadOnlyFlag

+ + Sub SetBasicReadOnlyFlag(bReadOnly as Boolean) + +

WritedbgInfo

+ + Sub WritedbgInfo(LocObject as Object) + +

WriteDbgString

+ + Sub WriteDbgString(LocString as String) + +

ShowArray

+ + Sub ShowArray(LocArray()) + +

ShowPropertyValues

+ + Sub ShowPropertyValues(oLocObject as Object) + +

ShowNameValuePair

+ + Sub ShowNameValuePair(Pair()) + +

ShowElementNames

+ ' Retrieves all the Elements of aSequence of an object, with the + ' possibility to define a filter(sfilter <> "") + + Sub ShowElementNames( + oLocElements() as Object, + Optional sFiltername as String) + +

ShowSupportedServiceNames

+ ' Retrieves all the supported servicenames of an object, with the + ' possibility to define a filter(sfilter <> "") + + Sub ShowSupportedServiceNames( + oLocObject as Object, + Optional sFilterName as String) + +

ShowAvailableServiceNames

+ ' Retrieves all the available Servicenames of an object, with the + ' possibility to define a filter(sfilter <> "") + + Sub ShowAvailableServiceNames( + oLocObject as Object, + Optional sFilterName as String) + +

ShowCommands

+ + Sub ShowCommands(oLocObject as Object) + +

ProtectCurrentSheets

+ + Sub ProtectCurrentSheets() + +

FillDocument

+ + Sub FillDocument() + +
+ + BASIC Tools library;ListBox module + +
+ ListBox Module + Functions and subroutines for handling ListBox elements. + +
+ + BASIC Tools library;Misc module + +
+ Misc Module + Miscellaneous functions and subroutines. +

RegisterNewDataSource

+ + Function RegisterNewDataSource( + DSName as String, + PropertyList(), + Optional DriverProperties() + as New com.sun.star.beans.PropertyValue) + +

ConnecttoDatabase

+ + Function ConnecttoDatabase( + DSName as String, + UserID as String, + Password as String, + Optional Propertylist(), + Optional DriverProperties() + as New com.sun.star.beans.PropertyValue) + +

GetStarOfficeLocale

+ + Function GetStarOfficeLocale() + as New com.sun.star.lang.Locale + +

GetRegistryKeyContent

+ + Function GetRegistryKeyContent( + sKeyName as string, + Optional bforUpdate as Boolean) + +

GetProductname

+ + Function GetProductname() as String + +

OpenDocument

+ ' Opens a Document, checks beforehand, whether it has to be loaded or whether it is already on the desktop. If the parameter bDisposable is set to False then the returned document should not be disposed afterwards, because it is already opened. + + Function OpenDocument( + DocPath as String, + Args(), + Optional bDisposable as Boolean) + +

TaskonDesktop

+ + Function TaskonDesktop(DocPath as String) as Boolean + +

RetrieveFileName

+ ' Retrieves a FileName out of a StarOffice-Document. + + Function RetrieveFileName(LocDoc as Object) + +

GetPathSettings

+ ' Gets a special configured PathSetting. + + Function GetPathSettings( + sPathType as String, + Optional bshowall as Boolean, + Optional ListIndex as integer) as String + +

GetOfficeSubPath

+ ' Gets the fully qualified path to a subdirectory of the Template Directory, e. g. with the parameter "wizard/bitmap". The parameter must be passed over in Url-scription. The return-Value is in Urlscription. + + Function GetOfficeSubPath( + sOfficePath as String, + ByVal sSubDir as String) + +

ShowNoOfficePathError

+ + Sub ShowNoOfficePathError() + +

InitResources

+ + Function InitResources( + Description, + ShortDescription as String) as boolean + +

GetResText

+ + Function GetResText( nID as integer ) As string + +

CutPathView

+ + Function CutPathView( + sDocUrl as String, + Optional PathLen as Integer) + +

DeleteInputCells

+ ' Deletes the content of all cells that are softformatted according to the 'InputStyleName'. + + Sub DeleteInputCells( + oSheet as Object, + InputStyleName as String) + +

ChangeValueofRange

+ ' Inserts a certain String to all cells of a Range that is passed over either as an object or as the RangeName. + + Sub ChangeValueofRange( + oSheet as Object, + Range, + ReplaceValue, + Optional StyleName as String) + +

ReplaceRangeValues

+ + Sub ReplaceRangeValues( + oRange as Object, + ReplaceValue) + +

GetValueofCellbyName

+ ' Returns the Value of the first cell of a Range. + + Function GetValueofCellbyName( + oSheet as Object, + sCellName as String) + +

DuplicateRow

+ + Function DuplicateRow( + oSheet as Object, + RangeName as String) + +

GetStringofCellbyName

+ ' Returns the String of the first cell of a Range. + + Function GetStringofCellbyName( + oSheet as Object, + sCellName as String) + +

GetCellByName

+ ' Returns a named Cell + + Function GetCellByName( + oSheet as Object, + sCellName as String) as Object + +

ChangeCellValue

+ ' Changes the numeric Value of a cell by transmitting the String of the numeric Value. + + Sub ChangeCellValue( + oCell as Object, + ValueString as String) + +

GetDocumentType

+ + Function GetDocumentType(oDocument) + +

GetNumberFormatType

+ + Function GetNumberFormatType( + oDocFormats, + oFormatObject as Object) as Integer + +

ProtectSheets

+ + Sub ProtectSheets(Optional oSheets as Object) + +

UnprotectSheets

+ + Sub UnprotectSheets(Optional oSheets as Object) + +

GetRowIndex

+ + Function GetRowIndex( + oSheet as Object, + RowName as String) + +

GetColumnIndex

+ + Function GetColumnIndex( + oSheet as Object, + ColName as String) + +

CopySheetbyName

+ + Function CopySheetbyName( + oSheets as Object, + OldName as String, + NewName as String, + DestPos as Integer) as Object + +

ToggleWindow

+ ' Dis-or enables a Window and adjusts the mousepointer accordingly + + Sub ToggleWindow(bDoEnable as Boolean) + +

CheckNewSheetname

+ + Function CheckNewSheetname( + oSheets as Object, + Sheetname as String, + Optional oLocale) as String + +

AddNewSheetName

+ + Sub AddNewSheetName( + oSheets as Object, + ByVal SheetName as String) + +

GetSheetIndex

+ + Function GetSheetIndex(oSheets, sName) as Integer + +

GetLastUsedRow

+ + Function GetLastUsedRow(oSheet as Object) as Integer + +

ModifyBorderLineWidth

+ ' Note To set a one lined frame you have to set the inner width to 0 In the API all Units that refer to pt-Heights are "1/100mm" The convert factor from 1pt to 1/100 mm is approximately 35 + + Function ModifyBorderLineWidth( + ByVal oStyleBorder, + iInnerLineWidth as Integer, + iOuterLineWidth as Integer) + +

AttachBasicMacroToEvent

+ + Sub AttachBasicMacroToEvent( + oDocument as Object, + EventName as String, + SubPath as String) + +

ModifyPropertyValue

+ + Function ModifyPropertyValue( + oContent() as New com.sun.star.beans.PropertyValue, + TargetProperties() + as New com.sun.star.beans.PropertyValue) + +

GetPropertyValueIndex

+ + Function GetPropertyValueIndex( + SearchName as String, + TargetProperties() + as New com.sun.star.beans.PropertyValue ) as Integer + +

DispatchSlot

+ + Sub DispatchSlot(SlotID as Integer) + +

IsFatOffice

+ 'returns the type of the office application FatOffice = 0, WebTop = 1 This routine has to be changed if the Product Name is being changed! + + Function IsFatOffice() As Boolean + +

GetLocale

+ + Function GetLocale( + sLanguage as String, + sCountry as String) + +

ToggleDesignMode

+ + Sub ToggleDesignMode(oDocument as Object) + +

isHighContrast

+ + Function isHighContrast(oPeer as Object) + +

CreateNewDocument

+ + Function CreateNewDocument( + sType as String, + Optional sAddMsg as String) as Object + +

DisposeDocument

+ ' This Sub has been used in order to ensure that after disposing a document from the backing window it is returned to the backing window, so the office won't be closed + + Sub DisposeDocument(oDocument as Object) + +

CalIsLeapYear

+ 'Function to calculate if the year is a leap year + + Function CalIsLeapYear( + ByVal iYear as Integer) as Boolean + +
+ + BASIC Tools library;ModuleControl module + +
+ ModuleControls Module + Functions and subroutines for module control. +

GetControlShape

+ ' Gets the Shape of a Control( e. g. to reset the size or Position of the control + ' Parameters: + ' The 'oContainer' is the Document or a specific sheet of a Calc - Document + ' 'CName' is the Name of the Control + + Function GetControlShape( + oContainer as Object, + CName as String) + +

getControlView

+ ' Returns the View of a Control + ' Parameters: + ' The 'oContainer' is the Document or a specific sheet of a Calc - Document + ' The 'oController' is always directly attached to the Document + ' 'CName' is the Name of the Control + + Function getControlView( + oContainer , + oController as Object, + CName as String) as Object + +

DisposeControl

+ ' Parameters: + ' The 'oContainer' is the Document or a specific sheet of a Calc - Document + ' 'CName' is the Name of the Control + + Function DisposeControl( + oContainer as Object, + CName as String) as Boolean + +

GetControlGroupModel

+ ' Returns a sequence of a group of controls like option buttons or checkboxes + ' The 'oContainer' is the Document or a specific sheet of a Calc - Document + ' 'sGroupName' is the Name of the Controlgroup + + Function GetControlGroupModel( + oContainer as Object, + sGroupName as String ) + +

GetRefValue

+ ' Returns the Referencevalue of a group of e.g. option buttons or check boxes + ' 'oControlGroup' is a sequence of the Control objects + + Function GetRefValue( + oControlGroup() as Object) + +

GetRefValueOfControlGroup

+ + Function GetRefValueOfControlGroup( + oContainer as Object, + GroupName as String) + +

GetOptionGroupValue

+ + Function GetOptionGroupValue( + oContainer as Object, + OptGroupName as String) as Boolean + +

WriteOptValueToCell

+ + Function WriteOptValueToCell( + oSheet as Object, + OptGroupName as String, + iCol as Integer, + iRow as Integer) as Boolean + +

LoadDialog

+ + Function LoadDialog( + Libname as String, + DialogName as String, + Optional oLibContainer) + + Refer to Opening a Dialog with Basic for an example of LoadDialog function. +

GetFolderName

+ + Sub GetFolderName(oRefModel as Object) + +

GetFileName

+ + Sub GetFileName( + oRefModel as Object, + Filternames()) + +

StoreDocument

+ + Function StoreDocument( + oDocument as Object, + FilterNames() as String, + DefaultName as String, + DisplayDirectory as String, + Optional iAddProcedure as Integer) as String + +

AddFiltersToDialog

+ + Sub AddFiltersToDialog( + FilterNames() as String, + oDialog as Object) + +

SwitchMousePointer

+ + Sub SwitchMousePointer( + oWindowPeer as Object, + bDoEnable as Boolean) + +

ShowOverwriteAllDialog

+ + Sub ShowOverwriteAllDialog( + FilePath as String, + sTitle as String) + +

SetOVERWRITEToQuery

+ + Sub SetOVERWRITEToQuery() + +

SetOVERWRITEToAlways

+ + Sub SetOVERWRITEToAlways() + +

SetOVERWRITEToNever

+ + Sub SetOVERWRITEToNever() + +
+ + BASIC Tools library;Strings module + +
+ Strings Module + Advanced functions and subroutines for string manipulation. +

ElimChar

+ + Function ElimChar( + ByVal BigString as String, + ElimArray() as String) + +

DeleteStr

+ ' Deletes out of a String 'BigString' a possible Partstring 'CompString' + + Function DeleteStr( + ByVal BigString, + CompString as String) as String + +

FindPartString

+ ' Finds a PartString, that is framed by the Strings 'Prestring' and 'PostString' + + Function FindPartString( + BigString, + PreString, + PostString as String, + SearchPos as Integer) as String + +

PartStringInArray

+ ' Note iCompare = 0 (Binary comparison) + ' iCompare = 1 (Text comparison) + + Function PartStringInArray( + BigArray(), + SearchString as String, + iCompare as Integer) as Integer + +

RTrimStr

+ ' Deletes the String 'SmallString' out of the String 'BigString' + ' in case SmallString's Position in BigString is right at the end + + Function RtrimStr( + ByVal BigString, + SmallString as String) as String + +

LTRimChar

+ ' Deletes the Char 'CompChar' out of the String 'BigString' + ' in case CompChar's Position in BigString is right at the beginning + + Function LTRimChar( + ByVal BigString as String, + CompChar as String) as String + +

ArrayOutOfString

+ ' Retrieves an Array out of a String. + ' The fields of the Array are separated by the parameter 'Separator', that is contained + ' in the Array + ' The Array MaxIndex delivers the highest Index of this Array + + Function ArrayOutOfString( + BigString, + Separator as String, + Optional MaxIndex as Integer) + +

ClearArray

+ ' Deletes all fieldvalues in one-dimensional Array + + Sub ClearArray(BigArray) + +

ClearMultiDimArray

+ ' Deletes all fieldvalues in a multidimensional Array + + Sub ClearMultiDimArray( + BigArray, + DimCount as integer) + +

FieldinArray

+ ' Checks if a Field (LocField) is already defined in an Array + ' Returns 'True' or 'False' + + Function FieldinArray( + LocArray(), + MaxIndex as integer, + LocField as String) As Boolean + +

FieldinList

+ ' Checks if a Field (LocField) is already defined in an Array + ' Returns 'True' or 'False' + + Function FieldinList( + LocField, + BigList()) As Boolean + +

IndexinArray

+ ' Retrieves the Index of the delivered String 'SearchString' in + ' the Array LocList()' + + Function IndexinArray( + SearchString as String, + LocList()) as Integer + +

MultiArrayInListbox

+ + Sub MultiArrayInListbox( + oDialog as Object, + ListboxName as String, + ValList(), + iDim as Integer) + +

StringInMultiArray

+ ' Searches for a String in a two-dimensional Array by querying all Searchindexes of the second dimension + ' and delivers the specific String of the ReturnIndex in the second dimension of the Searchlist() + + Function StringInMultiArray( + SearchList(), + SearchString as String, + SearchIndex as Integer, + ReturnIndex as Integer, + Optional MaxIndex as Integer) as String + +

GetIndexInMultiArray

+ ' Searches for a Value in multidimensial Array by querying all Searchindices of the passed dimension + ' and delivers the Index where it is found. + + Function GetIndexInMultiArray( + SearchList(), + SearchValue, + SearchIndex as Integer) as Integer + +

GetIndexForPartString_

+ inMultiArray + ' Searches for a Value in multidimensial Array by querying all Searchindices of the passed dimension + ' and delivers the Index where the Searchvalue is found as a part string + + Function GetIndexForPartStringinMultiArray( + SearchList(), + SearchValue, + SearchIndex as Integer) as Integer + +

ArrayfromMultiArray

+ + Function ArrayfromMultiArray( + MultiArray as String, + iDim as Integer) + +

ReplaceString

+ ' Replaces the string "OldReplace" through the String "NewReplace" in the String + ' 'BigString' + + Function ReplaceString( + ByVal Bigstring, + NewReplace, + OldReplace as String) as String + +

FindSecondValue

+ ' Retrieves the second value for a next to 'SearchString' in + ' a two-dimensional string-Array + + Function FindSecondValue( + SearchString as String, + TwoDimList() as String ) as String + +

Power

+ ' raises a base to a certain power + + Function Power( + Basis as Double, + Exponent as Double) as Double + +

Round

+ ' rounds a Real to a given Number of Decimals + + Function Round( + BaseValue as Double, + Decimals as Integer) as Double + +

FileNameoutofPath

+ 'Retrieves the mere filename out of a whole path + + Function FileNameoutofPath( + ByVal Path as String, + Optional Separator as String) as String + +

GetFileNameExtension

+ + Function GetFileNameExtension( + ByVal FileName as String) + +

GetFileNameWithoutExtension

+ + Function GetFileNameWithoutExtension( + ByVal FileName as String, + Optional Separator as String) + +

DirectoryNameoutofPath

+ + Function DirectoryNameoutofPath( + sPath as String, + Separator as String) as String + +

CountCharsinString

+ + Function CountCharsinString( + BigString, + LocChar as String, + ByVal StartPos as Integer) as Integer + +

BubbleSortList

+ + Function BubbleSortList( + ByVal SortList(), + optional sort2ndValue as Boolean) + + 'This function bubble sorts an array of maximum 2 dimensions. + 'The default sorting order is the first dimension + 'Only if sort2ndValue is True the second dimension is the relevant for the sorting order +

GetValueoutofList

+ + Function GetValueoutofList( + SearchValue, + BigList(), + iDim as Integer, + Optional ValueIndex) + +

AddListtoList

+ + Function AddListtoList( + ByVal FirstArray(), + ByVal SecondArray(), + Optional StartIndex) + +

CheckDouble

+ + Function CheckDouble(DoubleString as String) + +
+ + BASIC Tools library;UCB module + +
+ UCB Module + Universal Content Broker functions and subroutines. +

ReadDirectories

+ + Function ReadDirectories( + ByVal AnchorDir As String, + bRecursive as Boolean, + bcheckFileType as Boolean, + bGetByTitle as Boolean, + Optional sFileContent(), + Optional sExtension as String) + +

AddFoldertoList

+ + Sub AddFoldertoList( + sDirURL as String, + iDirIndex) + +

AddFileNameToList

+ + Sub AddFileNameToList( + sFileArray(), + FileName as String, + FileContent as String, + bGetByTitle as Boolean, + CurIndex) + +

RetrieveDocTitle

+ + Function RetrieveDocTitle( + oDocProps as Object, + sFileName as String) As String + +

GetRealFileContent

+ ' Retrieves The Filecontent of a Document by extracting the content + ' from the Header of the document + + Function GetRealFileContent( + FileName as String) As String + +

CopyRecursively

+ + Function CopyRecursively( + SourceFilePath as String, + SourceStemDir as String, + TargetStemDir as String) + +

ShowHelperDialog

+ ' Opens a help url referenced by a Help ID that is retrieved from the calling button tag + + Sub ShowHelperDialog(aEvent) + +

SaveDataToFile

+ + Sub SaveDataToFile( + FilePath as String, + DataList()) + +

LoadDataFromFile

+ + Function LoadDataFromFile( + FilePath as String, + DataList()) as Boolean + +

CreateFolder

+ + Function CreateFolder(sNewFolder) as Boolean + +
+
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/lib_wikieditor.xhp b/helpcontent2/source/text/sbasic/shared/03/lib_wikieditor.xhp new file mode 100644 index 000000000..2bf31fc1a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/lib_wikieditor.xhp @@ -0,0 +1,30 @@ + + + + + + WikiEditor Library + /text/sbasic/shared/03/lib_wikieditor.xhp + + + +

The WikiEditor Library

+ + BASIC WikiEditor library + +
+ +
+ +

Description

+ The WikiEditor library only contains dialogs, it is used by Wiki Publisher bundled Java extension. + This library is not used by %PRODUCTNAME Basic. + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_array.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_array.xhp new file mode 100644 index 000000000..241bbd408 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_array.xhp @@ -0,0 +1,968 @@ + + + + + + ScriptForge.Array service (SF_Array) + /text/sbasic/shared/03/sf_array.xhp + + + + +
+ + Array service + + +

ScriptForge.Array service

+ Provides a collection of methods for manipulating and transforming arrays of one dimension (vectors) and arrays of two dimensions (matrices). This includes set operations, sorting, importing from and exporting to text files. + Arrays with more than two dimensions cannot be used with the methods in this service, the only exception being the CountDims method that accepts Arrays with any number of dimensions. +
+ + Array items may contain any type of value, including (sub)arrays. + +

Service invocation

+ Before using the Array service the ScriptForge library needs to be loaded using: + + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + + Loading the library will create the SF_Array object that can be used to call the methods in the Array service. + The following code snippets show the various ways to call methods in the Array service (the Append method is used as an example): + + Dim arr : arr = Array(1, 2, 3) + arr = SF_Array.Append(arr, 4) + + + Dim arr : arr = Array(1, 2, 3) + Dim svc : svc = SF_Array + arr = svc.Append(arr, 4) + + + Dim arr : arr = Array(1, 2, 3) + Dim svc : svc = CreateScriptService("Array") + arr = svc.Append(arr, 4) + + Because Python has built-in list and tuple support, most of the methods in the Array service are available for Basic scripts only. The only exception is ImportFromCSVFile which is supported in both Basic and Python. + + + List of Methods in the Array Service + + + + Append
+ AppendColumn
+ AppendRow
+ Contains
+ ConvertToDictionary
+ Copy
+ CountDims
+ Difference
+ ExportToTextFile
+ ExtractColumn
+ ExtractRow
+
+ + Flatten
+ ImportFromCSVFile
+ IndexOf
+ Insert
+ InsertSorted
+ Intersection
+ Join2D
+ Prepend
+ PrependColumn
+ PrependRow
+ RangeInit
+
+ + Reverse
+ Shuffle
+ Slice
+ Sort
+ SortColumns
+ SortRows
+ Transpose
+ TrimArray
+ Union
+ Unique

+
+
+
+ The first argument of most methods is the array object to be considered. It is always passed by reference and left unchanged. Methods such as Append, Prepend, etc return a new array object after their execution. + +
+ Append --------------------------------------------------------------------------------------------- + + Array service;Append + +

Append

+ Appends the items listed as arguments to the end of the input array. + + + svc.Append(array_1d: any[0..*], arg0: any, [arg1: any] ...): any[0..*] + + + array_1d: The pre-existing array, may be empty. + arg0, arg1, ...: Items that will be appended to array_1d. + + + Dim a As Variant + a = SF_Array.Append(Array(1, 2, 3), 4, 5) + ' (1, 2, 3, 4, 5) + +
+ +
+ AppendColumn --------------------------------------------------------------------------------------- + + Array service;AppendColumn + +

AppendColumn

+ Appends a new column to the right side of a two dimensional array. The resulting array has the same lower bounds as the initial two dimensional array. + + + svc.AppendColumn(array_2d: any[0..*, 0..*], column: any[0..*]): any[0..*, 0..*] + + + array_2d: The pre-existing array, may be empty. If that array has only one dimension, it is considered as the first column of the resulting two-dimensional array. + column: A 1-dimensional array with as many items as there are rows in array_2d. + + + Dim a As Variant, b As variant + a = SF_Array.AppendColumn(Array(1, 2, 3), Array(4, 5, 6)) + ' ((1, 4), (2, 5), (3, 6)) + b = SF_Array.AppendColumn(a, Array(7, 8, 9)) + ' ((1, 4, 7), (2, 5, 8), (3, 6, 9)) + c = SF_Array.AppendColumn(Array(), Array(1, 2, 3)) + ' ∀ i ∈ {0 ≤ i ≤ 2} : b(0, i) ≡ i + +
+ +
+ AppendRow ------------------------------------------------------------------------------------------ + + Array service;AppendRow + +

AppendRow

+ Append to the bottom of a two dimension array a new row. The resulting array has the same lower bounds as the initial two dimension array. + + + svc.AppendRow(array_2d: any[0..*, 0..*], row: any[0..*]): any[0..*, 0..*]) + + + array_2d: The pre-existing array, may be empty. If that array has 1 dimension, it is considered as the first row of the resulting 2 dimension array. + row: A 1-dimensional array with as many items as there are columns in array_2d. + + + Dim a As Variant, b As variant + a = SF_Array.AppendRow(Array(1, 2, 3), Array(4, 5, 6)) + ' ((1, 2, 3), (4, 5, 6)) + b = SF_Array..AppendRow(Array(), Array(1, 2, 3)) + ' ∀ i ∈ {0 ≤ i ≤ 2} : b(i, 0) ≡ i + +
+ +
+ Contains ------------------------------------------------------------------------------------------- + + Array service;Contains + +

Contains

+ Check if a one dimension array contains a certain number, text or date. Text comparison can be case-sensitive or not. +
Sorted input arrays must be filled homogeneously, meaning all items must be scalars of the same type (Empty and Null items are forbidden). +
The result of the method is unpredictable when the array is announced as sorted and is in reality not. +
A binary search is done when the array is sorted, otherwise, it is simply scanned from top to bottom and Empty and Null items are ignored.
+ + + svc.Contains(array_1d: any[0..*], tofind: any, casesensitive: bool = False, sortorder: str = ""): bool + + + array_1d: The array to scan. + tofind: A number, a date or a string to find. + casesensitive: Only for string comparisons (Default = False). + sortorder: It can be either "ASC", "DESC" or "" (not sorted). The default value is "". + + + Dim a As Variant + a = SF_Array.Contains(Array("A","B","c","D"), "C", SortOrder := "ASC") ' True + SF_Array.Contains(Array("A","B","c","D"), "C", CaseSensitive := True) ' False + +
+ +
+ ConvertToDictionary ------------------------------------------------------------------------------------ + + Array service;ConvertToDictionary + +

ConvertToDictionary

+ Store the content of a 2-columns array into a ScriptForge.Dictionary object. +
The key will be extracted from the first column, the item from the second.
+ + + svc.ConvertToDictionary(array_2d: any[0..*, 0..1]): obj + + + array_2d: Data to be converted into a ScriptForge.Dictionary object. + + + The first column must contain exclusively strings with a length greater than zero, in any order. These values will be used as labels in the dictionary. + + + The second column contains the data that will be associated to the corresponding label in the dictionary. + + + + + Dim a As Variant, b As Variant + a = SF_Array.AppendColumn(Array("a", "b", "c"), Array(1, 2, 3)) + b = SF_Array.ConvertToDictionary(a) + MsgBox b.Item("c") ' 3 + +
+ +
+ Copy --------------------------------------------------------------------------------------------------- + + Array service;Copy + +

Copy

+ Creates a copy of a 1D or 2D array. + + + svc.Copy(array_nd: any[0..*]): any[0..*] + + + svc.Copy(array_nd: any[0..*, 0..*]): any[0..*, 0..*] + + + array_nd: The 1D or 2D array to be copied. + + A simple assignment of an Array object will copy its reference instead of creating a copy of the object's contents. See the example below: + + Dim a as Variant, b as Variant + a = Array(1, 2, 3) + ' The assignment below is made by reference + b = a + ' Hence changing values in "b" will also change "a" + b(0) = 10 + MsgBox a(0) ' 10 + + By using the Copy method, a copy of the whole Array object is made. In the example below, a and b are different objects and changing values in b will not affect values in a. + + Dim a as Variant, b as Variant + a = Array(1, 2, 3) + ' Creates a copy of "a" using the "Copy" method + b = SF_Array.Copy(a) + b(0) = 10 + MsgBox a(0) ' 1 + +
+ +
+ CountDims ---------------------------------------------------------------------------------------------- + + Array service;CountDims + +

CountDims

+ Count the number of dimensions of an array. The result can be greater than two. +
If the argument is not an array, returns -1 +
If the array is not initialized, returns 0.
+ + + svc.CountDims(array_nd: any): int + + + array_nd: The array to examine. + + + Dim a(1 To 10, -3 To 12, 5) + MsgBox SF_Array.CountDims(a) ' 3 + +
+ +
+ Difference --------------------------------------------------------------------------------------------- + + Array service;Difference + +

Difference

+ Build a set, as a zero-based array, by applying the difference operator on the two input arrays. Resulting items originate from the first array and not from the second. +
The resulting array is sorted in ascending order. +
Both input arrays must be filled homogeneously, their items must be scalars of the same type. Empty and Null items are forbidden. +
Text comparison can be case sensitive or not.
+ + + svc.Difference(array1_1d: any[0..*], array2_1d: any[0..*], casesensitive: bool = False): any[0..*] + + + array1_1d: A 1-dimensional reference array, whose items are examined for removal. + array2_1d: A 1-dimensional array, whose items are subtracted from the first input array. + casesensitive: This argument is only applicable if the arrays are populated with strings (Default = False). + + + Dim a As Variant + a = SF_Array.Difference(Array("A", "C", "A", "b", "B"), Array("C", "Z", "b"), True) + ' ("A", "B") + +
+ +
+ ExportToTextFile --------------------------------------------------------------------------------------- + + Array service;ExportToTextFile + +

ExportToTextFile

+ Write all items of the array sequentially to a text file. If the file exists already, it will be overwritten without warning. + + + svc.ExportToTextFile(array_1d: any[0..*], filename: str, [encoding: str]): bool + + + array_1d: The array to export. It must contain only strings. + filename: The name of the text file where the data will be written to. The name must be expressed according to the current FileNaming property of the SF_FileSystem service. + encoding: The character set that should be used. Use one of the names listed in IANA character sets. Note that %PRODUCTNAME may not implement all existing character sets (Default is "UTF-8"). + + + SF_Array.ExportToTextFile(Array("A","B","C","D"), "C:\Temp\A short file.txt") + +
+ +
+ ExtractColumn ------------------------------------------------------------------------------------------ + + Array service;ExtractColumn + +

ExtractColumn

+ Extract from a two dimension array a specific column as a new array. +
Its lower LBound and upper UBound boundaries are identical to that of the first dimension of the input array.
+ + + svc.ExtractColumn(array_2d: any[0..*, 0..*], columnindex: int): any[0..*, 0..*] + + + array_2d: The array from which to extract. + columnindex: The column number to extract - must be in the interval [LBound, UBound]. + + + 'Creates a 3x3 matrix: |1, 2, 3| + ' |4, 5, 6| + ' |7, 8, 9| + Dim mat as Variant, col as Variant + mat = SF_Array.AppendRow(Array(), Array(1, 2, 3)) + mat = SF_Array.AppendRow(mat, Array(4, 5, 6)) + mat = SF_Array.AppendRow(mat, Array(7, 8, 9)) + 'Extracts the third column: |3, 6, 9| + col = SF_Array.ExtractColumn(mat, 2) + +
+ +
+ ExtractRow --------------------------------------------------------------------------------------------- + + Array service;ExtractRow + +

ExtractRow

+ Extract from a two dimension array a specific row as a new array. +
Its lower LBound and upper UBound boundaries are identical to that of the second dimension of the input array.
+ + + svc.ExtractRow(array_2d: any[0..*, 0..*], rowindex: int): any[0..*, 0..*] + + + array_2d: The array from which to extract. + rowindex: The row number to extract - must be in the interval [LBound, UBound]. + + + 'Creates a 3x3 matrix: |1, 2, 3| + ' |4, 5, 6| + ' |7, 8, 9| + Dim mat as Variant, row as Variant + mat = SF_Array.AppendRow(Array(), Array(1, 2, 3)) + mat = SF_Array.AppendRow(mat, Array(4, 5, 6)) + mat = SF_Array.AppendRow(mat, Array(7, 8, 9)) + 'Extracts the first row: |1, 2, 3| + row = SF_Array.ExtractRow(mat, 0) + +
+ +
+ Flatten ------------------------------------------------------------------------------------------------ + + Array service;Flatten + +

Flatten

+ Stack all single items of an array and all items in its subarrays into one new array without subarrays. Empty subarrays are ignored and subarrays with a number of dimensions greater than one are not flattened. + + + svc.Flatten(array_1d: any[0..*]): any[0..*] + + + array_1d: The pre-existing array, may be empty. + + + Dim a As Variant + a = SF_Array.Flatten(Array(Array(1, 2, 3), 4, 5)) + ' (1, 2, 3, 4, 5) + + You can use the Flatten method along with other methods such as Append or Prepend to concatenate a set of 1D arrays into a single 1D array. + + Next is an example of how the methods Flatten and Append can be combined to concatenate three arrays. + + 'Creates three arrays for this example + Dim a as Variant, b as Variant, c as Variant + a = Array(1, 2, 3) + b = Array(4, 5) + c = Array(6, 7, 8, 9) + 'Concatenates the three arrays into a single 1D array + Dim arr as Variant + arr = SF_Array.Flatten(SF_Array.Append(a, b, c)) + '(1, 2, 3, 4, 5, 6, 7, 8, 9) + +
+ +
+ ImportFromCSVFile -------------------------------------------------------------------------------------- + + Array service;ImportFromCSVFile + +

ImportFromCSVFile

+ Import the data contained in a comma-separated values (CSV) file. The comma may be replaced by any character. + The applicable CSV format is described in IETF Common Format and MIME Type for CSV Files. + Each line in the file contains a full record (line splitting is not allowed). +
However sequences like \n, \t, ... are left unchanged. Use SF_String.Unescape() method to manage them.
+ The method returns a two dimension array whose rows correspond to a single record read in the file and whose columns correspond to a field of the record. No check is made about the coherence of the field types across columns. A best guess will be made to identify numeric and date types. + If a line contains less or more fields than the first line in the file, an exception will be raised. Empty lines however are simply ignored. If the size of the file exceeds the number of items limit (see inside the code), a warning is raised and the array is truncated. + + + svc.ImportFromCSVFile(filename: str, delimiter: str = ',', dateformat: str = ''): any[0..*] + + + filename: The name of the text file containing the data. The name must be expressed according to the current FileNaming property of the SF_FileSystem service. + delimiter: A single character, usually, a comma, a semicolon or a TAB character (Default = ","). + dateformat: A special mechanism handles dates when dateformat is either "YYYY-MM-DD", "DD-MM-YYYY" or "MM-DD-YYYY". The dash (-) may be replaced by a dot (.), a slash (/) or a space. Other date formats will be ignored. Dates defaulting to an empty string "" are considered as normal text. + + Consider the CSV file "myFile.csv" with the following contents: + Name,DateOfBirth,Address,City + Anna,2002/03/31,"Rue de l'église, 21",Toulouse + Fred,1998/05/04,"Rue Albert Einstein, 113A",Carcassonne + The examples below in Basic and Python read the contents of the CSV file into an Array object. + + + Dim arr As Variant + arr = SF_Array.ImportFromCSVFile("C:\Temp\myFile.csv", DateFormat := "YYYY/MM/DD") + MsgBox arr(0, 3) ' City + MsgBox arr(1, 2) ' Rue de l'église, 21 + MsgBox arr(1, 3) ' Toulouse + + + + from scriptforge import CreateScriptService + svc = CreateScriptService("Array") + bas = CreateScriptService("Basic") + arr = svc.ImportFromCSVFile(r"C:\Temp\myFile.csv", dateformat = "YYYY/MM/DD") + bas.MsgBox(arr[0][3]) # City + bas.MsgBox(arr[1][2]) # Rue de l'église, 21 + bas.MsgBox(arr[1][3]) # Toulouse + +
+ +
+ IndexOf ------------------------------------------------------------------------------------------------ + + Array service;IndexOf + +

IndexOf

+ Look in a one dimension array for a number, a string or a date. Text comparison can be case-sensitive or not. +
If the array is sorted it must be filled homogeneously, which means that all items must be scalars of the same type (Empty and Null items are forbidden). +
The result of the method is unpredictable when the array is announced as sorted and actually is not. +
A binary search is performed on sorted arrays. Otherwise, arrays are simply scanned from top to bottom and Empty and Null items are ignored. +
+
The method returns LBound(input array) - 1 if the search was not successful.
+ + + svc.IndexOf(array_1d: any[0..*], tofind: any, casesensitive: bool = False, sortorder: str = ''): int + + + array_1d: The array to scan. + tofind: A number, a date or a string to find. + casesensitive: Only for string comparisons (Default = False). + sortorder: It can be either "ASC", "DESC" or "" (not sorted). The default value is "". + + + MsgBox SF_Array.IndexOf(Array("A","B","c","D"), "C", SortOrder := "ASC") ' 2 + MsgBox SF_Array.IndexOf(Array("A","B","c","D"), "C", CaseSensitive := True) ' -1 + +
+ +
+ Insert ------------------------------------------------------------------------------------------------- + + Array service;Insert + +

Insert

+ Insert before a given index of the input array the items listed as arguments. +
Arguments are inserted blindly. Each of them might be either a scalar of any type or a subarray.
+ + + svc.Insert(array_1d: any[0..*], before: int, arg0: any, [arg1: any] ...): any[0..*] + + + array_1d: The pre-existing array, may be empty. + before: The index before which to insert; must be in the interval [LBound, UBound + 1]. + arg0, arg1, ...: Items that will be inserted into array_1d. + + + Dim a As Variant + a = SF_Array.Insert(Array(1, 2, 3), 2, "a", "b") + ' (1, 2, "a", "b", 3) + +
+ +
+ InsertSorted ------------------------------------------------------------------------------------------- + + Array service;InsertSorted + +

InsertSorted

+ Inserts into a sorted array a new item on its place. +
The array must be filled homogeneously, meaning that all items must be scalars of the same type. +
Empty and Null items are forbidden.
+ + + svc.InsertSorted(array_1d: any[0..*], item: any, sortorder: str = 'ASC', casesensitive: bool = False): any[0..*] + + + array_1d: The array into which the value will be inserted. + item: The scalar value to insert, of the same type as the existing array items. + sortorder: It can be either "ASC" (default) or "DESC". + casesensitive: Only for string comparisons (Default = False). + + + Dim a As Variant + a = SF_Array.InsertSorted(Array("A", "C", "a", "b"), "B", CaseSensitive := True) + ' ("A", "B", "C", "a", "b") + +
+ +
+ Intersection ------------------------------------------------------------------------------------------- + + Array service;Intersection + +

Intersection

+ Build a set, as a zero-based array, by applying the intersection set operator on the two input arrays. Resulting items are contained in both arrays. +
The resulting array is sorted in ascending order. +
Both input arrays must be filled homogeneously, in other words all items must be scalars of the same type. Empty and Null items are forbidden. +
Text comparison can be case sensitive or not.
+ + + svc.Intersection(array1_1d: any[0..*], array2_1d: any[0..*], casesensitive: bool = False): any[0..*] + + + array1_1d: The first input array. + array2_1d: The second input array. + casesensitive: Applies to arrays populated with text items (Default = False). + + + Dim a As Variant + a = SF_Array.Intersection(Array("A", "C", "A", "b", "B"), Array("C", "Z", "b"), True) + ' ("C", "b") + +
+ +
+ Join2D ------------------------------------------------------------------------------------------------- + + Array service;Join2D + +

Join2D

+ Join a two-dimensional array with two delimiters, one for the columns, one for the rows. + + + svc.Join2D(array_2d: any [0..*, 0..*], [columndelimiter: str], [rowdelimiter: str], [quote: str]): str + + + array_2d: Each item must be either text, a number, a date or a boolean. +
Dates are transformed into the YYYY-MM-DD hh:mm:ss format. +
Invalid items are replaced by a zero-length string.
+ columndelimiter: Delimits each column (default = Tab/Chr(9)). + rowdelimiter: Delimits each row (default = LineFeed/Chr(10)) + quote: If True, protect strings with double quotes. The default is False. + + + ' arr = | 1, 2, "A", [2020-02-29], 51, 2, "A", [2020-02-29], 5 | + ' | 6, 7, "this is a string", 9, 106, 7, "this is a string", 9, 10 | + Dim arr as Variant : arr = Array() + arr = SF_Array.AppendRow(arr, Array(1, 2, "A", [2020-02-29], 51, 2, "A", [2020-02-29], 5)) + arr = SF_Array.AppendRow(arr, Array(6, 7, "this is a string", 9, 106, 7, "this is a string", 9, 10)) + Dim arrText as String + arrText = SF_Array.Join2D(arr, ",", "/", False) + ' 1,2,A,,51,2,A,,5/6,7,this is a string,9,106,7,this is a string,9,10 + +
+ +
+ Prepend -------------------------------------------------------------------------------------------- + + Array service;Prepend + +

Prepend

+ Prepend at the beginning of the input array the items listed as arguments. + + + svc.Prepend(array_1d: any[0..*], arg0: any, [arg1: any] ...): any[0..*] + + + array_1d: The pre-existing array, may be empty. + arg0, arg1, ...: A list of items to prepend to array_1d. + + + Dim a As Variant + a = SF_Array.Prepend(Array(1, 2, 3), 4, 5) + ' (4, 5, 1, 2, 3) + +
+ +
+ PrependColumn -------------------------------------------------------------------------------------- + + Array service;PrependColumn + +

PrependColumn

+ Prepend to the left side of a two dimension array a new column. The resulting array has the same lower boundaries as the initial two dimension array. + + + svc.PrependColumn(array_2d: any[0..*, 0..*], column: any[0..*]): any[0..*, 0..*] + + + array_2d: The pre-existing array, may be empty. If that array has 1 dimension, it is considered as the last column of the resulting 2 dimension array. + column: A 1-dimensional array with as many items as there are rows in array_2d. + + + Dim a As Variant, b As variant + a = SF_Array.PrependColumn(Array(1, 2, 3), Array(4, 5, 6)) + ' ((4, 1), (5, 2), (6, 3)) + b = SF_Array.PrependColumn(Array(), Array(1, 2, 3)) + ' ∀ i ∈ {0 ≤ i ≤ 2} : b(0, i) ≡ i + +
+ +
+ PrependRow ----------------------------------------------------------------------------------------- + + Array service;PrependRow + +

PrependRow

+ Prepend a new row at the beginning of a 2-dimensional array. The resulting array has the same lower boundaries as the initial 2-dimensional array. + + + svc.PrependRow(array_2d: any[0..*, 0..*], row: any[0..*]): any[0..*, 0..*] + + + array_2d: The pre-existing array, may be empty. If that array has 1 dimension, it is considered as the last row of the resulting 2-dimensional array. + row: A 1-dimensional array containing as many items as there are columns in array_2d. + + + Dim a As Variant, b As variant + a = SF_Array.PrependRow(Array(1, 2, 3), Array(4, 5, 6)) + ' ((4, 5, 6), (1, 2, 3)) + b = SF_Array.PrependRow(Array(), Array(1, 2, 3)) + ' ∀ i ∈ {0 ≤ i ≤ 2} : b(i, 0) ≡ i + +
+ +
+ RangeInit ------------------------------------------------------------------------------------------ + + Array service;RangeInit + +

RangeInit

+ Initialize a new zero-based array with numeric values. + + + svc.RangeInit(from: num, upto: num, [bystep: num]): num[0..*] + + + from: Value of the first item. + upto: The last item should not exceed UpTo. + bystep: The difference between two successive items (Default = 1). + + + Dim a As Variant + a = SF_Array.RangeInit(10, 1, -1) + ' (10, 9, 8, 7, 6, 5, 4, 3, 2, 1) + +
+ +
+ Reverse -------------------------------------------------------------------------------------------- + + Array service;Reverse + +

Reverse

+ Return the reversed one dimension input array. + + + svc.Reverse(array_1d: any[0..*]): any[0..*] + + + array_1d: The array to reverse. + + + Dim a As Variant + a = SF_Array.Reverse(Array("a", 2, 3, 4)) + ' (4, 3, 2, "a") + +
+ +
+ Shuffle -------------------------------------------------------------------------------------------- + + Array service;Shuffle + +

Shuffle

+ Returns a random permutation of a one-dimensional array. + + + svc.Shuffle(array_1d: any[0..*]): any[0..*] + + + array_1d: The array to shuffle. + + + Dim a As Variant + a = SF_Array.Shuffle(Array(1, 2, 3, 4)) + ' Array "a" is now in random order, f.i. (2, 3, 1, 4) + +
+ +
+ Slice ---------------------------------------------------------------------------------------------- + + Array service;Slice + +

Slice

+ Returns a subset of a one-dimensional array. + + + svc.Slice(array_1d: any[0..*], from: int, [upto: int]): any[0..*] + + + array_1d: The array to slice. + from: The lower index in array_1d of the subarray to extract (from included) + upto: The upper index in array_1d of the subarray to extract (upto included). The default value is the upper bound of array_1d. If upto < from then the returned array is empty. + + + Dim a As Variant + a = SF_Array.Slice(Array(1, 2, 3, 4, 5), 1, 3) ' (2, 3, 4) + +
+ +
+ Sort ----------------------------------------------------------------------------------------------- + + Array service;Sort + +

Sort

+ Sort a one dimension array in ascending or descending order. Text comparisons can be case-sensitive or not. +
The array must be filled homogeneously, which means that items must be scalars of the same type. +
Empty and Null items are allowed. Conventionally Empty < Null < any other scalar value.
+ + + svc.Sort(array_1d: any[0..*], sortorder: str, casesensitive: bool = False): any[0..*] + + + array_1d: The array to sort. + sortorder: It can be either "ASC" (default) or "DESC". + casesensitive: Only for string comparisons (Default = False). + + + Dim a As Variant + a = SF_Array.Sort(Array("a", "A", "b", "B", "C"), CaseSensitive := True) + ' ("A", "B", "C", "a", "b") + +
+ +
+ SortColumns ---------------------------------------------------------------------------------------- + + Array service;SortColumns + +

SortColumns

+ Return a permutation of the columns of a two dimension array, sorted on the values of a given row. +
The row must be filled homogeneously, which means that all items must be scalars of the same type. +
Empty and Null items are allowed. Conventionally Empty < Null < any other scalar value.
+ + + svc.SortColumns(array_2d: any[0..*, 0..*], rowindex: int, sortorder: str, casesensitive: bool = False): any[0..*, 0..*] + + + array_2d: The 2-dimensional array to sort. + rowindex: The index of the row that will be used as reference to sort the columns. + sortorder: It can be either "ASC" (default) or "DESC". + casesensitive: Only for string comparisons (Default = False). + + + ' arr = | 5, 7, 3 | + ' | 1, 9, 5 | + ' | 6, 1, 8 | + Dim arr as Variant : arr = Array(5, 7, 3) + arr = SF_Array.AppendRow(arr, Array(1, 9, 5)) + arr = SF_Array.AppendRow(arr, Array(6, 1, 8)) + arr = SF_Array.SortColumns(arr, 2, "ASC") + ' arr = | 7, 5, 3 | + ' | 9, 1, 5 | + ' | 1, 6, 8 | + +
+ +
+ SortRows ------------------------------------------------------------------------------------------- + + Array service;SortRows + +

SortRows

+ Return a permutation of the rows of a two dimension array, sorted on the values of a given column. +
The column must be filled homogeneously, therefore all items must be scalars of the same type. +
Empty and Null items are allowed. Conventionally Empty < Null < any other scalar value.
+ + + svc.SortRows(array_2d: any[0..*, 0..*], columnindex: int, sortorder: str, casesensitive: bool = False): any[0..*, 0..*] + + + array_2d: The array to sort. + columnindex: The index of the column that will be used as reference to sort the rows. + sortorder: It can be either "ASC" (default) or "DESC". + casesensitive: Only for string comparisons (Default = False). + + + ' arr = | 5, 7, 3 | + ' | 1, 9, 5 | + ' | 6, 1, 8 | + Dim arr as Variant : arr = Array(5, 7, 3) + arr = SF_Array.AppendRow(arr, Array(1, 9, 5)) + arr = SF_Array.AppendRow(arr, Array(6, 1, 8)) + arr = SF_Array.SortRows(arr, 0, "ASC") + ' arr = | 1, 9, 5 | + ' | 5, 7, 3 | + ' | 6, 1, 8 | + +
+ +
+ Transpose ---------------------------------------------------------------------------------------------- + + Array service;Transpose + +

Transpose

+ Swaps rows and columns in a two-dimensional array. + + + svc.Transpose(array_2d: any[0..*, 0..*]): any[0..*, 0..*] + + + array_2d: The 2-dimensional array to transpose. + + + ' arr1 = | 1, 2 | + ' | 3, 4 | + ' | 5, 6 | + arr1 = Array(1, 2) + arr1 = SF_Array.AppendRow(arr1, Array(3, 4)) + arr1 = SF_Array.AppendRow(arr1, Array(5, 6)) + arr2 = SF_Array.Transpose(arr1) + ' arr2 = | 1, 3, 5 | + ' | 2, 4, 6 | + MsgBox arr2(0, 2) ' 5 + +
+ +
+ TrimArray ---------------------------------------------------------------------------------------------- + + Array service;TrimArray + +

TrimArray

+ Remove from a one dimension array all Null, Empty and zero-length entries. +
String items are trimmed with %PRODUCTNAME Basic Trim() function.
+ + + svc.TrimArray(array_1d: any[0..*]): any[0..*] + + + array_1d: The array to trim. + + + Dim a As Variant + a = SF_Array.TrimArray(Array("A", "B", Null, " D ")) + ' ("A", "B", "D") + +
+ +
+ Union -------------------------------------------------------------------------------------------------- + + Array service;Union + +

Union

+ Builds a set, as a zero-based array, by applying the union operator on the two input arrays. Resulting items originate from any of both arrays. +
The resulting array is sorted in ascending order. +
Both input arrays must be filled homogeneously, their items must be scalars of the same type. Empty and Null items are forbidden. +
Text comparison can be case sensitive or not.
+ + + svc.Union(array1_1d: any[0..*], array2_1d: any[0..*], casesensitive: bool = False): any[0..*] + + + array1_1d: The first input array. + array2_1d: The second input array. + casesensitive: Applicable only if the arrays are populated with strings (Default = False). + + + Dim a As Variant + a = SF_Array.Union(Array("A", "C", "A", "b", "B"), Array("C", "Z", "b"), True) + ' ("A", "B", "C", "Z", "b") + +
+ +
+ Unique ------------------------------------------------------------------------------------------------- + + Array service;Unique + +

Unique

+ Build a set of unique values derived from the input array. +
The input array must be filled homogeneously, its items must be scalars of the same type. Empty and Null items are forbidden. +
Text comparison can be case sensitive or not.
+ + + svc.Unique(array_1d: any[0..*], casesensitive: bool = False): any[0..*] + + + array_1d: The input array. + casesensitive: Applicable only if the array is populated with strings (Default = False). + + + Dim a As Variant + a = SF_Array.Unique(Array("A", "C", "A", "b", "B"), CaseSensitive := True) + ' ("A", "B", "C", "b") + +
+ + + +
+ + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_base.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_base.xhp new file mode 100644 index 000000000..ee0f5b2e8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_base.xhp @@ -0,0 +1,372 @@ + + + + + + + SFDocuments.Base service + /text/sbasic/shared/03/sf_base.xhp + + + + +
+ + Base service + +

SFDocuments.Base service

+ + The Base service provides a number of methods and properties to facilitate the management and handling of %PRODUCTNAME Base documents. + This service is closely related to the Document service, which provides generic methods for handling %PRODUCTNAME documents, including Base documents. Hence, the Base service extends the Document service and provides additional methods that are specific for Base documents, enabling users to: + + + Get access to the database contained in a Base document. + + + Open form documents stored in a Base document. + + + Check if a form document from a Base document is currently loaded. + + +
+ + Refer to the Document service to learn more about methods and properties that can be used to manage %PRODUCTNAME documents. + +

Service invocation

+ Before using the Base service the ScriptForge library needs to be loaded or imported: + + + + The Base service can be invoked in a variety of ways. The code snippet below uses the method CreateBaseDocument from the UI service to create a new Base file. + Note that in all examples the object oDoc is an instance of the Base service. + + Dim ui As Object, oDoc As Object + Set ui = CreateScriptService("UI") + Set oDoc = ui.CreateBaseDocument("C:\Documents\MyFile.odb") + + The Base service can also be instantiated while opening an existing Base file, as shown below: + + Set oDoc = ui.OpenBaseDocument("C:\Documents\MyFile.odb") + + If a Base document is already open, it is possible to instantiate the Base service directly: + + Dim oDoc As Object + Set oDoc = CreateScriptService("SFDocuments.Document", "MyFile.odb") + + + The examples above can be translated to Python as follows: + + from scriptforge import CreateScriptService + ui = CreateScriptService("UI") + doc = ui.CreateBaseDocument(r"C:\Documents\MyFile.odb") + + + doc = ui.OpenBaseDocument(r"C:\Documents\MyFile.odb") + + + doc = CreateScriptService("SFDocuments.Document", "MyFile.odb") + + The use of the "SFDocuments." substring in the previous example is optional. + + + + + List of Methods in the Base Service + + + + + + CloseFormDocument
+ FormDocuments
+ Forms
+
+
+ + + GetDatabase
+ IsLoaded
+ OpenFormDocument
+
+
+ + + PrintOut
+ SetPrinter

+
+
+
+
+ +
+ CloseFormDocument ------------------------------------------------------------------------------------- + + Base service;CloseFormDocument + +

CloseFormDocument

+ Closes the given form document. Returns True if closure is successful. + + + svc.CloseFormDocument(formdocument: str): bool + + + formdocument: The name of the FormDocument to be closed, as a case-sensitive string. + + If form documents are organized in folders, it is necessary to include the folder name to specify the form document to be opened, as illustrated in the following examples: + + + oDoc.CloseFormDocument("Folder1/myFormDocument") + + + + doc.CloseFormDocument('Folder1/myFormDocument') + +
+ +
+ FormDocuments --------------------------------------------------------------------------------------- + + Base service;FormDocuments + +

FormDocuments

+ Returns an array with the full names (path/name) of all form documents in the Base document as a zero-based Array of strings. + + + svc.FormDocuments(): str[0..*] + + + The code snippet below prints the names of all form documents in the current Base document. + + + Dim oDoc as Object, myForms as Object, formName as String + Set oDoc = CreateScriptService("Document", ThisDataBaseDocument) + Set myForms = oDoc.FormDocuments() + For Each formName In myForms + MsgBox formName + Next formName + + + + bas = CreateScriptService("Basic") + doc = CreateScriptService("Document", bas.ThisDataBaseDocument) + myForms = doc.FormDocuments() + for formName in myForms: + bas.MsgBox(formName) + + To learn more about form documents, refer to the Form service help page. +
+ +
+ Forms ---------------------------------------------------------------------------------------------- + + Base service;Forms + +

Forms

+ Depending on the parameters provided this method will return: + + + A zero-based Array with the names of all the forms contained in a form document (if the Form argument is absent) + + + A SFDocuments.Form object representing the form specified in the Form argument. + + + + + svc.Forms(formdocument: str): str[0..*] + + + svc.Forms(formdocument: str, form: str = ''): svc + + + svc.Forms(formdocument: str, form: int): svc + + + formdocument: The name of a valid form document as a case-sensitive string. + form: The name or index number of the form stored in the form document. If this argument is absent, the method will return a list with the names of all forms available in the form document. + Although it is possible to use index numbers to refer to forms, this is only recommended when there is just one form in the form document. If there are two or more forms, it is preferable to use the form name instead. + + The first line of the example below returns a list of all forms in the form document "myFormDocument". The second line returns an instance of the Form service representing the form "myForm". + + + Dim formsList as Object : formsList = oDoc.Forms("myFormDocument") + Dim oForm as Object : oForm = oDoc.Forms("myFormDocument", "myForm") + + + + formsList = doc.Forms("myFormDocument") + form = doc.Forms("myFormDocument", "myForm") + +
+ +
+ GetDatabase ----------------------------------------------------------------------------------------- + + Base service;GetDatabase + +

GetDatabase

+ Returns an instance of the Database service that allows the execution of SQL commands on the database defined and/or stored in the current Base document + + + svc.GetDatabase(user: str = '', password: str = ''): svc + + + user, password: Optional login parameters as strings. The default value for both parameters is an empty string "". + + + + Dim myDoc As Object, myDatabase As Object, ui As Object + Set ui = CreateScriptService("UI") + Set myDoc = ui.OpenBaseDocument("C:\Documents\myDb.odb") + ' User and password are supplied below, if needed + Set myDatabase = myDoc.GetDatabase() + ' ... Run queries, SQL statements, ... + myDatabase.CloseDatabase() + myDoc.CloseDocument() + + + + ui = CreateScriptService("UI") + myDoc = ui.OpenBaseDocument(r"C:\Documents\myDb.odb") + myDatabase = myDoc.GetDatabase() + # ... Run queries, SQL statements, ... + myDatabase.CloseDatabase() + myDoc.CloseDocument() + +
+ +
+ IsLoaded -------------------------------------------------------------------------------------------- + + Base service;IsLoaded + +

IsLoaded

+ Returns True if the specified FormDocument is currently open. + + + svc.IsLoaded(formdocument: str): bool + + + formdocument: The name of a FormDocument to be checked, as a case-sensitive string. + + + + If Not oDoc.IsLoaded("myFormDocument") Then + oDoc.OpenFormDocument("myFormDocument") + End If + + + + if not doc.IsLoaded("myFormDocument"): + doc.OpenFormDocument("myFormDocument") + +
+ +
+ OpenFormDocument ------------------------------------------------------------------------------------- + + Base service;OpenFormDocument + +

OpenFormDocument

+ Opens the specified FormDocument either in normal or in design mode. + If the form document is already open, it is activated without changing its mode. The method returns True if the form document could be opened. + + + svc.OpenFormDocument(formdocument: str, designmode: bool = False): bool + + + formDocument: The name of the FormDocument to be opened, as a case-sensitive string. + designmode: If this argument is True the FormDocument will be opened in design mode. + + + Most form documents are stored in the root of the Base document and they can be opened simply using their names, as in the example below: + + oDoc.OpenFormDocument("myFormDocument") + + If form documents are organized in folders, it becomes necessary to include the folder name to specify the form document to be opened, as illustrated in the following example: + + oDoc.OpenFormDocument("myFolder/myFormDocument") + + + + doc.OpenFormDocument("myFormDocument") + + + doc.OpenFormDocument("myFolder/myFormDocument") + +
+ +
+ PrintOut ---------------------------------------------------------------- + + Base service;PrintOut + +

PrintOut

+ This method sends the content of the given form document to a default printer or a printer defined by the SetPrinter() method. + Returns True if the document was successfully printed. + + + svc.PrintOut(opt formdocument: str, pages: str = "", copies: num = 1): bool + + + formdocument: A valid document form name as a case-sensitive string. The form document must be open. It is activated by the method. + pages: The pages to print as a string, like in the user interface. Example: "1-4;10;15-18". Default is all pages. + copies: The number of copies. Default is 1. + + + + If oDoc.PrintOut("myForm", "1-4;10;15-18", Copies := 2) Then + ' ... + End If + + + + if doc.PrintOut('myForm', copies=3, pages='45-88'): + # ... + +
+ +
+ SetPrinter ------------------------------------------------------------------- + + Base service;SetPrinter + +

SetPrinter

+ Define the printer options for a form document. The form document must be open. + Returns True when successful. + + + svc.SetPrinter(opt formdocument: str, opt printer: str, opt orientation: str, paperformat: str): bool + + + formdocument: A valid document form name as a case-sensitive string. + + + + + oDoc.SetPrinter("myForm", Orientation := "PORTRAIT") + + + + doc.SetPrinter('myForm', paperformat='TABLOID') + +
+ + +
+ + + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_basic.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_basic.xhp new file mode 100644 index 000000000..300838e7b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_basic.xhp @@ -0,0 +1,659 @@ + + + + + + ScriptForge.Basic service + /text/sbasic/shared/03/sf_basic.xhp + + + +
+ + Basic service + +
+
+

ScriptForge.Basic service

+ The ScriptForge.Basic service proposes a collection of %PRODUCTNAME Basic methods to be executed in a Python context. Basic service methods reproduce the exact syntax and behaviour of Basic builtin functions. + +
+ Typical example: + + bas.MsgBox('Display this text in a message box from a Python script') + + ScriptForge.Basic service is limited to Python scripts. +

Service invocation

+ Before using the Basic service, import the CreateScriptService() method from the scriptforge module: + + from scriptforge import CreateScriptService + bas = CreateScriptService("Basic") + +

Properties

+ + + Name + ReadOnly + Type + Description + + + + MB_OK, MB_OKCANCEL, MB_RETRYCANCEL, MB_YESNO, MB_YESNOCANCEL + + + Yes + + + Integer + + + Values: 0, 1, 5, 4, 3 + + + + + MB_ICONEXCLAMATION, MB_ICONINFORMATION, MB_ICONQUESTION, MB_ICONSTOP + + + Yes + + + Integer + + + Values: 48, 64, 32, 16
+
+
+ + + MB_ABORTRETRYIGNORE, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3 + + + Yes + + + Integer + + + Values: 2, 128, 256, 512 + + + + + IDABORT, IDCANCEL, IDIGNORE, IDNO, IDOK, IDRETRY, IDYES + + + Yes + + + Integer + + + Values: 3, 2, 5, 7, 1, 4, 6
Constants indicating MsgBox selected button.
+
+
+ + + StarDesktop + + + Yes + + + UNO
object
+
+ + StarDesktop object represents %PRODUCTNAME Start Center. + +
+
+ + + List of Methods in the Basic Service + + + + + CDate
+ CDateFromUnoDateTime
+ CDateToUnoDateTime
+ ConvertFromUrl
+ ConvertToUrl
+ CreateUnoService
+ DateAdd
+ DateDiff
+ DatePart
+
+
+ + + DateValue
+ Format
+ GetDefaultContext
+ GetGuiType
+ GetPathSeparator
+ GetSystemTicks
+ GlobalScope.BasicLibraries
+ GlobalScope.DialogLibraries
+ InputBox
+
+
+ + + MsgBox
+ Now
+ RGB
+ ThisComponent
+ ThisDatabaseDocument
+ Xray



+
+
+
+
+ +
+ CDate ------------------------------------------------------------------------- + + Basic service;CDate + +

CDate

+ Converts a numeric expression or a string to a datetime.datetime Python native object. + This method exposes the Basic builtin function CDate to Python scripts. + + + svc.CDate(expression: any): obj + + + expression: a numeric expression or a string representing a date. + + + + d = bas.CDate(1000.25) + bas.MsgBox(str(d)) # 1902-09-26 06:00:00 + bas.MsgBox(d.year) # 1902 + +
+ +
+ CDateFromUnoDateTime ------------------------------------------------------------------------- + + Basic service;CDateFromUnoDateTime + +

CDateFromUnoDateTime

+ Converts a UNO date/time representation to a datetime.datetime Python native object. + + + svc.CDateFromUnoDateTime(unodate: uno): obj + + + unodate: A UNO date/time object of one of the following types: com.sun.star.util.DateTime, com.sun.star.util.Date or com.sun.star.util.Time + + The following example creates a com.sun.star.util.DateTime object and converts it to a datetime.datetime Python object. + + import uno + uno_date = uno.createUnoStruct('com.sun.star.util.DateTime') + uno_date.Year = 1983 + uno_date.Month = 2 + uno_date.Day = 23 + new_date = bas.CDateFromUnoDateTime(uno_date) + bas.MsgBox(str(new_date)) # 1983-02-23 00:00:00 + +
+ +
+ CDateToUnoDateTime ------------------------------------------------------------------------- + + Basic service;CDateToUnoDateTime + +

CDateToUnoDateTime

+ Converts a date representation into a com.sun.star.util.DateTime object. + + + svc.CDateToUnoDateTime(date: obj): uno + + + date: A Python date/time object of one of the following types: datetime.datetime, datetime.date, datetime.time, float (time.time) or time.struct_time. + + + from datetime import datetime + current_datetime = datetime.now() + uno_date = bas.CDateToUnoDateTime(current_datetime) + bas.MsgBox(str(uno_date.Year) + "-" + str(uno_date.Month) + "-" + str(uno_date.Day)) + +
+ +
+ ConvertFromUrl ------------------------------------------------------------------------- + + Basic service;ConvertFromUrl + +

ConvertFromUrl

+ Returns a system path file name for the given file: URL. + + svc.ConvertFromUrl(url: str): str + + url: An absolute file: URL. + + A system path file name. + + + filename = bas.ConvertFromUrl( "file:///C:/Program%20Files%20(x86)/LibreOffice/News.txt") + bas.MsgBox(filename) + +
+ +
+ ConvertToUrl --------------------------------------------------------------------------- + + Basic service;ConvertToUrl + +

ConvertToUrl

+ Returns a file: URL for the given system path. + + svc.ConvertToUrl(systempath: str): str + + systempath: A system file name as a string. + + A file: URL as a string. + + + url = bas.ConvertToUrl( 'C:\Program Files(x86)\LibreOffice\News.txt') + bas.MsgBox(url) + +
+ +
+ CreateUnoService ----------------------------------------------------------------------- + + Basic service;CreateUnoService + +

CreateUnoService

+ Instantiates a UNO service with the ProcessServiceManager. + + svc.CreateUnoService(servicename: str): uno + + servicename: A fully qualified service name such as com.sun.star.ui.dialogs.FilePicker or com.sun.star.sheet.FunctionAccess. + + + dsk = bas.CreateUnoService('com.sun.star.frame.Desktop') + +
+ +
+ DateAdd -------------------------------------------------------------------------------- + + Basic service;DateAdd + +

DateAdd

+ Adds a date or time interval to a given date/time a number of times and returns the resulting date. + + svc.DateAdd(interval: str, number: num, date: datetime): datetime + + interval: A string expression from the following table, specifying the date or time interval. + + number: A numerical expression specifying how often the interval value will be added when positive or subtracted when negative. + date: A given datetime.datetime value, the interval value will be added number times to this datetime.datetime value. + + A datetime.datetime value. + + + dt = datetime.datetime(2004, 1, 31) + dt = bas.DateAdd("m", 1, dt) + print(dt) + +
+ +
+ DateDiff ------------------------------------------------------------------------------- + + Basic service;DateDiff + +

DateDiff

+ Returns the number of date or time intervals between two given date/time values. + + svc.DateDiff(interval: str, date1: datetime, date2: datetime, firstdayofweek = 1, firstweekofyear = 1): int + + interval: A string expression specifying the date interval, as detailed in above DateAdd method. + date1, date2: The two datetime.datetime values to be compared. + + + A number. + + + date1 = datetime.datetime(2005,1, 1) + date2 = datetime.datetime(2005,12,31) + diffDays = bas.DateDiff('d', date1, date2) + print(diffDays) + +
+ +
+ DatePart ------------------------------------------------------------------------------- + + Basic service;DatePart + +

DatePart

+ The DatePart function returns a specified part of a date. + + svc.DatePart(interval: str, date: datetime, firstdayofweek = 1, firstweekofyear = 1): int + + interval: A string expression specifying the date interval, as detailed in above DateAdd method. + date: The date/time from which the result is calculated. + firstdayofweek, firstweekofyear: optional parameters that respectively specify the starting day of a week and the starting week of a year, as detailed in above DateDiff method. + + The extracted part for the given date/time. + + + print(bas.DatePart("ww", datetime.datetime(2005,12,31) + print(bas.DatePart('q', datetime.datetime(1999,12,30) + +
+ +
+ DateValue ------------------------------------------------------------------------------ + + Basic service;DateValue + +

DateValue

+ Computes a date value from a date string. + + svc.DateValue(date: str): datetime + + + + The computed date. + + + dt = bas.DateValue("23-02-2011") + print(dt) + +
+ +
+ Format --------------------------------------------------------------------------------- + + Basic service;Format + +

Format

+ Converts a number to a string, and then formats it according to the format that you specify. + + svc.Format(expression: any, format = ''): str + +

Formatting Codes

+ +

Predefined Formats

+ + + + + txt = bas.Format(6328.2, '##.##0.00') + print(txt) + +
+ +
+ GetDefaultContext ---------------------------------------------------------------------- + + Basic service;GetDefaultContext + +

GetDefaultContext

+ Returns the default context of the process service factory, if existent, else returns a null reference. + GetDefaultContext is an alternative to the getComponentContext() method available from XSCRIPTCONTEXT global variable or from uno.py module. + + svc.GetDefaultContext(): uno + + The default component context is used, when instantiating services via XMultiServiceFactory. See the Professional UNO chapter in the Developer's Guide on api.libreoffice.org for more information. + + + ctx = bas.GetDefaultContext() + +
+ +
+ GetGuiType ----------------------------------------------------------------------------- + + Basic service;GetGuiType + +

GetGuiType

+ Returns a numerical value that specifies the graphical user interface. This function is only provided for backward compatibility with previous versions. + Refer to system() method from platform Python module to identify the operating system. + + svc.GetGuiType(): int + + + n = bas.GetGuiType() + +
+ +
+ GetPathSeparator ---------------------------------------------------------------------- + + Basic service;GetPathSeparator + +

GetPathSeparator

+ Returns the operating system-dependent directory separator used to specify file paths. + Use os.pathsep from os Python module to identify the path separator. + + svc.GetPathSeparator(): str + + + sep = bas.GetPathSeparator() + +
+ +
+ GetSystemTicks ------------------------------------------------------------------------- + + Basic service;GetSystemTicks + +

GetSystemTicks

+ Returns the number of system ticks provided by the operating system. You can use this function to optimize certain processes. Use this method to estimate time in milliseconds: + + svc.GetSystemTicks(): int + + + ticks_ini = bas.GetSystemTicks() + time.sleep(1) + ticks_end = bas.GetSystemTicks() + bas.MsgBox("{} - {} = {}".format(ticks_end, ticks_ini,ticks_end - ticks_ini)) + +
+ +
+ InputBox ------------------------------------------------------------------------------- + + Basic service;GlobalScope.BasicLibraries + +

GlobalScope.BasicLibraries

+ Returns the UNO object containing all shared Basic libraries and modules. + This method is the Python equivalent to GlobalScope.BasicLibraries in Basic scripts. + + + svc.GlobalScope.BasicLibraries(): uno + + + com.sun.star.script.XLibraryContainer + + The following example loads the Gimmicks Basic library if it has not been loaded yet. + + libs = bas.GlobalScope.BasicLibraries() + if not libs.isLibraryLoaded("Gimmicks"): + libs.loadLibrary("Gimmicks") + +
+ +
+ InputBox ------------------------------------------------------------------------------- + + Basic service;GlobalScope.DialogLibraries + +

GlobalScope.DialogLibraries

+ Returns the UNO object containing all shared dialog libraries. + This method is the Python equivalent to GlobalScope.DialogLibraries in Basic scripts. + + + svc.GlobalScope.DialogLibraries(): uno + + + com.sun.star.comp.sfx2.DialogLibraryContainer + + The following example shows a message box with the names of all available dialog libraries. + + dlg_libs = bas.GlobalScope.DialogLibraries() + lib_names = dlg_libs.getElementNames() + bas.MsgBox("\n".join(lib_names)) + +
+ +
+ InputBox ------------------------------------------------------------------------------- + + Basic service;InputBox + +

InputBox

+ + svc.InputBox(prompt: str, [title: str], [default: str], [xpostwips: int, ypostwips: int]): str + + + + String + +
+ + txt = s.InputBox('Please enter a phrase:', "Dear user") + s.MsgBox(txt, s.MB_ICONINFORMATION, "Confirmation of phrase") + + For in-depth information please refer to Input/Output to Screen with Python on the Wiki. +
+
+ +
+ MsgBox -------------------------------------------------------------------------------- + + Basic service;MsgBox + +

MsgBox

+ Displays a dialog box containing a message and returns an optional value.
MB_xx constants help specify the dialog type, the number and type of buttons to display, plus the icon type. By adding their respective values they form bit patterns, that define the MsgBox dialog appearance.
+ + bas.MsgBox(prompt: str, [buttons: int], [title: str])[: int] + + + + An optional integer as detailed in above IDxx properties. + + +
+ +
+ Now ------------------------------------------------------------------------------------ + + Basic service;Now + +

Now

+ Returns the current system date and time as a datetime.datetime Python native object. + + svc.Now(): datetime + + + bas.MsgBox(bas.Now(), bas.MB_OK, "Now") + +
+ +
+ RGB ------------------------------------------------------------------------------------ + + Basic service;RGB + +

RGB

+ Returns an integer color value consisting of red, green, and blue components. + + svc.RGB(red:int, green: int, blue: int): int + + + + Integer + + + YELLOW = bas.RGB(255,255,0) + +
+ +
+ ThisComponent -------------------------------------------------- + + Basic service;ThisComponent + +

ThisComponent

+ If the current component refers to a %PRODUCTNAME document, this method returns the UNO object representing the document. + The method will return None when the current component does not correspond to a document. + + + svc.ThisComponent(): uno + + + + comp = bas.ThisComponent + bas.MsgBox("\n".join(comp.getSupportedServiceNames())) + +
+ +
+ ThisDatabaseDocument ------------------------------------------ + + Basic service;ThisDatabaseDocument + +

ThisDatabaseDocument

+ If the script is being executed from a Base document or any of its subcomponents this method returns the main component of the Base instance. + This method returns None otherwise. + + + svc.ThisDatabaseDocument(): uno + + + + db_doc = bas.ThisDatabaseDocument + table_names = db_doc.DataSource.getTables().getElementNames() + bas.MsgBox("\n".join(table_names)) + + Visit the OfficeDatabaseDocument API page to learn more about Base's main component structure. +
+ +
+ Xray ------------------------------------------------------------ + + Basic service;Xray + +

Xray

+ Inspect Uno objects or variables. + + svc.Xray(obj: any) + + obj: A variable or UNO object. + + + bas.Xray(bas.StarDesktop) + +
+ + +
+ + + uno.fileUrlToSystemPath() + uno.systemPathToFileUrl() + Input/Output to Screen with Python on the wiki + XSCRIPTCONTEXT.getComponentContext() + uno.getComponentContext() + platform.system() + os.pathsep() +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_calc.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_calc.xhp new file mode 100644 index 000000000..6b75f86dd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_calc.xhp @@ -0,0 +1,2031 @@ + + + + + + + SFDocuments.Calc service + /text/sbasic/shared/03/sf_calc.xhp + + + + +
+ + Calc service + +
+ +
+

SFDocuments.Calc service

+ The SFDocuments shared library provides a number of methods and properties to facilitate the management and handling of %PRODUCTNAME documents. + The SFDocuments.Calc service is a subclass of the SFDocuments.Document service. All methods and properties defined for the Document service can also be accessed using a Calc service instance. + The Calc service is focused on: + + + Handling sheets within a Calc document (copy, insert, move, etc) + + + Exchanging data between Basic data structures and Calc ranges + + + Copying and importing massive amounts of data + + +
+ This help page describes methods and properties that are applicable only to Calc documents. + +

Service invocation

+ Before using the Calc service the ScriptForge library needs to be loaded or imported: + + + The Calc service is closely related to the UI service of the ScriptForge library. Below are a few examples of how the Calc service can be invoked. + + The code snippet below creates a Calc service instance that corresponds to the currently active Calc document. + + Set oDoc = CreateScriptService("Calc") + + Another way to create an instance of the Calc service is using the UI service. In the following example, a new Calc document is created and oDoc is a Calc service instance: + + Dim ui As Object, oDoc As Object + Set ui = CreateScriptService("UI") + Set oDoc = ui.CreateDocument("Calc") + + Or using the OpenDocument method from the UI service: + + Set oDoc = ui.OpenDocument("C:\Documents\MyFile.ods") + + It is also possible to instantiate the Calc service using the CreateScriptService method: + + Dim oDoc As Object + Set oDoc = CreateScriptService("SFDocuments.Calc", "MyFile.ods") + + In the example above, "MyFile.ods" is the name of an open document window. If this argument is not provided, the active window is considered. + It is recommended to free resources after use: + + Set oDoc = oDoc.Dispose() + + However, if the document was closed using the CloseDocument method, it becomes unnecessary to free resources using the command described above. + + + myDoc = CreateScriptService("Calc") + + + ui = CreateScriptService("UI") + myDoc = ui.CreateDocument("Calc") + + + myDoc = ui.OpenDocument(r"C:\Documents\MyFile.ods") + + + myDoc = CreateScriptService("SFDocuments.Calc", "MyFile.ods") + myDoc.Dispose() + + The use of the prefix "SFDocuments." while calling the service is optional. + +

Definitions

+ Many methods require a "Sheet" or a "Range" as argument. Single cells are considered a special case of a Range. + Both may be expressed either as a string or as a reference (= object) depending on the situation: + + + Within a specific Calc instance, sheets and ranges are given as strings such as "Sheet1" and "D2:F6". + + + Additionally, the .Sheet and .Range properties return a reference that may be used as argument of a method called from another instance of the Calc service. + + + + The example below copies data from document A (opened as read-only and hidden) to document B. + + + Dim oDocA As Object, oDocB As Object + Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True) + Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods") + oDocB.CopyToRange(oDocA.Range("SheetX.D4:F8"), "D2:F6") 'CopyToRange(source, target) + + + + docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True) + docB = ui.OpenDocument(r"C:\Documents\FileB.ods") + docB.CopyToRange(docA.Range("SheetX.D4:F8"), "D2:F6") + + +

SheetName

+ Either the sheet name as a string or an object produced by the .Sheet property. + The shortcut "~" (tilde) represents the current sheet. +

RangeName

+ Either a string designating a set of contiguous cells located in a sheet of the current instance or an object produced by the .Range property. + The shortcut "~" (tilde) represents the current selection or the first selected range if multiple ranges are selected. + The shortcut "*" represents all used cells. + The sheet name is optional when defining a range. If no sheet name is provided, then the active sheet is used. Surrounding single quotes and $ signs are allowed but ignored. + When specifying a SheetName as a string, the use of single quotes to enclose the sheet name are required if the name contains blank spaces " " or periods ".". + The examples below illustrate in which cases the use of single quotes is mandatory: + + ' The use of single quotes is optional + oDoc.clearAll("SheetA.A1:B10") + oDoc.clearAll("'SheetA'.A1:B10") + ' The use of single quotes is required + oDoc.clearAll("'Sheet.A'.A1:B10") + + Except for the CurrentSelection property, the Calc service considers only single ranges of cells. + + + + Examples of valid ranges + + + + + 1) $'SheetX'.D2
2) $D$2
+
+ + A single cell + +
+ + + 1) $'SheetX'.D2:F6
2) D2:D10
+
+ + Single range with multiple cells + +
+ + + $'SheetX'.* + + + All used cells in the given sheet + + + + + 1) $'SheetX'.A:A (column A)
2) 3:5 (rows 3 to 5)
+
+ + All cells in contiguous columns or rows up to the last used cell + +
+ + + myRange + + + A range named "myRange" at spreadsheet level + + + + + 1) ~.someRange
2) SheetX.someRange
+
+ + A range name at sheet level + +
+ + + myDoc.Range("SheetX.D2:F6") + + + A range within the sheet SheetX in file associated with the myDoc Calc instance + + + + + ~.~ or ~ + + + The current selection in the active sheet + + +
+ +

Properties

+ All the properties generic to any document are implicitly applicable also to Calc documents. For more information, read the Document service Help page. + The properties specifically available for Calc documents are: + + + + Name + + + Readonly + + + Argument + + + Return type + + + Description + + + + + CurrentSelection + + + No + + + None + + + String or array of strings + + + The single selected range as a string or the list of selected ranges as an array. + + + + + FirstCell + + + Yes + + + SheetName or RangeName as String + + + String + + + Returns the first used cell in a given range or sheet. + + + + + FirstColumn + + + Yes + + + SheetName or RangeName as String + + + Long + + + Returns the leftmost column number in a given range or sheet. + + + + + FirstRow + + + Yes + + + SheetName or RangeName as String + + + Long + + + Returns the topmost row number in a given range or sheet. + + + + + Height + + + Yes + + + RangeName As String + + + Long + + + The number of rows (>= 1) in the given range. + + + + + LastCell + + + Yes + + + SheetName or RangeName as String + + + String + + + Returns the last used cell in a given range or sheet. + + + + + LastColumn + + + Yes + + + SheetName or RangeName as String + + + Long + + + The last used column in a given range or sheet. + + + + + LastRow + + + Yes + + + SheetName or RangeName as String + + + Long + + + The last used row in a given range or sheet. + + + + + Range + + + Yes + + + RangeName As String + + + Object + + + A range reference that can be used as argument of methods like CopyToRange. + + + + + Region + + + Yes + + + RangeName As String + + + String + + + Returns the address of the smallest area that contains the specified range so that the area is surrounded by empty cells or sheet edges. This is equivalent to applying the Command + *Ctrl + * shortcut to the given range. + + + + + Sheet + + + Yes + + + SheetName As String + + + Object + + + A sheet reference that can be used as argument of methods like CopySheet. + + + + + SheetName + + + Yes + + + RangeName As String + + + String + + + Returns the sheet name of a given range address. + + + + + Sheets + + + Yes + + + None + + + Array of strings + + + The list with the names of all existing sheets. + + + + + Width + + + Yes + + + RangeName As String + + + Long + + + The number of columns (>= 1) in the given range. + + + + + XCellRange + + + Yes + + + RangeName As String + + + Object + + + A com.sun.star.Table.XCellRange UNO object. + + + + + XSheetCellCursor + + + Yes + + + RangeName As String + + + Object + + + A com.sun.star.sheet.XSheetCellCursor UNO object. After moving the cursor, the resulting range address can be accessed through the AbsoluteName UNO property of the cursor object, which returns a string value that can be used as argument for properties and methods of the Calc service. + + + + + XSpreadsheet + + + Yes + + + SheetName As String + + + Object + + + A com.sun.star.sheet.XSpreadsheet UNO object. + + +
+ + Visit %PRODUCTNAME API Documentation's website to learn more about XCellRange, XSheetCellCursor and XSpreadsheet UNO objects. + +

Methods

+ + + List of Methods in the Calc Service + + + + + A1Style
+ Activate
+ Charts
+ ClearAll
+ ClearFormats
+ ClearValues
+ CompactLeft
+ CompactUp
+ CopySheet
+ CopySheetFromFile
+ CopyToCell
+ CopyToRange
+ CreateChart
+ CreatePivotTable
+ DAvg
+
+
+ + + DCount
+ DMax
+ DMin
+ DSum
+ ExportRangeToFile
+ Forms
+ GetColumnName
+ GetFormula
+ GetValue
+ ImportFromCSVFile
+ ImportFromDatabase
+ InsertSheet
+ MoveRange
+ MoveSheet
+ Offset
+
+
+ + + OpenRangeSelector
+ PrintOut
+ Printf
+ RemoveSheet
+ RenameSheet
+ SetArray
+ SetValue
+ SetCellStyle
+ SetFormula
+ ShiftDown
+ ShiftLeft
+ ShiftRight
+ ShiftUp
+ SortRange

+
+
+
+
+ +
+ A1Style ----------------------------------------------------------------------------------------------- + + Calc service;A1Style + +

A1Style

+ Returns a range address as a string based on sheet coordinates, i.e. row and column numbers. + If only a pair of coordinates is given, then an address to a single cell is returned. Additional arguments can specify the bottom-right cell of a rectangular range. + + + svc.A1Style(row1: int, column1: int, row2: int = 0; column2: int = 0; sheetname: str = "~"): str + + + row1, column1: Specify the row and column numbers of the top-left cell in the range to be considered. Row and column numbers start at 1. + row2, column2: Specify the row and column numbers of the bottom-right cell in the range to be considered. If these arguments are not provided, or if values smaller than row1 and column1 are given, then the address of the single cell range represented by row1 and column1 is returned. + sheetname: The name of the sheet to be appended to the returned range address. The sheet must exist. The default value is "~" corresponding to the currently active sheet. + + The examples below in Basic and Python consider that "Sheet1" is the currently active sheet. + + + Set oDoc = CreateScriptService("Calc") + addr1 = oDoc.A1Style(1, 1) ' '$Sheet1'.$A$1 + addr2 = oDoc.A1Style(2, 2, 3, 6) ' '$Sheet1'.$B$2:$F$3 + addr3 = oDoc.A1Style(2, 2, 0, 6) ' '$Sheet1'.$B$2 + addr4 = oDoc.A1Style(3, 4, 3, 8, "Sheet2") ' '$Sheet2'.$D$3:$H$3 + addr5 = oDoc.A1Style(5, 1, SheetName := "Sheet3") ' '$Sheet3'.$A$5 + + + + doc = CreateScriptService("Calc") + addr1 = doc.A1Style(1, 1) # '$Sheet1'.$A$1 + addr2 = doc.A1Style(2, 2, 3, 6) # '$Sheet1'.$B$2:$F$3 + addr3 = doc.A1Style(2, 2, 0, 6) # '$Sheet1'.$B$2 + addr4 = doc.A1Style(3, 4, 3, 8, "Sheet2") # '$Sheet2'.$D$3:$H$3 + addr5 = doc.A1Style(5, 1, sheetname="Sheet3") # '$Sheet3'.$A$5 + + The method A1Style can be combined with any of the many properties and methods of the Calc service that require a range as argument, such as GetValue, GetFormula, ClearAll, etc. +
+ +
+ Activate -------------------------------------------------------------------------------------------------------------------------- + + Calc service;Activate + +

Activate

+ If the argument sheetname is provided, the given sheet is activated and it becomes the currently selected sheet. If the argument is absent, then the document window is activated. + + + svc.Activate(sheetname: str = ""): bool + + + sheetname: The name of the sheet to be activated in the document. The default value is an empty string, meaning that the document window will be activated without changing the active sheet. + + The example below activates the sheet named "Sheet4" in the currently active document. + + + Dim ui as Variant, oDoc as Object + Set ui = CreateScriptService("UI") + Set oDoc = ui.GetDocument(ui.ActiveWindow) + oDoc.Activate("Sheet4") + + + + ui = CreateScriptService("UI") + myDoc = ui.GetDocument(ui.ActiveWindow) + myDoc.Activate("Sheet4") + + Activating a sheet makes sense only if it is performed on a Calc document. To make sure you have a Calc document at hand you can use the isCalc property of the document object, which returns True if it is a Calc document and False otherwise. +
+ +
+ Charts ------------------------------------------------------------------------------------------------ + + Calc service;Charts + +

Charts

+ Returns either the list with the names of all chart objects in a given sheet or a single Chart service instance. + + + If only sheetname is specified, a zero-based array of strings containing the names of all charts is returned. + + + If a chartname is provided, then a single object corresponding to the desired chart is returned. The specified chart must exist. + + + + + svc.Charts(sheetname: str, chartname: str = ""): obj + + + sheetname: The name of the sheet from which the list of charts is to be retrieved or where the specified chart is located. + chartname: The user-defined name of the chart object to be returned. If the chart does not have a user-defined name, then the internal object name can be used. If this argument is absent, then the list of chart names in the specified sheet is returned. + Use the Navigator sidebar to check the names assigned to charts under the OLE objects category. + + + The example below shows the number of chart objects in "Sheet1". + + Dim arrNames as Object + arrNames = oDoc.Charts("Sheet1") + MsgBox "There are " & UBound(arrNames) + 1 & " charts in Sheet1" + + The following example accesses the chart named "MyChart" in "Sheet1" and prints its type. + + Dim oChart as Object + oChart = oDoc.Charts("Sheet1", "MyChart") + MsgBox oChart.ChartType + + + + bas = CreateScriptService("Basic") + chart_names = doc.Charts("Sheet1") + bas.MsgBox(f"There are {len(chart_names)} charts in Sheet1") + + + chart = doc.Charts("Sheet1", "MyChart") + bas.MsgBox(chart.ChartType) + +
+ +
+ ClearAll -------------------------------------------------------------------------------------------------------------------------- + + Calc service;ClearAll + +

ClearAll

+ Clears all the contents and formats of the given range. + + + svc.ClearAll(range: str) + + + range: The range to be cleared, as a string. + + + + oDoc.ClearAll("SheetX.A1:F10") + + + + myDoc.ClearAll("SheetX.A1:F10") + +
+ +
+ ClearFormats -------------------------------------------------------------------------------------------------------------------------- + + Calc service;ClearFormats + +

ClearFormats

+ Clears the formats and styles in the given range. + + + svc.ClearFormats(range: str) + + + range: The range whose formats and styles are to be cleared, as a string. + + + + oDoc.ClearFormats("SheetX.*") + + + + myDoc.ClearFormats("SheetX.*") + +
+ +
+ ClearValues -------------------------------------------------------------------------------------------------------------------------- + + Calc service;ClearValues + +

ClearValues

+ Clears the values and formulas in the given range. + + + svc.ClearValues(range: str) + + + range: The range whose values and formulas are to be cleared, as a string. + + + + oDoc.ClearValues("SheetX.A1:F10") + + + + myDoc.ClearValues("SheetX.A1:F10") + +
+ +
+ CompactLeft ------------------------------------------------------------------------------------------- + + Calc service;CompactLeft + +

CompactLeft

+ Deletes the columns of a specified range that match a filter expressed as a Calc formula. The filter is applied to each column to decide whether it will be deleted or not. + The deleted column can be limited to the height of the specified range or span to the height of the entire sheet, thus deleting whole columns. + This method returns a string with the range address of the compacted range. If all columns are deleted, then an empty string is returned. + If a range of cells is selected, calling this method will not impact the selection. + + + svc.CompactLeft(range: str, wholecolumn: bool = False, opt filterformula: str): str + + + range: The range from which columns will be deleted, as a string. + wholecolumn: If this option is set to True the entire column will be deleted from the sheet. The default value is False, which means that the deleted column will be limited to the height of the specified range. + filterformula: The filter to be applied to each column to determine whether or not it will be deleted. The filter is expressed as a Calc formula that should be applied to the first column. When the formula returns True for a column, that column will be deleted. The default filter deletes all empty columns. + For example, suppose range A1:J200 is selected (height = 200), so the default formula is =(COUNTBLANK(A1:A200)=200). This means that if all 200 cells are empty in the first column (Column A), then the column is deleted. Note that the formula is expressed with respect to the first column only. Internally the CompactLeft method will generalize this formula for all the remaining columns. + + + + ' Delete all empty columns in the range G1:L10 from Sheet1 + newrange = oDoc.CompactLeft("Sheet1.G1:L10") + ' The example below is similar, but the entire column is deleted from the sheet + newrange = oDoc.CompactLeft("Sheet1.G1:L10", WholeColumn := True) + ' Deletes all columns where the first row is marked with an "X" + newrange = oDoc.CompactLeft("Sheet1.G1:L10", FilterFormula := "=(G1=""X"")") + ' Deletes all columns where the sum of values in the column is odd + newrange = oDoc.CompactLeft("Sheet1.G1:L10", FilterFormula := "=(MOD(SUM(G1:G10);2)=1)") + + + + newrange = myDoc.CompactLeft("Sheet1.G1:L10") + newrange = myDoc.CompactLeft("Sheet1.G1:L10", wholecolumn = True) + newrange = myDoc.CompactLeft("Sheet1.G1:L10", filterformula = '=(G1="X")') + newrange = myDoc.CompactLeft("Sheet1.G1:L10", filterformula = '=(MOD(SUM(G1:G10);2)=1)') + +
+ +
+ CompactUp --------------------------------------------------------------------------------------------- + + Calc service;CompactUp + +

CompactUp

+ Deletes the rows of a specified range that match a filter expressed as a Calc formula. The filter is applied to each row to decide whether it will be deleted or not. + The deleted rows can be limited to the width of the specified range or span to the width of the entire sheet, thus deleting whole rows. + This method returns a string with the range address of the compacted range. If all rows are deleted, then an empty string is returned. + If a range of cells is selected, calling this method will not impact the selection. + + + svc.CompactUp(range: str, wholerow: bool = False, opt filterformula: str): str + + + range: The range from which rows will be deleted, as a string. + wholerow: If this option is set to True the entire row will be deleted from the sheet. The default value is False, which means that the deleted row will be limited to the width of the specified range. + filterformula: The filter to be applied to each row to determine whether or not it will be deleted. The filter is expressed as a Calc formula that should be applied to the first row. When the formula returns True for a row, that row will be deleted. The default filter deletes all empty rows. + For example, suppose range A1:J200 is selected (width = 10), so the default formula is =(COUNTBLANK(A1:J1)=10). This means that if all 10 cells are empty in the first row (Row 1), then the row is deleted. Note that the formula is expressed with respect to the first row only. Internally the CompactUp method will generalize this formula for all the remaining rows. + + + + ' Delete all empty rows in the range G1:L10 from Sheet1 + newrange = oDoc.CompactUp("Sheet1.G1:L10") + ' The example below is similar, but the entire row is deleted from the sheet + newrange = oDoc.CompactUp("Sheet1.G1:L10", WholeRow := True) + ' Deletes all rows where the first column is marked with an "X" + newrange = oDoc.CompactUp("Sheet1.G1:L10", FilterFormula := "=(G1=""X"")") + ' Deletes all rows where the sum of values in the row is odd + newrange = oDoc.CompactUp("Sheet1.G1:L10", FilterFormula := "=(MOD(SUM(G1:L1);2)=1)") + + + + newrange = myDoc.CompactUp("Sheet1.G1:L10") + newrange = myDoc.CompactUp("Sheet1.G1:L10", wholerow = True) + newrange = myDoc.CompactUp("Sheet1.G1:L10", filterformula = '=(G1="X")') + newrange = myDoc.CompactUp("Sheet1.G1:L10", filterformula = '=(MOD(SUM(G1:L1);2)=1)') + +
+ +
+ CopySheet -------------------------------------------------------------------------------------------------------------------------- + + Calc service;CopySheet + +

CopySheet

+ Copies a specified sheet before an existing sheet or at the end of the list of sheets. The sheet to be copied may be contained inside any open Calc document. Returns True if successful. + + + svc.CopySheet(sheetname: any, newname: str, [beforesheet: any]): bool + + + sheetname: The name of the sheet to be copied as a string or its reference as an object. + newname: The name of the sheet to insert. The name must not be in use in the document. + beforesheet: The name (string) or index (numeric, starting from 1) of the sheet before which to insert the copied sheet. This argument is optional and the default behavior is to add the copied sheet at the last position. + + + The following example makes a copy of the sheet "SheetX" and places it as the last sheet in the current document. The name of the copied sheet is "SheetY". + + Dim oDoc as Object + 'Gets the Document object of the active window + Set oDoc = CreateScriptService("Calc") + oDoc.CopySheet("SheetX", "SheetY") + + The example below copies "SheetX" from "FileA.ods" and pastes it at the last position of "FileB.ods" with the name "SheetY": + + Dim oDocA As Object : Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True) + Dim oDocB As Object : Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods") + oDocB.CopySheet(oDocA.Sheet("SheetX"), "SheetY") + + + + myDoc.CopySheet("SheetX", "SheetY") + + + docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True) + docB = ui.OpenDocument(r"C:\Documents\FileB.ods") + docB.CopySheet(docA.Sheet("SheetX"), "SheetY") + + To copy sheets between open documents, use CopySheet. To copy sheets from documents that are closed, use CopySheetFromFile. +
+ +
+ CopySheetFromFile -------------------------------------------------------------------------------------------------------------------------- + + Calc service;CopySheetFromFile + +

CopySheetFromFile

+ Copies a specified sheet from a closed Calc document and pastes it before an existing sheet or at the end of the list of sheets of the file referred to by a Document object. + If the file does not exist, an error is raised. If the file is not a valid Calc file, a blank sheet is inserted. If the source sheet does not exist in the input file, an error message is inserted at the top of the newly pasted sheet. + + + svc.CopySheetFromFile(filename: str, sheetname: str, newname: str, [beforesheet: any]): bool + + + filename: Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation. The file must not be protected with a password. + sheetname: The name of the sheet to be copied as a string. + newname: The name of the copied sheet to be inserted in the document. The name must not be in use in the document. + beforesheet: The name (string) or index (numeric, starting from 1) of the sheet before which to insert the copied sheet. This argument is optional and the default behavior is to add the copied sheet at the last position. + + The following example copies "SheetX" from "myFile.ods" and pastes it into the document referred to by "oDoc" as "SheetY" at the first position. + + + oDoc.CopySheetFromFile("C:\Documents\myFile.ods", "SheetX", "SheetY", 1) + + + + myDoc.CopySheetFromFile(r"C:\Documents\myFile.ods", "SheetX", "SheetY", 1) + +
+ +
+ CopyToCell -------------------------------------------------------------------------------------------------------------------------- + + Calc service;CopyToCell + +

CopyToCell

+ Copies a specified source range (values, formulas and formats) to a destination range or cell. The method reproduces the behaviour of a Copy/Paste operation from a range to a single cell. + It returns a string representing the modified range of cells. The size of the modified area is fully determined by the size of the source area. + The source range may belong to another open document. + + + svc.CopyToCell(sourcerange: any, destinationcell: str): str + + + sourcerange: The source range as a string when it belongs to the same document or as a reference when it belongs to another open Calc document. + destinationcell: The destination cell where the copied range of cells will be pasted, as a string. If a range is given, only its top-left cell is considered. + + + Next is an example where the source and destination are in the same file: + + oDoc.CopyToCell("SheetX.A1:F10", "SheetY.C5") + + The example below illustrates how to copy a range from another open Calc document: + + Dim ui as Variant : ui = CreateScriptService("UI") + Dim oDocSource As Object, oDocDestination As Object + 'Open the source document in the background (hidden) + Set oDocSource = ui.OpenDocument("C:\SourceFile.ods", Hidden := True, ReadOnly := True) + Set oDocDestination = CreateScriptService("Calc") + oDocDestination.CopyToCell(oDocSource.Range("Sheet1.C2:C4"), "SheetT.A5") + 'Do not forget to close the source document because it was opened as hidden + oDocSource.CloseDocument() + + + + docSource = ui.OpenDocument(r"C:\Documents\SourceFile.ods", hidden = True, readonly = True) + docDestination = CreateScriptService("Calc") + docDestination.CopyToCell(docSource.Range("Sheet1.C2:C4"), "SheetT.A5") + docSource.CloseDocument() + + To simulate a Copy/Paste from a range to a single cell, use CopyToCell. To simulate a Copy/Paste from a range to a larger range (with the same cells being replicated several times), use CopyToRange. +
+ +
+ CopyToRange -------------------------------------------------------------------------------------------------------------------------- + + Calc service;CopyToRange + +

CopyToRange

+ Copies downwards and/or rightwards a specified source range (values, formulas and formats) to a destination range. The method imitates the behaviour of a Copy/Paste operation from a source range to a larger destination range. + + + If the height (or width) of the destination area is > 1 row (or column) then the height (or width) of the source must be <= the height (or width) of the destination. Otherwise nothing happens. + + + If the height (or width) of the destination is = 1 then the destination is expanded downwards (or rightwards) up to the height (or width) of the source range. + + + The method returns a string representing the modified range of cells. + The source range may belong to another open document. + + + svc.CopyToRange(sourcerange: any, destinationrange: str): str + + + sourcerange: The source range as a string when it belongs to the same document or as a reference when it belongs to another open Calc document. + destinationrange: The destination of the copied range of cells, as a string. + + + Copy within the same document: + + oDoc.CopyToRange("SheetX.A1:F10", "SheetY.C5:J5") + ' Returns a range string: "$SheetY.$C$5:$J$14" + + Copy from one file to another: + + Dim oDocA As Object : Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True) + Dim oDocB As Object : Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods") + oDocB.CopyToRange(oDocA.Range("SheetX.A1:F10"), "SheetY.C5:J5") + + + + doc.CopyToRange("SheetX.A1:F10", "SheetY.C5:J5") + + + docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True) + docB = ui.OpenDocument(r"C:\Documents\FileB.ods") + docB.CopyToRange(docA.Range("SheetX.A1:F10"), "SheetY.C5:J5") + +
+ +
+ CreateChart ------------------------------------------------------------------------------------------- + + Calc service;CreateChart + +

CreateChart

+ Creates a new chart object showing the data in the specified range. The returned chart object can be further manipulated using the Chart service. + + + svc.CreateChart(chartname: str, sheetname: str, range: str, columnheader: bool = False, rowheader: bool = False): obj + + + chartname: The user-defined name of the chart to be created. The name must be unique in the same sheet. + sheetname: The name of the sheet where the chart will be placed. + range: The range to be used as the data source for the chart. The range may refer to any sheet of the Calc document. + columnheader: When True, the topmost row of the range is used as labels for the category axis or the legend (Default = False). + rowheader: When True, the leftmost column of the range is used as labels for the category axis or the legend. (Default = False). + + The examples below in Basic and Python create a chart using the data contained in the range "A1:B5" of "Sheet1" and place the chart in "Sheet2". + + + Set oChart = oDoc.CreateChart("MyChart", "Sheet2", "Sheet1.A1:B5", RowHeader := True) + oChart.ChartType = "Donut" + + + + chart = doc.CreateChart("MyChart", "Sheet2", "Sheet1.A1:B5", rowheader=True) + chart.ChartType = "Donut" + + Refer to the help page about ScriptForge's Chart service to learn more how to further manipulate chart objects. It is possible to change properties as the chart type, chart and axes titles and chart position. +
+ +
+ CreatePivotTable ---------------------------------------------------------------------------------------- + + Calc service;CreatePivotTable + +

CreatePivotTable

+ Creates a new pivot table with the properties defined by the arguments passed to the method. + A name must be provided for the pivot table. If a pivot table with the same name already exists in the targeted sheet, it will be replaced without warning. + This method returns a string containing the range where the new pivot table was placed. + + + svc.CreatePivotTable(pivottablename: str, sourcerange: str, targetcell: str, datafields: str[0..*], rowfields: str[0..*], columnfields: str[0..*], filterbutton: bool = true, rowtotals: bool = true, columntotals: bool = true): str + + + pivottablename: The user-defined name of the new pivot table. + sourcerange: The range containing the raw data, as a string. It is assumed that the first row contains the field names that are used by the pivot table. + targetcell: The top-left cell where the new pivot table will be placed. If a range is specified, only its top-left cell is considered. + datafields: It can be either a single string or an array containing strings that define field names and functions to be applied. When an array is specified, it must follow the syntax Array("FieldName[;Function]", ...). + The allowed functions are: Sum, Count, Average, Max, Min, Product, CountNums, StDev, StDevP, Var, VarP and Median. Function names must be provided in English. When all values are numerical, Sum is the default function, otherwise the default function is Count. + rowfields: A single string or an array with the field names that will be used as the pivot table rows. + columnfields: A single string or an array with the field names that will be used as the pivot table columns. + filterbutton: Determines whether a filter button will be displayed above the pivot table (Default = True). + rowtotals: Specifies if a separate column for row totals will be added to the pivot table (Default = True). + columntotals Specifies if a separate row for column totals will be added to the pivot table (Default = True) + + + + Dim vData As Variant, oDoc As Object, ui As Object, sTable As String, sPivot As String + Set ui = CreateScriptService("UI") + Set oDoc = ui.CreateDocument("Calc") + vData = Array(Array("Item", "State", "Team", "2002", "2003", "2004"), _ + Array("Books", "Michigan", "Jean", 14788, 30222, 23490), _ + Array("Candy", "Michigan", "Jean", 26388, 15641, 32849), _ + Array("Pens", "Michigan", "Jean", 16569, 32675, 25396), _ + Array("Books", "Michigan", "Volker", 21961, 21242, 29009), _ + Array("Candy", "Michigan", "Volker", 26142, 22407, 32841)) + sTable = oDoc.SetArray("A1", vData) + sPivot = oDoc.CreatePivotTable("PT1", sTable, "H1", _ + Array("2002", "2003;count", "2004;average"), _ ' Three data fields + "Item", _ ' A single row field + Array("State", "Team"), False) ' Two column fields + + + + ui = CreateScriptService("UI") + doc = ui.CreateDocument("Calc") + vData = [["Item", "State", "Team", "2002", "2003", "2004"], + ["Books", "Michigan", "Jean", 14788, 30222, 23490], + ["Candy", "Michigan", "Jean", 26388, 15641, 32849], + ["Pens", "Michigan", "Jean", 16569, 32675, 25396)], + ["Books", "Michigan", "Volker", 21961, 21242, 29009], + ["Candy", "Michigan", "Volker", 26142, 22407, 32841]] + sTable = doc.SetArray("A1", vData) + sPivot = doc.CreatePivotTable("PT1", sTable, "H1", + ["2002", "2003;count", "2004;average"], + "Item", + ["State", "Team"], False) + + To learn more about Pivot Tables in %PRODUCTNAME Calc, read the Pivot Table help page. +
+ + +
+ DAvg, DCount, DMax, DMin, DSum -------------------------------------------------------------------------------------------------------------------------- + + Calc service;DAvg + Calc service;DCount + Calc service;DMax + Calc service;DMin + Calc service;DSum + +

DAvg, DCount, DMax, DMin and DSum

+ Apply the functions Average, Count, Max, Min and Sum, respectively, to all the cells containing numeric values on a given range. + + + svc.DAvg(range: str): float + + + svc.DCount(range: str): float + + + svc.DMax(range: str): float + + + svc.DMin(range: str): float + + + svc.DSum(range: str): float + + + range: The range to which the function will be applied, as a string. + + The example below applies the Sum function to the range "A1:A1000" of the currently selected sheet: + + + result = oDoc.DSum("~.A1:A1000") + + + + result = myDoc.DSum("~.A1:A1000") + + Cells in the given range that contain text will be ignored by all of these functions. For example, the DCount method will not count cells with text, only numerical cells. +
+ +
+ ExportRangeToFile --------------------------------------------------------------------------------------- + + Calc service;ExportRangeToFile + +

ExportRangeToFile

+ Exports the specified range as an image or PDF file. + This method returns True if the destination file was successfully saved. + Hidden rows or columns in the specified range are not exported to the destination file. + + + svc.ExportRangeToFile(range: str, filename: str, imagetype: str = "pdf", overwrite: bool = False): bool + + + range: A sheet name or a cell range to be exported, as a string. + filename: The name of the file to be saved. It must follow the SF_FileSystem.FileNaming notation. + imagetype: Identifies the destination file type. Possible values are "jpeg", "pdf" (default) and "png". + overwrite: When set to True, the destination file may be overwritten (Default = False). + + + + ' Exports the entire sheet as a PDF file + oDoc.ExportRangeToFile("SheetX", "C:\Temp\image.pdf") + ' Exports the range as a PNG file and overwrites the destination file if it exists + oDoc.ExportRangeToFile("SheetX.A1:D10", "C:\Temp\image.png", "png", Overwrite := True) + + + + doc.ExportRangeToFile("SheetX", r"C:\Temp\image.pdf") + doc.ExportRangeToFile("SheetX.A1:D10", r"C:\Temp\image.png", "png", overwrite = True) + +
+ +
+ Forms ------------------------------------------------------------------------------------------- + + Calc service;Forms + +

Forms

+ Depending on the parameters provided this method will return: + + + A zero-based Array (or a tuple in Python) with the names of all the forms contained in a given sheet (if the form argument is absent) + + + A SFDocuments.Form service instance representing the form specified as argument. + + + + + svc.Forms(sheetname: str): str[0..*] + + + svc.Forms(sheetname: str, form: str = ''): svc + + + svc.Forms(sheetname: str, form: int): svc + + + sheetname: The name of the sheet, as a string, from which the form will be retrieved. + form: The name or index corresponding to a form stored in the specified sheet. If this argument is absent, the method will return a list with the names of all forms available in the sheet. + + In the following examples, the first line gets the names of all forms stored in "Sheet1" and the second line retrieves the Form object of the form named "Form_A" which is stored in "Sheet1". + + + Set FormNames = oDoc.Forms("Sheet1") + Set FormA = oDoc.Forms("Sheet1", "Form_A") + + + + form_names = doc.Forms("Sheet1") + form_A = doc.Forms("Sheet1", "Form_A") + +
+ +
+ GetColumnName -------------------------------------------------------------------------------------------------------------------------- + + Calc service;GetColumnName + +

GetColumnName

+ Converts a column number ranging between 1 and 1024 into its corresponding letter (column 'A', 'B', ..., 'AMJ'). If the given column number is outside the allowed range, a zero-length string is returned. + + + svc.GetColumnName(columnnumber: int): str + + + columnnumber: The column number as an integer value in the interval 1 ... 1024. + + + Displays a message box with the name of the third column, which by default is "C". + + MsgBox oDoc.GetColumnName(3) + + + + bas = CreateScriptService("Basic") + bas.MsgBox(myDoc.GetColumnName(3)) + + The maximum number of columns allowed on a Calc sheet is 1024. +
+ +
+ GetFormula -------------------------------------------------------------------------------------------------------------------------- + + Calc service;GetFormula + +

GetFormula

+ Get the formula(s) stored in the given range of cells as a single string, a 1D or a 2D array of strings. + + + svc.GetFormula(range: str): any + + + range: The range where to get the formulas from, as a string. + + + The following example returns a 3 by 2 array with the formulas in the range "A1:B3" (3 rows by 2 columns): + + arrFormula = oDoc.GetFormula("~.A1:B3") + + + + arrFormula = myDoc.GetFormula("~.A1:B3") + +
+ +
+ GetValue -------------------------------------------------------------------------------------------------------------------------- + + Calc service;GetValue + +

GetValue

+ Get the value(s) stored in the given range of cells as a single value, a 1D array or a 2D array. All values are either doubles or strings. + + + svc.GetValue(range: str): any + + + range: The range where to get the values from, as a string. + + + + arrValues = oDoc.GetValue("~.B1:C100") + + + + arrValues = myDoc.GetValue("~.B1:C100") + + If a cell contains a date, the number corresponding to that date will be returned. To convert numeric values to dates in Basic scripts, use the Basic CDate builtin function. In Python scripts, use the CDate function from the Basic service. +
+ +
+ ImportFromCSVFile -------------------------------------------------------------------------------------------------------------------------- + + Calc service;ImportFromCSVFile + +

ImportFromCSVFile

+ Imports the contents of a CSV-formatted text file and places it on a given destination cell. + The destination area is cleared of all contents and formats before inserting the contents of the CSV file. The size of the modified area is fully determined by the contents of the input file. + The method returns a string representing the modified range of cells. + + + svc.ImportFromCSVFile(filename: str, destinationcell: str, [filteroptions: str]): str + + + filename: Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation. + destinationcell: The destination cell to insert the imported data, as a string. If instead a range is given, only its top-left cell is considered. + filteroptions: The arguments for the CSV input filter. The default filter makes following assumptions: + + + The input file encoding is UTF8. + + + The field separator is a comma, a semi-colon or a Tab character. + + + The string delimiter is the double quote ("). + + + All lines are included. + + + Quoted strings are formatted as text. + + + Special numbers are detected. + + + All columns are presumed to be texts, except if recognized as valid numbers. + + + The language is English/US, which implies that the decimal separator is "." and the thousands separator is ",". + + + + + + oDoc.ImportFromCSVFile("C:\Temp\myCSVFile.csv", "SheetY.C5") + + + + myDoc.ImportFromCSVFile(r"C:\Temp\myCSVFile.csv", "SheetY.C5") + + To learn more about the CSV Filter Options, refer to the CSV Filter Options help page. +
+ +
+ ImportFromDatabase -------------------------------------------------------------------------------------------------------------------------- + + Calc service;ImportFromDatabase + +

ImportFromDatabase

+ Imports the contents of a database table, query or resultset, i.e. the result of a SELECT SQL command, inserting it on a destination cell. + The destination area is cleared of all contents and formats before inserting the imported contents. The size of the modified area is fully determined by the contents in the table or query. + The method returns True when the import was successful. + + + svc.ImportFromDatabase(filename: str = "", registrationname: str = "", destinationcell: str = "", sqlcommand: str = "", directsql: bool): bool + + + filename: Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation. + registrationname: The name to use to find the database in the databases register. This argument is ignored if a filename is provided. + destinationcell: The destination of the imported data, as a string. If a range is given, only its top-left cell is considered. + sqlcommand: A table or query name (without surrounding quotes or square brackets) or a SELECT SQL statement in which table and field names may be surrounded by square brackets or quotes to improve its readability. + directsql: When True, the SQL command is sent to the database engine without pre-analysis. Default is False. The argument is ignored for tables. For queries, the applied option is the one set when the query was defined. + + + + oDoc.ImportFromDatabase("C:\Temp\myDbFile.odb", , "SheetY.C5", "SELECT * FROM [Employees] ORDER BY [LastName]") + + + + myDoc.ImportFromDatabase(r"C:\Temp\myDbFile.odb", , "SheetY.C5", "SELECT * FROM [Employees] ORDER BY [LastName]") + +
+ +
+ InsertSheet -------------------------------------------------------------------------------------------------------------------------- + + Calc service;InsertSheet + +

InsertSheet

+ Inserts a new empty sheet before an existing sheet or at the end of the list of sheets. + + + svc.InsertSheet(sheetname: str, [beforesheet: any]): bool + + + sheetname: The name of the new sheet. + beforesheet: The name (string) or index (numeric, starting from 1) of the sheet before which to insert the new sheet. This argument is optional and the default behavior is to insert the sheet at the last position. + + The following example inserts a new empty sheet named "SheetX" and places it before "SheetY": + + + oDoc.InsertSheet("SheetX", "SheetY") + + + + myDoc.InsertSheet("SheetX", "SheetY") + +
+ +
+ MoveRange -------------------------------------------------------------------------------------------------------------------------- + + Calc service;MoveRange + +

MoveRange

+ Moves a specified source range to a destination range of cells. The method returns a string representing the modified range of cells. The dimension of the modified area is fully determined by the size of the source area. + + + + svc.MoveRange(source: str, destination: str): str + + + source: The source range of cells, as a string. + destination: The destination cell, as a string. If a range is given, its top-left cell is considered as the destination. + + + + oDoc.MoveRange("SheetX.A1:F10", "SheetY.C5") + + + + myDoc.MoveRange("SheetX.A1:F10", "SheetY.C5") + +
+ +
+ MoveSheet -------------------------------------------------------------------------------------------------------------------------- + + Calc service;MoveSheet + +

MoveSheet

+ Moves an existing sheet and places it before a specified sheet or at the end of the list of sheets. + + + svc.MoveSheet(sheetname: str, [beforesheet: any]): bool + + + sheetname: The name of the sheet to move. The sheet must exist or an exception is raised. + beforesheet: The name (string) or index (numeric, starting from 1) of the sheet before which the original sheet will be placed. This argument is optional and the default behavior is to move the sheet to the last position. + + The example below moves the existing sheet "SheetX" and places it before "SheetY": + + + oDoc.MoveSheet("SheetX", "SheetY") + + + + myDoc.MoveSheet("SheetX", "SheetY") + +
+ +
+ Offset ------------------------------------------------------------------------------------------------ + + Calc service;Offset + +

Offset

+ Returns a new range (as a string) offset by a certain number of rows and columns from a given range. + This method has the same behavior as the homonymous Calc's Offset function. + + + svc.Offset(reference: str, rows: int = 0, columns: int = 0, [height: int], [width: int]): str + + + reference: The range, as a string, that the method will use as reference to perform the offset operation. + rows: The number of rows by which the initial range is offset upwards (negative value) or downwards (positive value). Use 0 (default) to stay in the same row. + columns: The number of columns by which the initial range is offset to the left (negative value) or to the right (positive value). Use 0 (default) to stay in the same column. + height: The vertical height for an area that starts at the new range position. Omit this argument when no vertical resizing is needed. + width: The horizontal width for an area that starts at the new range position. Omit this argument when no horizontal resizing is needed. + Arguments rows and columns must not lead to zero or negative start row or column. + Arguments height and width must not lead to zero or negative count of rows or columns. + + + + oDoc.Offset("A1", 2, 2) + 'SheetX.$C$3 (A1 moved by two rows and two columns down) + oDoc.Offset("A1", 2, 2, 5, 6) + 'SheetX.$C$3:$H$7 (A1 offset by two rows and columns with width of 5 rows and 6 columns) + + + + myDoc.Offset("A1", 2, 2) + myDoc.Offset("A1", 2, 2, 5, 6) + +
+ +
+ OpenRangeSelector ------------------------------------------------------------------------------------- + + Calc service;OpenRangeSelector + +

OpenRangeSelector

+ Opens a non-modal dialog that can be used to select a range in the document and returns a string containing the selected range. + This method opens the same dialog that is used by %PRODUCTNAME when the Shrink button is pressed. For example, the Tools - Goal Seek dialog has a Shrink button to the right of the Formula cell field. + This method does not change the current selection. + + + svc.OpenRangeSelector(opt title: str, opt selection: str, singlecell: bool = False, closeafterselect: bool = True): str + + + title: The title of the dialog, as a string. + selection: An optional range that is initially selected when the dialog is displayed. + singlecell: When True (default) only single-cell selection is allowed. When False range selection is allowed. + closeafterselect: When True (default) the dialog is closed immediately after the selection is made. When False the user can change the selection as many times as needed and then manually close the dialog. + + + + Dim sRange as String + sRange = oDoc.OpenRangeSelector(Title := "Select a range") + + + + sRange = myDoc.OpenRangeSelector(title = "Select a range") + +
+ +
+ Printf ------------------------------------------------------------------------------------------------ + + Calc service;Printf + +

Printf

+ Returns the input string after substituting its token characters by their values in a given range. + This method does not change the current selection. + This method can be used to quickly extract specific parts of a range name, such as the sheet name or first cell column and row, and use them to compose a new range address. + + + svc.Printf(inputstr: str, range: str, tokencharacter: str = "%"): str + + + inputstr: The string containing the tokens that will be replaced by the corresponding values in range. + range: A RangeName from which values will be extracted. If it contains a sheet name, the sheet must exist. + tokencharacter: Character used to identify tokens. By default "%" is the token character. The following tokens are accepted: + + + %S - The sheet name containing the range, including single quotes when necessary. + + + %R1 - The row number of the top left cell of the range. + + + %C1 - The column letter of the top left cell of the range. + + + %R2 - The row number of the bottom right cell of the range. + + + %C2 - The column letter of the bottom right cell of the range. + + + + + The example below extracts each element of the RangeName defined in sRange and uses them to compose a message. + + Dim sRange as String, sInputStr as String + sRange = "Sheet1.A1:E10" + sInputStr = "Sheet name: %S" & Chr(10) & _ + "First row: %R1" & Chr(10) & _ + "First column %C1" & Chr(10) & _ + "Last row %R2" & Chr(10) & _ + "Last column %C2" + MsgBox oDoc.Printf(sInputStr, sRange) + + The Printf method can be combined with SetFormula to create formulas over multiple cells. For instance, consider a table with numeric values in the range "A1:E10" from which formulas are to be created to sum the values in each row and place the results in the range "F1:F10": + + Dim sFormula as String, sRange as String + sRange = "A1:E10" + ' Note the use of the "$" character + sFormula = "=SUM($%C1%R1:$%C2%R1)" + oDoc.SetFormula("F1:F10", oDoc.Printf(sFormula, sRange)) + + + + sRange = "Sheet1.A1:E10" + sInputStr = "Sheet name: %S\n" \ + "First row: %R1\n" \ + "First column %C1\n" \ + "Last row %R2\n" \ + "Last column %C2" + bas = CreateScriptService("Basic") + bas.MsgBox(myDoc.Printf(sInputStr, sRange)) + + + sRange = "A1:E10 + sFormula = "=SUM($%C1%R1:$%C2%R1)" + myDoc.SetFormula("F1:F10", myDoc.Printf(sFormula, sRange)) + +
+ +
+ PrintOut ---------------------------------------------------------------- + + Calc service;PrintOut + +

PrintOut

+ This method sends the contents of the given sheet to the default printer or to the printer defined by the SetPrinter method of the Document service. + Returns True if the sheet was successfully printed. + + + svc.PrintOut(opt sheetname: str, pages: str = "", copies: num = 1): bool + + + sheetname: The sheet to print, default is the active sheet. + pages: The pages to print as a string, like in the user interface. Example: "1-4;10;15-18". Default is all pages. + copies: The number of copies. Default is 1. + + + + If oDoc.PrintOut("SheetX", "1-4;10;15-18", Copies := 2) Then + ' ... + End If + + + + if doc.PrintOut('SheetX', copies=3, pages='45-88'): + # ... + +
+ +
+ RemoveSheet -------------------------------------------------------------------------------------------------------------------------- + + Calc service;RemoveSheet + +

RemoveSheet

+ Removes an existing sheet from the document. + + + svc.RemoveSheet(sheetname: str): bool + + + sheetname: The name of the sheet to remove. + + + + oDoc.RemoveSheet("SheetY") + + + + myDoc.RemoveSheet("SheetY") + +
+ +
+ RenameSheet -------------------------------------------------------------------------------------------------------------------------- + + Calc service;RenameSheet + +

RenameSheet

+ Renames the given sheet and returns True if successful. + + + svc.RenameSheet(sheetname: str, newname: str): bool + + + sheetname: The name of the sheet to rename. + newname: the new name of the sheet. It must not exist yet. + + This example renames the active sheet to "SheetY": + + + oDoc.RenameSheet("~", "SheetY") + + + + mydoc.RenameSheet("~", "SheetY") + +
+ +
+ SetArray -------------------------------------------------------------------------------------------------------------------------- + + Calc service;SetArray + +

SetArray

+ Stores the given value starting from a specified target cell. The updated area expands itself from the target cell or from the top-left corner of the given range to accommodate the size of the input value argument. Vectors are always expanded vertically. + The method returns a string representing the modified area as a range of cells. + + + svc.SetArray(targetcell: str, value: any): str + + + targetcell: The cell or a range as a string from where to start to store the given value. + value: A scalar, a vector or an array (in Python, one or two-dimensional lists and tuples) with the new values to be stored from the target cell or from the top-left corner of the range if targetcell is a range. The new values must be strings, numeric values or dates. Other types will cause the corresponding cells to be emptied. + + + The following example uses the builtin DimArray function to create an array and then store it in cell "A1": + + Dim arrData as Variant + arrData = DimArray(2, 1) + arrData(0, 0) = 1 : arrData(1, 0) = 2 : arrData(2, 0) = 3 + arrData(0, 1) = "One" : arrData(1, 1) = "Two" : arrData(2, 1) = "Three" + oDoc.SetArray("Sheet1.A1", arrData) + + This example uses the RangeInit method of the ScriptForge Array service to create an array with values that are then stored from cell "A1" and downwards. + + 'Fill 1st column with values from 1 to 1000 + oDoc.SetArray("Sheet1.A1", SF_Array.RangeInit(1, 1000)) + + + + arrData = ((1, "One"), (2, "Two"), (3, "Three")) + myDoc.SetArray("Sheet1.A1", arrData) + + + myDoc.SetArray("Sheet1.A1", tuple(i + 1 for i in range(1000))) + + To dump the full contents of an array in a sheet, use SetArray. To dump the contents of an array only within the boundaries of the targeted range of cells, use SetValue. +
+ +
+ SetValue -------------------------------------------------------------------------------------------------------------------------- + + Calc service;SetValue + +

SetValue

+ Stores the given value in the specified range. The size of the modified area is equal to the size of the target range. + The method returns a string representing the modified area as a range of cells. + + + svc.SetValue(targetrange: str, value: any): str + + + targetrange: The range where to store the given value, as a string. + value: A scalar, a vector or an array with the new values for each cell of the range. The new values must be strings, numeric values or dates. Other types will cause the corresponding cells to be emptied. + The full range is updated and the remainder of the sheet is left unchanged. If the size of value is smaller than the size of targetrange, then the remaining cells will be emptied. + If the size of value is larger than the size of targetrange, then value is only partially copied until it fills the size of targetrange. + Vectors are expanded vertically, except if targetrange has a height of exactly 1 row. + + + + oDoc.SetValue("A1", 2) + 'Below the Value array is smaller than the TargetRange (remaining cells are emptied) + oDoc.SetValue("A1:F1", Array(1, 2, 3)) + 'Below the Value and TargetRange have the same size + oDoc.SetValue("A1:D2", SF_Array.AppendRow(Array(1, 2, 3, 4), Array(5, 6, 7, 8))) + + If you want to fill a single row with values, you can use the Offset function. In the example below, consider that arrData is a one-dimensional array: + + Dim firstCell As String : firstCell = "A1" + Dim lenArray As Integer : lenArray = UBound(arrData) - LBound(arrData) + 1 + Dim newRange As String : newRange = oDoc.Offset(firstCell, width = lenArray) + oDoc.SetValue(newRange, arrData) + + + + myDoc.SetValue("A1", 2) + myDoc.SetValue("A1:F1", (1, 2, 3)) + myDoc.SetValue("A1:D2", ((1, 2, 3, 4), (5, 6, 7, 8))) + + + firstCell = "A1" + newRange = doc.Offset(firstCell, width = len(arrData)) + doc.SetValue(newRange, arrData) + +
+ +
+ SetCellStyle -------------------------------------------------------------------------------------------------------------------------- + + Calc service;SetCellStyle + +

SetCellStyle

+ Applies the specified cell style to the given target range. The full range is updated and the remainder of the sheet is left untouched. If the cell style does not exist, an error is raised. + The method returns a string representing the modified area as a range of cells. + + + svc.SetCellStyle(targetrange: str, style: str): str + + + targetrange: The range to which the style will be applied, as a string. + style: The name of the cell style to apply. + + + + oDoc.SetCellStyle("A1:J1", "Heading 1") + oDoc.SetCellStyle("A2:J100", "Neutral") + + + + myDoc.SetCellStyle("A1:J1", "Heading 1") + myDoc.SetCellStyle("A2:J100", "Neutral") + +
+ +
+ SetFormula -------------------------------------------------------------------------------------------------------------------------- + + Calc service;SetFormula + +

SetFormula

+ Inserts the given (array of) formula(s) in the specified range. The size of the modified area is equal to the size of the range. + The method returns a string representing the modified area as a range of cells. + + + svc.SetFormula(targetrange: str, formula: any): str + + + targetrange: The range to insert the formulas, as a string. + formula: A string, a vector or an array of strings with the new formulas for each cell in the target range. + The full range is updated and the remainder of the sheet is left unchanged. + If the given formula is a string, the unique formula is pasted along the whole range with adjustment of the relative references. + If the size of formula is smaller than the size of targetrange, then the remaining cells are emptied. + If the size of formula is larger than the size of targetrange, then the formulas are only partially copied until it fills the size of targetrange. + Vectors are always expanded vertically, except if targetrange has a height of exactly 1 row. + + + + oDoc.SetFormula("A1", "=A2") + 'Horizontal vector, partially empty + oDoc.SetFormula("A1:F1", Array("=A2", "=B2", "=C2+10")) + 'D2 contains the formula "=H2" + oDoc.SetFormula("A1:D2", "=E1") + + + + myDoc.SetFormula("A1", "=A2") + myDoc.SetFormula("A1:F1", ("=A2", "=B2", "=C2+10")) + myDoc.SetFormula("A1:D2", "=E1") + +
+ +
+ ShiftDown --------------------------------------------------------------------------------------------- + + Calc service;ShiftDown + +

ShiftDown

+ Moves a given range of cells downwards by inserting empty rows. The current selection is not affected. + Depending on the value of the wholerow argument the inserted rows can either span the width of the specified range or span all columns in the row. + This method returns a string representing the new location of the initial range. + If the shifted range exceeds the sheet edges, then nothing happens. + + + svc.ShiftDown(range: str, wholerow: bool = False, opt rows: int): str + + + range: The range above which rows will be inserted, as a string. + wholerow: If set to False (default), then the width of the inserted rows will be the same as the width of the specified range. Otherwise, the inserted row will span all columns in the sheet. + rows: The number of rows to be inserted. The default value is the height of the original range. The number of rows must be a positive number. + + + + ' Moves the range "A3:D3" down by one row; affects only columns A to D + oDoc.ShiftDown("A3:D3") + ' The inserted row spans all columns in the sheet + oDoc.ShiftDown("A3:D3", WholeRow := True) + ' Moves the range "A3:D3" down by five rows + oDoc.ShiftDown("A3:D3", Rows := 5) + ' Moves the range "A3:D10" down by two rows and shows the new location of the original range + Dim sNewRange as String + sNewRange = oDoc.ShiftDown("A3:D10", Rows := 2) + MsgBox sNewRange ' $Sheet1.$A$5:$D$12 + + + + myDoc.ShiftDown("A3:D3") + myDoc.ShiftDown("A3:D3", wholerow = True) + myDoc.ShiftDown("A3:D3", rows = 5) + sNewRange = myDoc.ShiftDown("A3:D10", rows = 2) + bas = CreateScriptService("Basic") + bas.MsgBox(sNewRange) + +
+ +
+ ShiftLeft --------------------------------------------------------------------------------------------- + + Calc service;ShiftLeft + +

ShiftLeft

+ Deletes the leftmost columns of a given range and moves to the left all cells to the right of the affected range. The current selection is not affected. + Depending on the value of the wholecolumn argument the deleted columns can either span the height of the specified range or span all rows in the column. + This method returns a string representing the location of the remaining portion of the initial range. If all cells in the original range have been deleted, then an empty string is returned. + + + svc.ShiftLeft(range: str, wholecolumn: bool = False, opt columns: int): str + + + range: The range from which cells will be deleted, as a string. + wholecolumn: If set to False (default), then the height of the deleted columns will be the same as the height of the specified range. Otherwise, the deleted columns will span all rows in the sheet. + columns: The number of columns to be deleted from the specified range. The default value is the width of the original range, which is also the maximum value of this argument. + + + + ' Deletes the range "B3:B6"; moves left all cells to the right + oDoc.ShiftLeft("B3:B6") + ' Deletes the first column in the range "A3:D6" + oDoc.ShiftLeft("A3:D6", Columns := 1) + ' The deleted columns (A to D) spans all rows in the sheet + oDoc.ShiftLeft("A3:D6", WholeColumn := True) + + + + myDoc.ShiftLeft("B3:B6") + myDoc.ShiftLeft("A3:D6", Columns = 1) + myDoc.ShiftLeft("A3:D6", WholeColumn = True) + +
+ +
+ ShiftUp ----------------------------------------------------------------------------------------------- + + Calc service;ShiftUp + +

ShiftUp

+ Deletes the topmost rows of a given range and moves upwards all cells below the affected range. The current selection is not affected. + Depending on the value of the wholerow argument the deleted rows can either span the width of the specified range or span all columns in the row. + This method returns a string representing the location of the remaining portion of the initial range. If all cells in the original range have been deleted, then an empty string is returned. + + + svc.ShiftUp(range: str, wholerow: bool = False, opt rows: int): str + + + range: The range from which cells will be deleted, as a string. + wholerow: If set to False (default), then the width of the deleted rows will be the same as the width of the specified range. Otherwise, the deleted row will span all columns in the sheet. + rows: The number of rows to be deleted from the specified range. The default value is the height of the original range, which is also the maximum value of this argument. + + + + ' Deletes the range "A3:D3"; moves all cells below it by one row up + oDoc.ShiftUp("A3:D3") + ' Deletes the first row in the range "A3:D6" + oDoc.ShiftUp("A3:D6", Rows := 1) + ' The deleted rows spans all columns in the sheet + oDoc.ShiftUp("A3:D6", WholeRow := True) + + + + myDoc.ShiftUp("A3:D3") + myDoc.ShiftUp("A3:D6", rows = 1) + myDoc.ShiftUp("A3:D6", wholerow = True) + +
+ +
+ ShiftRight --------------------------------------------------------------------------------------------- + + Calc service;ShiftRight + +

ShiftRight

+ Moves a given range of cells to the right by inserting empty columns. The current selection is not affected. + Depending on the value of the wholecolumn argument the inserted columns can either span the height of the specified range or span all rows in the column. + This method returns a string representing the new location of the initial range. + If the shifted range exceeds the sheet edges, then nothing happens. + + + svc.ShiftRight(range: str, wholecolumn: bool = False, opt columns: int): str + + + range: The range which will have empty columns inserted to its left, as a string. + wholecolumn: If set to False (default), then the height of the inserted columns will be the same as the height of the specified range. Otherwise, the inserted columns will span all rows in the sheet. + columns: The number of columns to be inserted. The default value is the width of the original range. + + + + ' Moves the range "A3:A6" right by one column; affects only rows 3 to 6 + oDoc.ShiftRight("A3:A6") + ' Moves the range "A3:A6" right by five columns + oDoc.ShiftRight("A3:A6", Columns := 5) + ' The inserted column spans all rows in the sheet + oDoc.ShiftRight("A3:A6", WholeColumn := True) + + + + myDoc.ShiftRight("A3:A6") + myDoc.ShiftRight("A3:A6", columns = 5) + myDoc.ShiftRight("A3:A6", wholecolumn = True) + +
+ +
+ SortRange -------------------------------------------------------------------------------------------------------------------------- + + Calc service;SortRange + +

SortRange

+ Sorts the given range based on up to 3 columns/rows. The sorting order may vary by column/row. It returns a string representing the modified range of cells. The size of the modified area is fully determined by the size of the source area. + + + svc.SortRange(range: str, sortkeys: any, sortorder: any = "ASC", destinationcell: str = "", containsheader: bool = False, casesensitive: bool = False, sortcolumns: bool = False): str + + + range: The range to be sorted, as a string. + sortkeys: A scalar (if 1 column/row) or an array of column/row numbers starting from 1. The maximum number of keys is 3. + sortorder: A scalar or an array of strings containing the values "ASC" (ascending), "DESC" (descending) or "" (which defaults to ascending). Each item is paired with the corresponding item in sortkeys. If the sortorder array is shorter than sortkeys, the remaining keys are sorted in ascending order. + destinationcell: The destination cell of the sorted range of cells, as a string. If a range is given, only its top-left cell is considered. By default the source Range is overwritten. + containsheader: When True, the first row/column is not sorted. + casesensitive: Only for string comparisons. Default = False + sortcolumns: When True, the columns are sorted from left to right. Default = False : rows are sorted from top to bottom. + + + + 'Sort range based on columns A (ascending) and C (descending) + oDoc.SortRange("A2:J200", Array(1, 3), Array("ASC", "DESC"), CaseSensitive := True) + + + + myDoc.SortRange("A2:J200", (1, 3), ("ASC", "DESC"), casesensitive = True) + +
+ + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_chart.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_chart.xhp new file mode 100644 index 000000000..ca1cc338f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_chart.xhp @@ -0,0 +1,504 @@ + + + + + + SFDocuments.Chart service + /text/sbasic/shared/03/sf_chart.xhp + + + +
+ + Chart service + +
+
+

SFDocuments.Chart service

+ The Chart service provides a set of properties and methods to handle charts in Calc documents. With this service it is possible to: + + + Access chart objects in Calc documents and manipulate their properties. + + + Create and insert new charts into a Calc document. + + + Export charts as image files. + + +
+ +

Chart names

+ Charts may have two different names: + + + An internal name given by %PRODUCTNAME as soon as the chart object is created (usually "Object 1", "Object 2" and so on). + + + A user-defined name, which can be defined by right-clicking the chart and choosing Name in the context menu. + + + The Chart service primarily uses the user-defined name to access a chart object. If it does not exist, than the internal name is used. + +

Service invocation

+ Before using the Chart service the ScriptForge library needs to be loaded or imported: + + + The Chart service is instantiated from a Calc service instance either using the Charts or CreateChart methods. + + The example below creates a Chart service instance from an existing chart in the current Calc document: + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim oDoc as Object, oChart as Object + Set oDoc = CreateScriptService("Calc") + Set oChart = oDoc.Charts("Sheet1", "Object 1") + + The following example instantiate the Chart service by creating a new chart object based on the data contained in the range "Sheet1.A1:C10". + + Dim oDoc as Object, oChart as Object + Set oDoc = CreateScriptService("Calc") + Set oChart = oDoc.CreateChart("My Chart", "Sheet1", "Sheet1.A1:C10") + + Read the CreateChart method description to learn more about its arguments. + + + The examples above can be written in Python as follows: + + from scriptforge import CreateScriptService + doc = CreateScriptService("Calc") + chart = doc.Charts("Sheet1", "Object 1") + + + doc = CreateScriptService("Calc") + chart = doc.CreateChart("My Chart", "Sheet1", "Sheet1.A1:C10") + + + + Chart service;ChartType + Chart service;Deep + Chart service;Dim3D + Chart service;Exploded + Chart service;Filled + Chart service;Legend + Chart service;Percent + Chart service;Stacked + Chart service;Title + Chart service;XTitle + Chart service;YTitle + Chart service;XChartObj + Chart service;XDiagram + Chart service;XShape + Chart service;XTableChart + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + ChartType + + + No + + + String + + + Specifies the chart type as a string that can assume one of the following values: "Pie", "Bar", "Donut", "Column", "Area", "Line", "XY", "Bubble", "Net". + + + + + Deep + + + No + + + Boolean + + + When True indicates that the chart is three-dimensional and each series is arranged in the z-direction. + When False series are arranged considering only two dimensions. + + + + + Dim3D + + + No + + + Boolean or String + + + Specifies if the chart is displayed with 3D elements. If the value is a string, it must be either "Bar", "Cylinder", "Cone" or "Pyramid". + If the boolean True value is specified, then the chart is displayed using 3D bars. + + + + + Exploded + + + No + + + Numeric + + + Specifies how much pie segments are offset from the chart center as a percentage of the radius. Applicable to pie and donut charts only. + + + + + Filled + + + No + + + Boolean + + + When True, specifies a filled net chart. Applicable to net charts only. + + + + + Legend + + + No + + + Boolean + + + Specifies whether or not the chart has a legend. + + + + + Percent + + + No + + + Boolean + + + When True, chart series are stacked and each category sums up to 100%. Applicable to Area, Bar, Bubble, Column and Net charts. + + + + + Stacked + + + No + + + Boolean + + + When True, chart series are stacked. Applicable to Area, Bar, Bubble, Column and Net charts. + + + + + Title + + + No + + + String + + + Specifies the main title of the chart. + + + + + XTitle + + + No + + + String + + + Specifies the title of the X axis. + + + + + YTitle + + + No + + + String + + + Specifies the title of the Y axis. + + + + + XChartObj + + + Yes + + + UNO Object + + + Returns the object representing the chart, which is an instance of the ScChartObj class. + + + + + XDiagram + + + Yes + + + UNO Object + + + Returns the com.sun.star.chart.XDiagram object representing the diagram of the chart. + + + + + XShape + + + Yes + + + UNO Object + + + Returns the com.sun.star.drawing.XShape object representing the shape of the chart. + + + + + XTableChart + + + Yes + + + UNO Object + + + Returns the com.sun.star.table.XTableChart object representing the data being displayed in the chart. + + +
+ +

Creating a chart

+ Consider the following data in the range "A1:B6" of a sheet named "Report". + + + + + + + A + + + B + + + + + 1 + + + Sample A + + + Sample B + + + + + 2 + + + 36 + + + 40 + + + + + 3 + + + 39 + + + 43 + + + + + 4 + + + 45 + + + 40 + + + + + 5 + + + 52 + + + 48 + + +
+ The examples below in Basic and Python show how to create a line chart from this data with legends. + + + oDoc = CreateScriptService("Calc") + oChart = oDoc.CreateChart("Samples", "Report", "Report.A1:B6") + oChart.ChartType = "Line" + oChart.Legend = True + oChart.Resize(1000, 1000, 25000, 15000) + + + + doc = CreateScriptService("Calc") + chart = doc.CreateChart("Samples", "Report", "Report.A1:B6") + chart.ChartType = "Line" + chart.Legend = True + chart.Resize(1000, 1000, 25000, 15000) + + The chart does not need to be created in the same sheet where the data is located. It can be created in any existing sheet in the current file by specifying the sheet name in the second argument of the CreateChart method. + +

Methods

+ + + List of Methods in the Chart Service + + + + + ExportToFile
+
+
+ + + Resize
+
+
+
+
+ +
+ ExportToFile ----------------------------------------------------------------------------------------- + + Chart service;ExportToFile + +

ExportToFile

+ Saves the chart as an image file in a specified location. Returns True if the image file could be successfully created. + + + chart.ExportToFile(filename: str, imagetype: str = "png", overwrite: bool = False): bool + + + filename: Identifies the path and file name where the image will be saved. It must follow the notation defined in SF_FileSystem.FileNaming. + imagetype: The name of the image type to be created. The following values are accepted: "gif", "jpeg", "png" (default), "svg" and "tiff". + overwrite: Specifies if the destination file can be overwritten (Default = False). + + + + oChart.ExportToFile("C:\Temp\myChart.svg", ImageType := "svg", Overwrite := True) + + + + chart.ExportToFile(r"C:\Temp\myChart.svg", imagetype="svg", overwrite=True) + +
+ +
+ Resize ----------------------------------------------------------------------------------------- + + Chart service;Resize + +

Resize

+ Changes the position of the chart in the current sheet and modifies its width and height. Returns True if resizing was successful. + + + chart.Resize([xpos: int], [ypos: int], [width: int], [height: int]): bool + + + xpos, ypos: Specify the new X and Y positions of the chart. If any of these values are omitted or if negative values are provided, the corresponding positions are left unchanged. + width: Specify the new width of the chart. If this argument is omitted or if a negative value is provided, the chart width is left unchanged. + height: Specify the new height of the chart. If this argument is omitted or if a negative value is provided, the chart height is left unchanged. + All arguments are provided as integer values that correspond to 1/100 of a millimeter. + + + + ' Changes only X and Y position + oChart.Rezise(1000, 3000) + ' Changes only the chart width and height + oChart.Resize(, , 25000, 12500) + ' Keyword arguments are supported + oChart.Resize(Width := 25000, Height := 12500) + + + + chart.Rezise(1000, 3000) + chart.Resize(-1, -1, 20000, 20000) + chart.Resize(width=25000, height=12500) + +
+ + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_database.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_database.xhp new file mode 100644 index 000000000..468f83b58 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_database.xhp @@ -0,0 +1,404 @@ + + + + + + + SFDatabases.Database service + /text/sbasic/shared/03/sf_database.xhp + + + +
+ + Database service + +
+ +
+

SFDatabases.Database service

+ The Database service provides access to databases either embedded or described in Base documents. This service provides methods to: + + + Get access to data in database tables. + + + Run SELECT queries and perform aggregate functions. + + + Run SQL action statements such as INSERT, UPDATE, DELETE, etc. + + +
+ Each instance of the Database service represents a single database and gives access to its tables, queries and data. + This service does not provide access to forms or reports in the Base document that contains the database. To access forms in a Base document, refer to the method FormDocuments of the Base service. + All exchanges between this service and the database are done using SQL only. + SQL statements may be run in direct or indirect mode. In direct mode the statement is transferred to the database engine without any syntax checking or review. + The provided interfaces include simple tables and queries lists, as well as access to database data. + To make SQL statements more readable, you may use square brackets "[ ]" to enclose names of tables, queries and fields instead of using other enclosing characters that may be exclusive to certain Relational Database Management Systems (RDBMS). But beware that enclosing characters are mandatory in this context. + +

Service invocation

+ Before using the Database service the ScriptForge library needs to be loaded or imported: + + + + To create a instance of the Database service you can use the CreateScriptService method: + + CreateScriptService("SFDatabases.Database", [filename: str], [registrationname], [readonly], [user, [password]]): svc + + In the syntax described above you can use either "SFDatabases.Database" or simply "Database" as the first argument of the CreateScriptService method. + + filename: The name of the Base file. Must be expressed using SF_FileSystem.FileNaming notation. + registrationname: The name of a registered database. If filename is provided, this argument should not be used. + Conversely, if a registrationname is specified, the filename parameter should not be defined. + readonly: Determines if the database will be opened as readonly (Default = True). + user, password: Additional connection parameters to the database server. + + + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim myDatabase as Object + Set myDatabase = CreateScriptService("Database", "/home/user/Documents/myDB.odb") + ' Run queries, SQL statements, ... + myDatabase.CloseDatabase() + + + + from scriptforge import CreateScriptService + myDatabase = CreateScriptService("Database", "/home/user/Documents/myDB.odb") + # Run queries, SQL statements, ... + myDatabase.CloseDatabase() + + +

Accessing Databases with the UI Service

+ It is also possible to access the database associated with a Base document using the ScriptForge.UI service, as shown in the examples below: + + + Dim myDoc As Object, myDatabase As Object, ui As Object + Set ui = CreateScriptService("UI") + Set myDoc = ui.OpenBaseDocument("/home/user/Documents/myDB.odb") + ' User and password are supplied below, if needed + Set myDatabase = myDoc.GetDatabase() + ' Run queries, SQL statements, ... + myDatabase.CloseDatabase() + myDoc.CloseDocument() + + + + ui = CreateScriptService("UI") + doc = ui.OpenBaseDocument("/home/user/Documents/myDB.odb") + # User and password are supplied below, if needed + myDatabase = doc.GetDatabase() + # Run queries, SQL statements, ... + myDatabase.CloseDatabase() + doc.CloseDocument() + + The GetDatabase method used in the example above is part of ScriptForge's Base service. + + + Database Service;Queries + Database Service;Tables + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + Queries + + + Yes + + + Array of strings + + + The list of stored queries. + + + + + Tables + + + Yes + + + Array of strings + + + The list of stored tables. + + + + + XConnection + + + Yes + + + XConnection + + + The UNO object representing the current database connection. + + + + + XMetaData + + + Yes + + + XDatabaseMetaData + + + The UNO object representing the metadata describing the database system attributes. + + +
+ + + + + List of Methods in the Database Service + + + + + + CloseDatabase
+ DAvg
+ DCount +
+
+ + + DMin
+ DMax
+ DSum +
+
+ + + DLookup
+ GetRows
+ RunSql +
+
+
+
+ +
+ CloseDatabase ---------------------------------------------------------------------------------- + + Database Service;CloseDatabase + +

CloseDatabase

+ Closes the current database connection. + + + db.CloseDatabase() + + + + myDatabase.CloseDatabase() ' Basic + + + myDatabase.CloseDatabase() # Python + +
+ +
+ DFunctions ----------------------------------------------------------------------------------- + + Database Service;DAvg + + + Database Service;DCount + + + Database Service;DMax + + + Database Service;DMin + + + Database Service;DSum + +

DAvg, DCount, DMin, DMax, DSum

+ Computes the given aggregate function on a field or expression belonging to a table. + Optionally, a SQL WHERE clause can be specified as a filter that will be applied prior to the aggregate function. + + + db.DAvg(expression: str, tablename: str, [criteria: str]): any + + + db.DCount(expression: str, tablename: str, [criteria: str]): any + + + db.DMin(expression: str, tablename: str, [criteria: str]): any + + + db.DMax(expression: str, tablename: str, [criteria: str]): any + + + db.DSum(expression: str, tablename: str, [criteria: str]): any + + + expression: A SQL expression in which the field names are surrounded with square brackets. + tablename: A table name (without square brackets). + criteria: A WHERE clause without the "WHERE" keyword, in which field names are surrounded with square brackets. + + The example below assumes the file Employees.odb has a table named EmployeeData. + + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim myDB as Variant + Set myDB = CreateScriptService("Database", "/home/user/Databases/Employees.odb") + ' Counts the number of employees in the table + MsgBox myDB.DCount("[ID]", "EmployeeData") + ' Returns the sum of all salaries in the table + MsgBox myDB.DSum("[Salary]", "EmployeeData") + ' Below are some examples of how tables can be filtered + MsgBox myDB.DCount("[ID]", "EmployeeData", "[Position] = 'Manager'") + MsgBox myDB.DCount("[ID]", "EmployeeData", "[Position] = 'Sales' AND [City] = 'Chicago'") + MsgBox myDB.DCount("[ID]", "EmployeeData", "[FirstName] LIKE 'Paul%'") + + + + myDB = CreateScriptService("Database", "/home/user/Databases/Employees.odb") + bas = CreateScriptService("Basic") + bas.MsgBox(myDB.DCount("[ID]", "EmployeeData")) + bas.MsgBox(myDB.DSum("[Salary]", "EmployeeData")) + bas.MsgBox(myDB.DCount("[ID]", "EmployeeData", "[Position] = 'Manager'")) + bas.MsgBox(myDB.DCount("[ID]", "EmployeeData", "[Position] = 'Sales' AND [City] = 'Chicago'")) + bas.MsgBox(myDB.DCount("[ID]", "EmployeeData", "[FirstName] LIKE 'Paul%'")) + +
+ +
+ DLookup -------------------------------------------------------------------------------------------- + + Database Service;DLookup + +

DLookup

+ Computes a SQL expression on a single record returned by a WHERE clause defined by the Criteria parameter. + If the query returns multiple records, only the first one is considered. Use the OrderClause parameter to determine how query results are sorted. + + + db.DLookup(expression: str, tablename: str, [criteria:str], [orderclause: str]): any + + + expression: A SQL expression in which the field names are surrounded with square brackets. + tablename: A table name (without square brackets). + criteria: A WHERE clause without the "WHERE" keyword, in which field names are surrounded with square brackets. + orderclause: An ORDER BY clause without the "ORDER BY" keywords. Field names should be surrounded with square brackets. + + + + MsgBox myDB.DLookup("[FirstName]", "EmployeeData", Criteria := "[LastName] LIKE 'Smith'", OrderClause := "[FirstName] DESC") + MsgBox myDB.DLookup("[Salary]", "EmployeeData", Criteria := "[ID] = '3'") + MsgBox myDB.DLookup("[Quantity] * [Value]", "Sales", Criteria := "[SaleID] = '5014'") + + + + bas = CreateScriptService("Basic") + bas.MsgBox(myDB.DLookup("[FirstName]", "EmployeeData", criteria = "[LastName] LIKE 'Smith'", orderclause = "[FirstName] DESC")) + bas.MsgBox(myDB.DLookup("[Salary]", "EmployeeData", criteria = "[ID] = '3'")) + bas.MsgBox(myDB.DLookup("[Quantity] * [Value]", "Sales", criteria = "[SaleID] = '5014'")) + +
+ +
+ GetRows ---------------------------------------------------------------------------------------- + + Database Service;GetRows + +

GetRows

+ Stores the contents of a table or the results of a SELECT query or of an SQL statement in a two-dimensional array. The first index in the array corresponds to the rows and the second index refers to the columns. + An upper limit can be specified to the number of returned rows. Optionally column names may be inserted in the first row of the array. + The returned array will be empty if no rows are returned and the column headers are not required. + + + db.GetRows(sqlcommand: str, directsql: bool = False, header: bool = False, maxrows: int = 0): any + + + sqlcommand: A table or query name (without square brackets) or a SELECT SQL statement. + directsql: When True, the SQL command is sent to the database engine without pre-analysis. Default is False. This argument is ignored for tables. For queries, the applied option is the one set when the query was defined. + header: When True, the first row of the returned array contains the column headers. + maxrows: The maximum number of rows to return. The default is zero, meaning there is no limit to the number of returned rows. + + Below are a few examples of how the GetRows method can be used: + + + Dim queryResults as Variant + ' Returns all rows in the table with column headers + queryResults = myDB.GetRows("EmployeeData", Header := True) + ' Returns the first 50 employee records ordered by the 'FirstName' field + queryResults = myDB.GetRows("SELECT * FROM EmployeeData ORDER BY [FirstName]", MaxRows := 50) + + + + queryResults = myDB.GetRows("EmployeeData", header = True) + queryResults = myDB.GetRows("SELECT * FROM EmployeeData ORDER BY [FirstName]", maxrows = 50) + +
+ +
+ RunSql -------------------------------------------------------------------------------------------- + + Database Service;RunSql + +

RunSql

+ Executes an action query of an SQL statement such as creating a table, as well as inserting, updating and deleting records. + The method returns True when successful. + The RunSql method is rejected with an error message in case the database was previously opened in read-only mode. + + + db.RunSql(sqlcommand: str, directsql: bool = False): bool + + + sqlcommand: A query name (without square brackets) or a SQL statement. + directsql: When True, the SQL command is sent to the database engine without pre-analysis. (Default = False). For queries, the applied option is the one set when the query was defined. + + + + myDatabase.RunSql("INSERT INTO [EmployeeData] VALUES(25, 'Smith', 'John')", DirectSQL := True) + + + + myDatabase.RunSql("INSERT INTO [EmployeeData] VALUES(25, 'Smith', 'John')", directsql = True) + +
+ + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_dialog.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_dialog.xhp new file mode 100644 index 000000000..8f9f755c1 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_dialog.xhp @@ -0,0 +1,681 @@ + + + + + + SFDialogs.Dialog service + /text/sbasic/shared/03/sf_dialog.xhp + + + +
+ + Dialog service + +
+
+

SFDialogs.Dialog service

+ The Dialog service contributes to the management of dialogs created with the Basic Dialog Editor. Each instance of the current class represents a single dialog box displayed to the user. +
+ A dialog box can be displayed in modal or in non-modal modes. + In modal mode, the box is displayed and the execution of the macro process is suspended until one of the OK or Cancel buttons is pressed. In the meantime, user actions executed on the box can trigger specific actions. + In non-modal mode, the dialog box is "floating" on the user desktop and the execution of the macro process continues normally. A non-modal dialog closes when it is terminated with the Terminate() method or when the %PRODUCTNAME session ends. The window close button is inactive in non-modal dialogs. + A dialog box disappears from memory after its explicit termination. + The SFDialogs.Dialog service is closely related to the SFDialogs.DialogControl service. + +

Service invocation and usage

+ Before using the Dialog service the ScriptForge library needs to be loaded or imported: + + + The Dialog service is invoked through the CreateScriptService method. It requires three positional arguments to specify the dialog box to activate: + Container: "GlobalScope" for preinstalled libraries or a window name as defined by ScriptForge.UI service. Empty string "" default value stands for the current document. + Library: The case-sensitive name of a library contained in the container. Default value is "Standard". + DialogName: A case-sensitive string designating the dialog. + Below %PRODUCTNAME Basic and Python examples are displaying the dlgConsole dialog that belongs to ScriptForge shared library: + + Dim oDlg As Object, lButton As Long + Dim Container As String, Library As String, DialogName As String + Set oDlg = CreateScriptService("SFDialogs.Dialog", "GlobalScope", "ScriptForge", "dlgConsole") + '... controls initialization goes here... + lButton = oDlg.Execute() + 'Default mode = Modal + If lButton = oDlg.OKBUTTON Then + '... Process controls and do what is needed here + End If + oDlg.Terminate() + + Or using Python: + + dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', 'ScriptForge', 'dlgConsole') + # ... controls initialization goes here... + rc = dlg.Execute() + # Default mode is Modal + if rc == dlg.OKBUTTON: + # ... Process controls and do what is needed here + dlg.Terminate() + + + Alternatively a Dialog instance can be retrieved via the SFDialogs.DialogEvent service, providing that the dialog was initiated with the Dialog service. DialogEvent returns the SFDialogs.Dialog service instance that triggered the event. + + Sub SomeEvent(ByRef poEvent As Object) + Dim oDlg As Object + Set oDlg = CreateScriptService("SFDialogs.DialogEvent", poEvent) + End Sub + + with Python: + + def some_event(event: uno): + dlg = CreateScriptService("SFDialogs.DialogEvent", event) + + Note that in previous examples, the prefix "SFDialogs." may be omitted when deemed appropriate. + +

Properties

+ + + + Name + + + ReadOnly + + + Type + + + Description + + + + + OKBUTTON + + + Yes + + + Integer + + + Value = 1. An OK button was pressed. + + + + + CANCELBUTTON + + + Yes + + + Integer + + + Value = 0. A Cancel button was pressed. + + + + + Caption + + + No + + + String + + + Specify the title of the dialog. + + + + + Height + + + No + + + Long + + + Specify the height of the dialog box. + + + + + Modal + + + Yes + + + Boolean + + + Specifies if the dialog box is currently in execution in modal mode. + + + + + Name + + + Yes + + + String + + + The name of the dialog + + + + + Page + + + No + + + Integer + + + A dialog may have several pages that can be traversed by the user step by step. The Page property of the Dialog object defines which page of the dialog is active. + + + + + Visible + + + No + + + Boolean + + + Specify if the dialog box is visible on the desktop. By default it is not visible until the Execute() method is run and visible afterwards. + + + + + XDialogModel + + + Yes + + + + API;UnoControlDialogModel + + UNO
object
+
+ + The UNO object representing the dialog model. Refer to XControlModel and UnoControlDialogModel in Application Programming Interface (API) documentation for detailed information. + +
+ + + XDialogView + + + Yes + + + + API;UnoControlDialog + + UNO
object
+
+ + The UNO object representing the dialog view. Refer to XControl and UnoControlDialog in Application Programming Interface (API) documentation for detailed information. + +
+ + + Width + + + No + + + Long + + + Specify the width of the dialog box. + + +
+

Event properties

+ Returns a URI string with the reference to the script triggered by the event. Read its specification in the scripting framework URI specification. + + + + Name + + + ReadOnly + + + Basic IDE Description + + + + + OnFocusGained + + + Yes + + + When receiving focus + + + + + OnFocusLost + + + Yes + + + When losing focus + + + + + OnKeyPressed + + + Yes + + + Key pressed + + + + + OnKeyReleased + + + Yes + + + Key released + + + + + OnMouseDragged + + + Yes + + + Mouse moved while key presses + + + + + OnMouseEntered + + + Yes + + + Mouse inside + + + + + OnMouseExited + + + Yes + + + Mouse outside + + + + + OnMouseMoved + + + Yes + + + Mouse moved + + + + + OnMousePressed + + + Yes + + + Mouse button pressed + + + + + OnMouseReleased + + + Yes + + + Mouse button released + + +
+ + + + Methods + + + + + Activate
+ Center
+ Controls
+
+ + EndExecute
+ Execute
+ GetTextsFromL10N
+
+ + Resize
+ Terminate

+
+
+
+ +
+ Activate -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;Activate + +

Activate

+ Set the focus on the current Dialog instance. Return True if focusing was successful. + This method is called from a dialog or control event, or when a dialog is displayed in non-modal mode. + + svc.Activate(): bool + + + Dim oDlg As Object + Set oDlg = CreateScriptService(,, "myDialog") + oDlg.Execute() + ' ... + oDlg.Activate() + + Python and %PRODUCTNAME Basic examples both assume that the dialog is stored in current document's Standard library. + + dlg = CreateScriptService(,,'myDialog') + dlg.Execute() + # ... + dlg.Activate() + +
+ +
+ Center -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;Center + +

Center

+ Centers the current dialog instance in the middle of a parent window. Without arguments, the method centers the dialog in the middle of the current window. + Returns True when successful. + + svc.Center(opt Parent: obj): bool + + Parent: An optional object that can be either … + + + a ScriptForge dialog object + + + a ScriptForge document (Calc, Base, ...) object + + + + + + Sub TriggerEvent(oEvent As Object) + Dim oDialog1 As Object, oDialog2 As Object, lExec As Long + Set oDialog1 = CreateScriptService("DialogEvent", oEvent) ' The dialog that caused the event + Set oDialog2 = CreateScriptService("Dialog", ...) ' Open a second dialog + oDialog2.Center(oDialog1) + lExec = oDialog2.Execute() + Select Case lExec + ... + End Sub + + + + def triggerEvent(event: uno): + dlg1 = CreateScriptService('DialogEvent.Dialog', event) # The dialog having caused the event + dlg2 = CreateScriptService('Dialog', ...) # Open a second dialog + dlg2.Center(dlg1) + rc = dlg2.Execute() + if rc is False: + # ... + +
+ +
+ Controls -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;Controls + +

Controls

+ Return either: + + + the list of the controls contained in the dialog + + + a DialogControl class instance based on its name + + + + svc.Controls(): str[0..*] + svc.Controls(controlname: str): svc + + ControlName : A valid control name as a case-sensitive string. If absent, the list of control names is returned as a zero-based array. + + + Dim myDialog As Object, myList As Variant, myControl As Object + Set myDialog = CreateScriptService("SFDialogs.Dialog", , "Standard", "Dialog1") + myList = myDialog.Controls() + Set myControl = myDialog.Controls("myTextBox") + + + dlg = CreateScriptService('SFDialogs.Dialog','', 'Standard', 'Dialog1') + ctrls = dlg.Controls() + ctrl = dlg.Controls('myTextBox') + +
+ +
+ EndExecute -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;EndExecute + +

EndExecute

+ Ends the display of a modal dialog and gives back the argument as return value for the current Execute() running action. + EndExecute() is usually contained in the processing of a macro triggered by a dialog or control event. + + svc.EndExecute(returnvalue: int) + + returnvalue: The value passed to the running Execute() method. + + Using %PRODUCTNAME Basic: + + Sub OnEvent(poEvent As com.sun.star.lang.EventObject) + Dim oDlg As Object + Set oDlg = CreateScriptService("SFDialogs.DialogEvent", poEvent) + oDlg.EndExecute(ReturnValue := 25) + End Sub + + Using Python: + + from com.sun.star.lang import EventObject + def on_event(event: EventObject): + dlg = CreateScriptService("SFDialogs.DialogEvent", event) + dlg.EndExecute(25) + + Above com.sun.star.lang.EventObject mentions are optional. Such annotations help identify %PRODUCTNAME Application Programming Interface (API). +
+ +
+ Execute -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;Execute +

Execute

+ Display the dialog box and, when modal, wait for its termination by the user. The returned value is either: + + + 0 : Cancel button pressed + + + 1 : OK button pressed + + + Otherwise the dialog stopped with an EndExecute() statement issued by a dialog or control event + + + For non-modal dialog boxes the method always returns 0 and the execution of the macro continues. + + svc.Execute(modal: bool = True): int + + modal: False when non-modal dialog. Default = True. + + In this Basic example myDialog dialog is stored in current document's Standard library. + + Dim oDlg As Object, lReturn As Long + Set oDlg = CreateScriptService("SFDialogs.Dialog", , , "myDialog") + lReturn = oDlg.Execute(Modal := False) + Select Case lReturn + ' ... + End Select + + This Python code displays DlgConvert modal dialog from Euro shared Basic library. + + dlg = CreateScriptService("SFDialogs.Dialog", 'GlobalScope', 'Euro', "DlgConvert") + rc = dlg.Execute() + if rc == dlg.CANCELBUTTON: + # ... + +
+ +
+ GetTextsFromL10N -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;GetTextsFromL10N + +

GetTextsFromL10N

+ Replaces all fixed text strings in a dialog by their translated versions based on a L10N service instance. This method translates the following strings: + + The method returns True if successful. + To create a list of translatable strings in a dialog use the AddTextsFromDialog method from the L10N service. + + + svc.GetTextsFromL10N(l10n: svc): bool + + + l10n: A L10N service instance from which translated strings will be retrieved. + + The following example loads translated strings and applies them to the dialog "MyDialog". + + + oDlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "MyDialog") + myPO = CreateScriptService("L10N", "/home/user/po_files/") + oDlg.GetTextsFromL10N(myPO) + oDlg.Execute() + + + + dlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "MyDialog") + myPO = CreateScriptService("L10N", "/home/user/po_files/") + dlg.GetTextsFromL10N(myPO) + dlg.Execute() + + Read the L10N service help page to learn more about how PO and POT files are handled. +
+ +
+ Resize -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;Resize + +

Resize

+ Moves the topleft corner of a dialog to new coordinates and/or modify its dimensions. All distances are expressed in 1/100 mm. Without arguments, the method resets the initial dimensions. Return True if the resize was successful. + + svc.Resize(opt Left: num, opt Top: num, opt Width: num, opt Height: num): bool + + Left: the horizontal distance from the top-left corner + Top: the vertical distance from the top-left corner + Width: the width of the rectangle containing the dialog + Height: the height of the rectangle containing the dialog + Negative or missing arguments are left unchanged + + + + oDialog.Resize(1000, 2000, Height := 6000) ' Width is not changed + + + With Python: + + oDialog.Resize(1000, 2000, Height = 6000) # Width is not changed + +
+ +
+ Terminate -------------------------------------------------------------------------------------------------------------------------- + + Dialog service;Terminate + +

Terminate

+ Terminate the Dialog service for the current instance. Return True if the termination was successful. + + svc.Terminate(): bool + + Below Basic and Python examples open DlgConsole and dlgTrace non-modal dialogs. They are respectively stored in ScriptForge and Access2Base shared libraries. Dialog close buttons are disabled and explicit termination is performed at the end of a running process. + In this example a button in DlgConsole is substituting inhibited window closing: + + + oDlg = CreateScriptService("SFDialogs.Dialog","GlobalScope","ScriptForge","DlgConsole") + oDlg.Execute(modal:=False) + Wait 5000 + oDlg.Terminate() + + With Python: + + + from time import sleep + dlg = CreateScriptService('SFDialogs.Dialog',"GlobalScope",'Access2Base',"dlgTrace") + dlg.Execute(modal=False) + sleep 5 + dlg.Terminate() + +
+ + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_dialogcontrol.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_dialogcontrol.xhp new file mode 100644 index 000000000..59bb03085 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_dialogcontrol.xhp @@ -0,0 +1,1273 @@ + + + + + + SFDialogs.DialogControl service + /text/sbasic/shared/03/sf_dialogcontrol.xhp + + + +
+ + DialogControl service + +

SFDialogs.DialogControl service

+ The DialogControl service manages the controls belonging to a dialog defined with the Basic Dialog Editor. Each instance of the current service represents a single control within a dialog box. + + API;awt.XControl + API;awt.XControlModel + + The focus is set on getting and setting the values displayed by the controls of the dialog box. Formatting is accessible via the XControlModel and XControlView properties. + Note that the unique DialogControl.Value property content varies according to the control type. + A special attention is given to controls of type tree control. It is easy to populate a tree, either branch by branch, or with a set of branches at once. Populating a tree control can be performed statically or dynamically. +
+ The SFDialogs.DialogControl service is closely related to the SFDialogs.Dialog service. +

Service invocation

+ Before using the DialogControl service the ScriptForge library needs to be loaded or imported: + + + The DialogControl service is invoked from an existing Dialog service instance through its Controls() method. The dialog must be initiated with the SFDialogs.Dialog service. + + Dim myDialog As Object, myControl As Object + Set myDialog = CreateScriptService("SFDialogs.Dialog", "GlobalScope", myLibrary, DialogName) + Set myControl = myDialog.Controls("myTextBox") + myControl.Value = "Dialog started at " & Now() + myDialog.Execute() + ' ... process the controls actual values + myDialog.Terminate() + + + from time import localtime, strftime + dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', lib_name, dlg_name) + text = dlg.Controls('myTextBox') + text.Value = "Dialog started at " + strftime("%a, %d %b %Y %H:%M:%S", localtime()) + dlg.Execute() + # ... process the controls actual values + dlg.Terminate() + + Alternatively a control instance can be retrieved via the SFDialogs.DialogEvent service, providing the dialog was initiated with the Dialog service. DialogEvent returns the SFDialogs.DialogControl class instance that triggered the event. + + Sub SomeEvent(ByRef poEvent As Object) + Dim oControl As Object + Set oControl = CreateScriptService("SFDialogs.DialogEvent", poEvent) + ' ... + End Sub + + + def some_event(event: uno): + ctrl = CreateScriptService('SFDialogs.DialogEvent', event) + # ... + + Note that in previous examples, the prefix "SFDialogs." may be omitted. +

Control types

+ The DialogControl service is available for these control types: + + + Button + + + CheckBox + + + ComboBox + + + CurrencyField + + + DateField + + + FileControl + + + FixedLine + + + FixedText + + + FormattedField + + + GroupBox + + + ImageControl + + + ListBox + + + NumericField + + + PatternField + + + ProgressBar + + + RadioButton + + + ScrollBar + + + TableControl + + + TextField + + + TimeField + + + TreeControl + + +

Properties

+ + + + Name + + + ReadOnly + + + Type + + + Applicable to + + + Description + + + + + Cancel + + + No + + + Boolean + + + Button + + + Specifies if a command button has or not the behaviour of a Cancel button. + + + + + Caption + + + No + + + String + + + Button, CheckBox, FixedLine, FixedText, GroupBox, RadioButton + + + Specifies the text associated with the control. + + + + + ControlType + + + Yes + + + String + + + All + + + One of the types listed above. + + + + + CurrentNode + + + No + + + UNO
object
+
+ + TreeControl + + + The currently upmost node selected in the tree control. Refer to XmutableTreeNode in Application Programming Interface (API) documentation for detailed information. + +
+ + + Default + + + No + + + Boolean + + + Button + + + Specifies whether a command button is the default (OK) button. + + + + + Enabled + + + No + + + Boolean + + + All + + + Specifies if the control is accessible with the cursor. + + + + + Format + + + No + + + String + + + DateField, TimeField, FormattedField + (read-only) + + + Specifies the format used to display dates and times. It must be one these strings: + For dates: "Standard (short)", "Standard (short YY)", "Standard (short YYYY)", "Standard (long)", "DD/MM/YY", "MM/DD/YY", "YY/MM/DD", "DD/MM/YYYY", "MM/DD/YYYY" , "YYYY/MM/DD", "YY-MM-DD", "YYYY-MM-DD". + For times: "24h short", "24h long", "12h short", "12h long". + + + + + ListCount + + + Yes + + + Long + + + ComboBox, ListBox, TableControl + + + Specifies the number of rows in a ListBox, a ComboBox or a TableControl. + + + + + ListIndex + + + No + + + Long + + + ComboBox, ListBox, TableControl + + + Specifies which item is selected in a ListBox, a ComboBox or a TableControl. + + + + + Locked + + + No + + + Boolean + + + ComboBox, CurrencyField, DateField, FileControl, FormattedField, ListBox, NumericField, PatternField, TextField, TimeField + + + Specifies if the control is read-only. + + + + + MultiSelect + + + No + + + Boolean + + + ListBox + + + Specifies whether a user can make multiple selections in a listbox. + + + + + Name + + + Yes + + + String + + + All + + + The name of the control. + + + + + Page + + + No + + + Integer + + + All + + + A dialog may have several pages that can be traversed by the user step by step. The Page property of the Dialog object defines which page of the dialog is active. + The Page property of a control defines the page of the dialog on which the control is visible. + + + + + Parent + + + Yes + + + Dialog
service
+
+ + All + + + The parent SFDialogs.Dialog class object instance. + +
+ + + Picture + + + No + + + String + + + Button, ImageControl + + + Specifies the file name containing a bitmap or other type of graphic to be displayed on the specified control. The filename must comply with the FileNaming attribute of the ScriptForge.FileSystem service. + + + + + RootNode + + + Yes + + + UNO
object
+
+ + TreeControl + + + An object representing the lowest root node (usually there is only one such root node). Refer to XmutableTreeNode in Application Programming Interface (API) documentation for detailed information. + +
+ + + RowSource + + + No + + + Array of strings + + + ComboBox, ListBox + + + Specifies the data contained in a combobox or a listbox. + + + + + Text + + + Yes + + + String + + + ComboBox, FileControl, FormattedField, PatternField, TextField + + + Gives access to the text being displayed by the control. + + + + + TipText + + + No + + + String + + + All + + + Specifies the text that appears as a tooltip when you hold the mouse pointer over the control. + + + + + TripleState + + + No + + + Boolean + + + CheckBox + + + Specifies if the checkbox control may appear dimmed (grayed) or not. + + + + + Value + + + No + + + Variant + + + + Refer to Value property + + + + + Visible + + + No + + + Boolean + + + All + + + Specifies if the control is hidden or visible. + + + + + XControlModel + + + Yes + + + UNO
object
+
+ + All + + + The UNO object representing the control model. Refer to XControlModel and UnoControlDialogModel in Application Programming Interface (API) documentation for detailed information. + +
+ + + XControlView + + + Yes + + + UNO
object
+
+ + All + + + The UNO object representing the control view. Refer to XControl and UnoControlDialog in Application Programming Interface (API) documentation for detailed information. + +
+ + + XTreeDataModel + + + Yes + + + UNO
object
+
+ + TreeControl + + + The UNO object representing the tree control data model. Refer to XMutableTreeDataModel in Application Programming Interface (API) documentation for detailed information. + +
+
+ +

The Value property

+ + + + Control type + + + Type + + + Description + + + + + Button + + + Boolean + + + For toggle buttons only + + + + + CheckBox + + + Boolean or Integer + + + 0, False: not checked
1, True: checked
2: grayed, don't know
+
+
+ + + ComboBox + + + String + + + The selected value. The ListIndex property is an alternate option. + + + + + CurrencyField + + + Numeric + + + + + + + DateField + + + Date + + + + + + + FileControl + + + String + + + A file name formatted in accordance with the FileNaming property of the ScriptForge.FileSystem service + + + + + FormattedField + + + String or Numeric + + + + + + + ListBox + + + String or array of strings + + + The selected row(s) as a scalar or as an array depending on the MultiSelect attribute + + + + + NumericField + + + Numeric + + + + + + + PatternField + + + String + + + + + + + ProgressBar + + + Numeric + + + Must be within the predefined bounds + + + + + RadioButton + + + Boolean + + + Each button has its own name. They are linked together if their TAB positions are contiguous. If a radiobutton is set to True, the other related buttons are automatically set to False + + + + + ScrollBar + + + Numeric + + + Must be within the predefined bounds + + + + + TableControl + + + Array + + + One-dimensional array with the data of the currently selected row. + + + + + TextField + + + String + + + The text appearing in the field + + + + + TimeField + + + Date + + + + +
+

Event properties

+ Returns a URI string with the reference to the script triggered by the event. Read its specification in the scripting framework URI specification. + + + + Name + + + ReadOnly + + + Description as labeled in the Basic IDE + + + + + OnActionPerformed + + + Yes + + + Execute action + + + + + OnAdjustmentValueChanged + + + Yes + + + While adjusting + + + + + OnFocusGained + + + Yes + + + When receiving focus + + + + + OnFocusLost + + + Yes + + + When losing focus + + + + + OnItemStateChanged + + + Yes + + + Item status changed + + + + + OnKeyPressed + + + Yes + + + Key pressed + + + + + OnKeyReleased + + + Yes + + + Key released + + + + + OnMouseDragged + + + Yes + + + Mouse moved while key presses + + + + + OnMouseEntered + + + Yes + + + Mouse inside + + + + + OnMouseExited + + + Yes + + + Mouse outside + + + + + OnMouseMoved + + + Yes + + + Mouse moved + + + + + OnMousePressed + + + Yes + + + Mouse button pressed + + + + + OnMouseReleased + + + Yes + + + Mouse button released + + + + + OnNodeExpanded + + + No + + + (Not in Basic IDE) when the expansion button is pressed on a node in a tree control + + + + + OnNodeSelected + + + No + + + (Not in Basic IDE) when a node in a tree control is selected + + + + + OnTextChanged + + + Yes + + + Text modified + + +
+ +

Methods

+ + + + List of Methods in the DialogControl Service + + + + AddSubNode
+ AddSubTree
+ CreateRoot
+
+ + FindNode
+ SetFocus

+
+ + SetTableData
+ WriteLine

+
+
+
+ +
+ AddSubNode -------------------------------------------------------------------------------------------- + + DialogControl service;AddSubNode + +

AddSubNode

+ Create and return a new node of the tree control as a UNO object subordinate to a parent node. Refer to XMutableTreeNode in Application Programming Interface (API) documentation for detailed information. +
+ This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event - using the OnNodeExpanded event - to complete the tree dynamically. +
+ + + svc.AddSubNode(parentnode: uno, displayvalue: str, opt datavalue: any): uno + + + parentnode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode. + displayvalue: The text appearing in the tree control box. +
+ datavalue: Any value associated with the new node. datavalue may be a string, a number or a date. Omit the argument when not applicable. +
+ + %PRODUCTNAME Basic and Python examples pick up current document's myDialog dialog from Standard library. + + + Dim oDlg As Object, myTree As Object, myNode As Object, theRoot As Object + Set oDlg = CreateScriptService("Dialog",,, "myDialog") + Set myTree = oDlg.Controls("myTreeControl") + Set theRoot = myTree.CreateRoot("Tree top") + Set myNode = myTree.AddSubNode(theRoot, "A branch ...") + + + + dlg = CreateScriptService('SFDialogs.Dialog', None, None, 'myDialog') + tree = dlg.Controls('myTreeControl') + root = tree.CreateRoot('Tree top') + node = tree.AddSubNode(root, 'A branch ...') + +
+ +
+ AddSubTree -------------------------------------------------------------------------------------------- + + DialogControl service;AddSubTree + +

AddSubTree

+ Return True when a subtree, subordinate to a parent node, could be inserted successfully in a tree control. If the parent node had already child nodes before calling this method, the child nodes are erased. + + + + svc.AddSubTree(parentnode: uno, flattree: any, opt withdatavalue: bool): bool + + + parentnode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode. + flattree: a two dimension array sorted on the columns containing the display values. Such an array can be issued by the GetRows method applied on the SFDatabases.Database service. When an array item containing the text to be displayed is Empty or Null, no new subnode is created and the remainder of the row is skipped. + + Flat tree >>>> Resulting subtree + A1 B1 C1 |__ A1 + A1 B1 C2 |__ B1 + A1 B2 C3 |__ C1 + A2 B3 C4 |__ C2 + A2 B3 C5 |__ B2 + A3 B4 C6 |__ C3 + |__ A2 + |__ B3 + |__ C4 + |__ C5 + |__ A3 + |__ B4 + |__ C6 + + withdatavalue: When False default value is used, every column of flattree contains the text to be displayed in the tree control. When True, the texts to be displayed (displayvalue) are in columns 0, 2, 4, ... while the data values (datavalue) are in columns 1, 3, 5, ... + + + + Dim myTree As Object, theRoot As Object, oDb As Object, vData As Variant + Set myTree = myDialog.Controls("myTreeControl") + Set theRoot = myTree.CreateRoot("By product category") + Set oDb = CreateScriptService("SFDatabases.Database", "/home/.../mydatabase.odb") + vData = oDb.GetRows("SELECT [Category].[Name], [Category].[ID], [Product].[Name], [Product].[ID] " _ + & "FROM [Category], [Product] WHERE [Product].[CategoryID] = [Category].[ID] " _ + & "ORDER BY [Category].[Name], [Product].[Name]") + myTree.AddSubTree(theRoot, vData, WithDataValue := True) + + + + SQL_STMT = "SELECT [Category].[Name], [Category].[ID], [Product].[Name], [Product].[ID] \ + FROM [Category], [Product] WHERE [Product].[CategoryID] = [Category].[ID] \ + ORDER BY [Category].[Name], [Product].[Name]" + tree = dlg.Controls('myTreeControl') + root = tree.CreateRoot('By Product category') + db = CreateScriptService('SFDatabases.Database', '/home/.../mydatabase.odb') + sub_tree = db.GetRows(SQL_STMT) + tree.AddSubTree(root, sub_tree, withdatavalue=True) + +
+ +
+ CreateRoot ------------------------------------------------------------------------------------------- + + DialogControl service;CreateRoot + +

CreateRoot

+ Returns a new root node of the tree control, as a node UNO object of type com.sun.star.awt.tree.XMutableTreeNode. The new tree root is inserted below pre-existing root nodes. + This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event to complete the tree dynamically. + + + svc.CreateRoot(displayvalue: str, opt datavalue: any): uno + + + displayvalue: The text appearing in the tree control box. + + + + + Dim myTree As Object, myNode As Object + Set myTree = myDialog.Controls("myTreeControl") + Set myNode = myTree.CreateRoot("Tree starts here ...") + + + + tree = dlg.Controls('myTreeControl') + node = tree.CreateRoot('Tree starts here ...') + +
+ +
+ FindNode ---------------------------------------------------------------------------------------------- + + DialogControl service;FindNode + +

FindNode

+ Traverses the tree and finds recursively, starting from the root, a node meeting some criteria. Either - 1 match is enough - having its display value matching displayvalue pattern or having its data value equal to datavalue. The comparisons may be or not case-sensitive. The first matching occurrence is returned as a node UNO object of type com.sun.star.awt.tree.XMutableTreeNode. + When not found, the method returns Nothing, to be tested with the IsNull() builtin function. + This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event. + + + svc.FindNode(displayvalue: str = '', opt datavalue: any, casesensitive = False): uno + + + One argument out of displayvalue or datavalue must be specified. If both present, one match is sufficient to select the node. + displayvalue: The pattern to be matched. Refer to SF_String.IsLike() method for the list of possible wildcards. When equal to the zero-length string (default), this display value is not searched for. + + casesensitive: Default value is False + + + + Dim myTree As Object, myNode As Object + Set myTree = myDialog.Controls("myTreeControl") + Set myNode = myTree.FindNode("*Sophie*", CaseSensitive := True) + + + + tree = dlg.Controls('myTreeControl') + node = FindNode('*Sophie*', casesensitive=True) + if node is None: + # ... + +
+ +
+ SetFocus ---------------------------------------------------------------------------------------------- + + DialogControl service;SetFocus + +

SetFocus

+ Set the focus on the control. Return True if focusing was successful. + This method is often called from a dialog or control event. + + + svc.SetFocus(): bool + + + + + Dim oControl As Object + Set oDlg = CreateScriptService("SFDialogs.Dialog",,, "myDialog") + Set oControl = oDlg.Controls("thisControl") + oControl.SetFocus() + + + + dlg = CreateScriptService('Dialog', None, None, 'myDialog') + ctrl = dlg.Controls('thisControl') + ctrl.SetFocus() + +
+ +
+ SetTableData ------------------------------------------------------------------------------------------ + + DialogControl service;SetTableData + +

SetTableData

+ Fills a TableControl with the given data. All preexisting data is cleared before inserting the new data passed as argument. + When the TableControl is added to the dialog, it is possible to use the Basic IDE to define whether column and row headers will be shown in the table. If the TableControl has column and/or row headers, the first column and/or row in the provided data array are used as labels for the table headers. + This method returns True when successful. + + + svc.SetTableData(dataarray: any[0..*, 0..*], widths: int[0..*], alignments: str): bool + + + dataarray: Data to be entered into the table represented as an Array of Arrays in Basic or a tuple of tuples in Python. The data must include column and row headers if they are to be displayed by the TableControl. + widths: Array containing the relative widths of each column. In other words, widths = Array(1, 2) means that the second column is twice as wide as the first one. If the number of values in the array is smaller than the number of columns in the table, then the last value in the array is used to define the width of the remaining columns. + alignments: Defines the alignment in each column as a string in which each character can be "L" (Left), "C" (Center), "R" (Right) or " " (whitespace, default, meaning left for strings and right for numeric values). If the length of the string is shorter than the number of columns in the table, then the last character in the string is used to define the alignment of the remaining columns. + + + The following example assumes that the dialog myDialog has a TableControl named Grid1 with "Show row header" and "Show column header" properties set to "Yes". + + Dim myDialog As Object, oTable As Object, tableData As Variant + myDialog = CreateScriptService("Dialog", "GlobalScope", "Standard", "myDialog") + oTable = myDialog.Controls("Grid1") + tableData = Array("Column A", "Column B", "Column C") + tableData = SF_Array.AppendRow(tableData, Array("Row 1", 1, 2)) + tableData = SF_Array.AppendRow(tableData, Array("Row 2", 3, 4)) + tableData = SF_Array.AppendRow(tableData, Array("Row 3", 5, 6)) + vAlignments = "LCC" + vWidths = Array(2, 1, 1) + oTable.SetTableData(tableData, vWidths, vAlignments) + myDialog.Execute() + + The Value property returns the selected row in the table. If no row is selected, an empty Array object is returned. The following code snippet shows how to test if any row is selected in the table. + + rowValues = oTable.Value + If UBound(rowValues) < 0 Then + MsgBox "No row selected." + Else + MsgBox "Row " & oTable.ListIndex & " is selected." + End If + + + + dlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "myDialog") + table_control = dlg.Controls("Grid1") + table_data = (("Column A", "Column B", "Column C"), + ("Row 1", 1, 2), + ("Row 2", 3, 4), + ("Row 3", 5, 6)) + alignments = "LCC" + widths = (100, 50, 50) + table_control.SetTableData(table_data, widths, alignments) + dlg.Execute() + + + bas = CreateScriptService("Basic") + row_values = table_control.Value + if len(row_values) == 0: + bas.MsgBox("No row selected.") + else: + bas.MsgBox(f"Row {table_control.ListIndex} is selected.") + +
+ +
+ WriteLine -------------------------------------------------------------------------------------------- + + DialogControl service;WriteLine + +

WriteLine

+ Add a new line at the end of a multiline text field. A newline character will be inserted when appropriate. The method returns True when successful. + An error is raised if the actual control is not of the type TextField or is not multiline. + + + svc.WriteLine(opt line: str): bool + + + Line: The string to insert. Default is an empty line. + + + + Dim oDlg As Object, oControl As Object + Set oDlg = CreateScriptService("SFDialogs.Dialog",,, "myDialog") + Set oControl = oDlg.Controls("thisControl") + oControl.WriteLine("a new line") + + + + dlg = CreateScriptService('SFDialogs.Dialog', None, None, 'myDialog') + ctrl = dlg.Controls('thisControl') + ctr.WriteLine("a new line") + +
+ + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_dictionary.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_dictionary.xhp new file mode 100644 index 000000000..7d94a6c9f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_dictionary.xhp @@ -0,0 +1,523 @@ + + + + + + + ScriptForge.Dictionary service + /text/sbasic/shared/03/sf_dictionary.xhp + + + +
+ + Dictionary service + + +

ScriptForge.Dictionary service

+ + A dictionary is a collection of key-item pairs + + The key is a case-insensitive string + Items may be of any type + +
+ + Keys and items can be retrieved, counted, updated, and much more. + The Dictionary service is similar to the built-in %PRODUCTNAME Basic Collection object, however with more features. For example, Collection objects do not support the retrieval of keys. Moreover, Dictionaries provide additional capabilities as replacing keys, testing if a specific key already exists and converting the Dictionary into an Array object or JSON string. + +

Service invocation

+ + The following example creates myDict as an empty dictionary. + + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + Dim myDict As Variant + myDict = CreateScriptService("Dictionary") + + + It is recommended to free resources after use: + + Set myDict = myDict.Dispose() + + + The example below creates an empty instance of the Dictionary service and uses the Python native update method to populate it with the contents of a Python dict object. + + dico = dict('A' = 1, 'B' = 2, 'C' = 3) + # Initialize myDict as an empty dict object + myDict = CreateScriptService('Dictionary') + # Load the values of dico into myDict + myDict.update(dico) + myDict['D'] = 4 + print(myDict) # {'A': 1, 'B': 2, 'C': 3, 'D': 4} + propval = myDict.ConvertToPropertyValues() + + It is possible to create an instance of the Dictionary service using a Python dict object as argument as shown in the following example. + + dico = dict('A' = 1, 'B' = 2, 'C' = 3) + # Initialize myDict with the content of dico + myDict = CreateScriptService('Dictionary', dico) + myDict['D'] = 4 + print(myDict) # {'A': 1, 'B': 2, 'C': 3, 'D': 4} + propval = myDict.ConvertToPropertyValues() + + Because Python has built-in dictionary support, most of the methods in the Dictionary service are available for Basic scripts only. Exceptions are ConvertToPropertyValues and ImportFromPropertyValues that are supported in both Basic and Python. + +

Properties

+ + + + Name + + + Read-only + + + Type + + + Description + + + + + Count + + + Yes + + + Long + + + The number of entries in the dictionary + + + + + Items + + + Yes + + + Array of Variants + + + The list of items as a one dimensional array + + + + + Keys + + + Yes + + + Array of Strings + + + The list of keys as a one dimensional array + + +
+ + The Keys and Items properties return their respective contents, using an identical ordering. The order is unrelated to the creation sequence. + + + The following example uses the Keys property to iterate over all keys in the dictionary myDict. + + Dim a As Variant, b As String + a = myDict.Keys + For Each b In a + MsgBox(myDict.Item(b)) + Next b + + + + + + Methods + + + + + Add
+ ConvertToArray
+ ConvertToJson
+ ConvertToPropertyValues +
+ + Exists
+ ImportFromJson
+ ImportFromPropertyValues
+ Item +
+ + Remove
+ RemoveAll
+ ReplaceItem
+ ReplaceKey +
+
+
+ +
+ Add ---------------------------------------------------------------------------------------------------- + + Dictionary service;Add + +

Add

+ Adds a new key-item pair into the dictionary. Returns True if successful. + + + dict.Add(key: str, item: any): bool + + + key: String value used to identify the Item. The key is not case-sensitive. + item: Any value, including an array, a Basic object, a UNO object, a dictionary, etc. + + + Dim NewValue As Variant + myDict.Add("NewKey", NewValue) + + Every key must be unique in the same dictionary. If the key already exists in the dictionary, a DUPLICATEKEYERROR will be raised. Keys that are made of space characters will raise a INVALIDKEYERROR error. +
+ +
+ ConvertToArray ----------------------------------------------------------------------------------------- + + Dictionary service;ConvertToArray + +

ConvertToArray

+ Stores the contents of the dictionary in a two-columns zero-based array. The keys are stored in the first column and the items are stored in the second column. + If the dictionary is empty, this method will return an empty Array. + + + dict.ConvertToArray(): any[0..*, 0..1] + + + + Dim myDict as Variant + myDict = CreateScriptService("Dictionary") + myDict.Add("a", 1) + myDict.Add("b", 2) + myDict.Add("c", 3) + Dim arr as Variant + arr = myDict.ConvertToArray() + '(("a", 1), ("b", 2), ("c", 3)) + +
+ +
+ ConvertToJson ------------------------------------------------------------------------------------------ + + Dictionary service;ConvertToJson + +

ConvertToJson

+ Converts the contents of a dictionary to JSON (JavaScript Object Notation) text. +

Limitations

+ This method supports the following data types: String, Boolean, numbers, Null and Empty. Arrays containing items of those types are also allowed, whatever their dimensions. Dates are converted into strings, however they cannot be used inside Arrays. Other data types are converted to their string representation using the SF_String.Represent service. + + + dict.ConvertToJson(indent: str = ""): str + + + indent: When indent is a positive number or a text, JSON array elements and object members are pretty-printed with that indentation level. A negative indent value will add new lines with no indentation. The default value is an empty string "" which selects the most compact representation. Using a positive integer for indent indents that many spaces per level. When indent is a string, such as Chr(9) or Tab(1), the Tab character is used to indent each level. + + + myDict.Add("p0", 12.5) + myDict.Add("p1", "a string àé""ê") + myDict.Add("p2", DateSerial(2020,9,28)) + myDict.Add("p3", True) + myDict.Add("p4", Array(1,2,3)) + MsgBox myDict.ConvertToJson() + '{"p0": 12.5, "p1": "a string \u00e0\u00e9\"\u00ea", "p2": "2020-09-28", "p3": true, "p4": [1, 2, 3]} + +
+ +
+ ConvertToPropertyValues --------------------------------------------------------------------------------- + + Dictionary service;ConvertToPropertyValues + API;PropertyValue + API;DateTime + +

ConvertToPropertyValues

+ Stores the contents of the dictionary into an array of PropertyValues. + Each entry in the array is a com.sun.star.beans.PropertyValue. The key is stored in Name, the item is stored in Value. + If one of the items has a type Date, it is converted to a com.sun.star.util.DateTime structure. If one of the items is an empty array, it is converted to Null. The resulting array is empty when the dictionary is empty. + + + dict.ConvertToPropertyValues(): obj[0..*] + + + + + Dim myDict as Variant + myDict = CreateScriptService("Dictionary") + 'Adds some properties to the dictionary + myDict.Add("Color", "Blue") + myDict.Add("Width", 20) + 'Converts to an Array of PropertyValue objects + Dim prop as Variant + prop = myDict.ConvertToPropertyValues() + + + Note in the example below that a Python dictionary needs to be passed as the second argument of the CreateScriptService method. + + myDict = dict() + myDict["Color"] = "Blue" + myDict["Width"] = 30 + sfDic = CreateScriptService("Dictionary", myDict) + prop = sfDic.ConvertToPropertyValues() + + Many services and methods in the UNO library take in parameters represented using the PropertyValue struct, which is part of the %PRODUCTNAME API. +
+ +
+ Exists ------------------------------------------------------------------------------------------------- + + Dictionary service;Exists + +

Exists

+ Determines if a key exists in the dictionary. + + + dict.Exists(key: str): bool + + + key: The key to be looked up in the dictionary. + + + Dim myDict as Variant + myDict = CreateScriptService("Dictionary") + 'Adds some properties to the dictionary + myDict.Add("Color", "Blue") + myDict.Add("Width", 20) + '(...) + If Not myDict.Exists("Size") Then + MsgBox "You have to provide a Size value" + End If + +
+ +
+ ImportFromJson ----------------------------------------------------------------------------------------- + + Dictionary service;ImportFromJson + +

ImportFromJson

+ Adds the content of a JSON (JavaScript Object Notation) string into the current dictionary. Returns True if successful. +

Limitations

+ The JSON string may contain numbers, text, booleans, null values and arrays containing those types. It must not contain JSON objects namely sub-dictionaries. + An attempt is made to convert text to date if the item matches one of these patterns: YYYY-MM-DD, HH:MM:SS or YYYY-MM-DD HH:MM:SS. + + + dict.ImportFromJson(inputstr: str, overwrite: bool = False): bool + + + inputstr: The string to import. + overwrite: When True, entries with same name may exist in the dictionary and their values are overwritten. When False (default), repeated keys will raise an error. Beware that dictionary keys are not case-sensitive while names are case-sensitive in JSON strings. + + + Dim s As String + s = "{'firstName': 'John','lastName': 'Smith','isAlive': true,'age': 66, 'birth': '1954-09-28 20:15:00'" _ + & ",'address': {'streetAddress': '21 2nd Street','city': 'New York','state': 'NY','postalCode': '10021-3100'}" _ + & ",'phoneNumbers': [{'type': 'home','number': '212 555-1234'},{'type': 'office','number': '646 555-4567'}]" _ + & ",'children': ['Q','M','G','T'],'spouse': null}" + s = Replace(s, "'", """") + myDict.ImportFromJson(s, OverWrite := True) + 'The (sub)-dictionaries "address" and "phoneNumbers" (0) and (1) are imported as Empty values. + +
+ +
+ ImportFromPropertyValues ------------------------------------------------------------------------------- + + Dictionary service;ImportFromPropertyValues + +

ImportFromPropertyValues

+ Inserts the contents of an array of PropertyValue objects into the current dictionary. PropertyValue Names are used as Keys in the dictionary, whereas Values contain the corresponding values. Returns True if successful. + + + dict.ImportFromPropertyValues(propertyvalues: obj[0..*], overwrite: bool = False): bool + + + propertyvalues: A zero-based 1-dimensional array containing com.sun.star.beans.PropertyValue objects. This parameter may also be a single PropertyValue object not contained in an Array. + overwrite: When True, entries with same name may exist in the dictionary and their values are overwritten. When False (default), repeated keys will raise an error. Note that dictionary keys are not case-sensitive in Basic, whereas names are case-sensitive in sets of property values and in Python dictionaries. + + The examples below first create an array with two PropertyValue objects and then convert it to a dictionary. + + + Dim vProp As New com.sun.star.beans.PropertyValue + Dim arrProp : arrProp = Array() + vProp.Name = "Color" + vProp.Value = "Blue" + arrProp = SF_Array.Append(arrProp, vProp) + vProp.Name = "Date" + vProp.Value = CDateToUnoDateTime(Now) + arrProp = SF_Array.Append(arrProp, vProp) + myDict = CreateScriptService("Dictionary") + myDict.ImportFromPropertyValues(arrProp, Overwrite := True) + Dim keys : keys = myDict.Keys + For Each k In keys + MsgBox k & " - " & myDict.Item(k) + Next k + + + + from scriptforge import CreateScriptService + from datetime import datetime + import uno + bas = CreateScriptService("Basic") + arrProp = list() + vProp = uno.createUnoStruct("com.sun.star.beans.PropertyValue") + vProp.Name = "Color" + vProp.Value = "Blue" + arrProp.append(vProp) + vProp = uno.createUnoStruct("com.sun.star.beans.PropertyValue") + vProp.Name = "Date" + vProp.Value = bas.CDateToUnoDateTime(datetime.now()) + arrProp.append(vProp) + myDict = CreateScriptService("Dictionary") + myDict.ImportFromPropertyValues(arrProp, overwrite=True) + for k in myDict.keys(): + bas.MsgBox("{} - {}".format(k, myDict[k])) + +
+ +
+ Item --------------------------------------------------------------------------------------------------- + + Dictionary service;Item + +

Item

+ Retrieves an existing dictionary entry based on its key. Returns the value of the item if successful, otherwise returns Empty. + + + dict.Item(key: str): any + + + key: Not case-sensitive. If it does not exist, Empty value is returned. + + The following example iterates over all keys in the dictionary and uses the Item method to access their values. + + Dim myDict as Variant, k as Variant, allKeys as Variant + myDict = CreateScriptService("Dictionary") + myDict.Add("key1", 100) + myDict.Add("key2", 200) + myDict.Add("key3", 300) + allKeys = myDict.Keys + For Each k in allKeys + MsgBox(myDict.Item(k)) + Next k + +
+ +
+ Remove ------------------------------------------------------------------------------------------------- + + Dictionary service;Remove + +

Remove

+ Removes an existing dictionary entry based on its key. Returns True if successful. + + + dict.Remove(key: str): bool + + + key: Not case-sensitive. Must exist in the dictionary, otherwise an UNKNOWNKEYERROR error is raised. + + + myDict.Add("key1", 100) + myDict.Add("key2", 200) + myDict.Add("key3", 300) + MsgBox(myDict.Count) ' 3 + myDict.Remove("key2") + MsgBox(myDict.Count) ' 2 + +
+ +
+ RemoveAll ---------------------------------------------------------------------------------------------- + + Dictionary service;RemoveAll + +

RemoveAll

+ Removes all the entries from the dictionary. Returns True if successful. + + + dict.RemoveAll(): bool + + + + myDict.Add("key1", 100) + myDict.Add("key2", 200) + myDict.Add("key3", 300) + MsgBox(myDict.Count) ' 3 + myDict.RemoveAll() + MsgBox(myDict.Count) ' 0 + +
+ +
+ ReplaceItem -------------------------------------------------------------------------------------------- + + Dictionary service;ReplaceItem + +

ReplaceItem

+ Replaces an existing item value based on its key. Returns True if successful. + + + dict.ReplaceItem(key: str, value: any): bool + + + key: String value representing the key whose value will be replaced. Not case-sensitive. If the key does not exist in the dictionary, an UNKNOWNKEYERROR error is raised. + value: The new value of the item referred to with the key parameter. + + + myDict.Add("a", 1) + MsgBox(myDict.Item("a")) ' 1 + myDict.ReplaceItem("a", 100) + MsgBox(myDict.Item("a")) ' 100 + +
+ +
+ ReplaceKey --------------------------------------------------------------------------------------------- + + Dictionary service;ReplaceKey + +

ReplaceKey

+ Replaces an existing key in the dictionary by a new key. The item value is left unchanged. Returns True if successful. + + + dict.ReplaceKey(key: str, value: str): bool + + + key: String value representing the key to be replaced. Not case-sensitive. If the key does not exist in the dictionary, a UNKNOWNKEYERROR error is raised. + value: String value for the new key. Not case-sensitive. If the new key already exists in the dictionary, an DUPLICATEKEYERROR error is raised. + + + myDict.Add("oldKey", 100) + MsgBox(myDict.Item("oldKey")) ' 100 + myDict.ReplaceKey("oldKey", "newKey") + MsgBox(myDict.Item("newKey")) ' 100 + +
+ + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_document.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_document.xhp new file mode 100644 index 000000000..f0c0ee7c5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_document.xhp @@ -0,0 +1,729 @@ + + + + + + + SFDocuments.Document service + /text/sbasic/shared/03/sf_document.xhp + + + + +
+ + Document service + +
+ +
+

SFDocuments.Document service

+ The SFDocuments library provides methods and properties to facilitate the management and manipulation of %PRODUCTNAME documents. + Methods that are applicable for all types of documents (Text Documents, Sheets, Presentations, etc) are provided by the SFDocuments.Document service. Some examples are: + + + Opening, closing and saving documents + + + Accessing standard or custom properties of documents + + +
+ + The properties, methods or arguments marked with (*) are NOT applicable to Base documents. + Methods and properties that are specific to certain %PRODUCTNAME components are stored in separate services, such as SFDocuments.SF_Calc and SFDocuments.SF_Base. + Although the Basic language does not offer inheritance between object classes, the latter services may be considered as subclasses of the SFDocuments.Document service. Such subclasses can invoke the properties and methods described below. + +

Service invocation

+ Before using the Document service the ScriptForge library needs to be loaded or imported: + + + Below are three variants of how the Document service can be invoked. + + Using the getDocument method from the ScriptForge.UI service: + + Dim ui As Object, oDoc As Object + Set ui = CreateScriptService("UI") + Set oDoc = ui.GetDocument("Untitled 1") + + Alternatively you can use the methods CreateDocument and OpenDocument from the UI service. + + Set oDocA = ui.CreateDocument("Calc") + Set oDocB = ui.OpenDocument("C:\Documents\MyFile.odt") + + Directly if the document is already open. + + Dim oDoc As Object + Set oDoc = CreateScriptService("SFDocuments.Document", "Untitled 1") 'Default = ActiveWindow + + From a macro triggered by a document event. + + Sub RunEvent(ByRef poEvent As Object) + Dim oDoc As Object + Set oDoc = CreateScriptService("SFDocuments.DocumentEvent", poEvent) + ' (...) + End Sub + + The Document service is closely related to the UI and FileSystem services. + Except when the document was closed by program with the CloseDocument method (it is then superfluous), it is recommended to free resources after use: + + Set oDoc = oDoc.Dispose() + + + + from scriptforge import CreateScriptService + ui = CreateScriptService("UI") + doc = ui.GetDocument("Untitled 1") + # (...) + doc.Dispose() + + + docA = ui.CreateDocument("Calc") + docB = ui.OpenDocument("C:\Documents\MyFile.odt") + + + doc = CreateScriptService("SFDocuments.Document", "Untitled 1") + + + def RunEvent(event) + doc = CreateScriptService("SFDocuments.DocumentEvent", Event) + # (...) + + The use of the prefix "SFDocuments." while calling the service is optional. + + + API;Duration + API;XComponent + API;ODatabaseDocument + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + CustomProperties (*) + + + No + + + Dictionary service + + + Returns a ScriptForge.Dictionary object instance. After update, can be passed again to the property for updating the document.
Individual items of the dictionary may be either strings, numbers, (Basic) dates or com.sun.star.util.Duration items.
+
+
+ + + Description (*) + + + No + + + String + + + Gives access to the Description property of the document (also known as "Comments") + + + + + DocumentProperties (*) + + + Yes + + + Dictionary service + + + Returns a ScriptForge.Dictionary object containing all the entries. Document statistics are included. Note that they are specific to the type of document. As an example, a Calc document includes a "CellCount" entry. Other documents do not. + + + + + DocumentType + + + Yes + + + String + + + String value with the document type ("Base", "Calc", "Writer", etc) + + + + + ExportFilters + + + Yes + + + String array + + + Returns a list with the export filter names applicable to the current document as a zero-based array of strings. Filters used for both import/export are also returned. + + + + + ImportFilters + + + Yes + + + String array + + + Returns a list with the import filter names applicable to the current document as a zero-based array of strings. Filters used for both import/export are also returned. + + + + + IsBase
IsCalc
IsDraw
IsImpress
IsMath
IsWriter
+
+ + Yes + + + Boolean + + + Exactly one of these properties is True for a given document. + +
+ + + Keywords (*) + + + No + + + String + + + Gives access to the Keywords property of the document. Represented as a comma-separated list of keywords + + + + + Readonly (*) + + + Yes + + + Boolean + + + True if the document is actually in read-only mode + + + + + Subject (*) + + + No + + + String + + + Gives access to the Subject property of the document. + + + + + Title (*) + + + No + + + String + + + Gives access to the Title property of the document. + + + + + XComponent + + + Yes + + + UNO Object + + + The UNO object com.sun.star.lang.XComponent or com.sun.star.comp.dba.ODatabaseDocument representing the document + + +
+ + + + The example below prints all the properties of a document. Note that the oDoc object returned by the UI.OpenDocument method is a SFDocuments.Document object. + + Dim ui as Variant : Set ui = CreateScriptService("UI") + Dim oDoc as Object + Set oDoc = ui.OpenDocument("C:\Documents\MyFile.ods") + Dim propDict as Object + Set propDict = oDoc.DocumentProperties + Dim keys as Variant : propKeys = propDict.Keys + Dim k as String, strProp as String + For Each k In propKeys + strProp = strProp & k & ": " & propDict.Item(k) & CHR$(10) + Next k + MsgBox strProp + oDoc.CloseDocument() + + + To access document properties in a Python script the user needs to directly access them using their names, as shown below: + + doc = ui.GetDocument(r"C:\Documents\MyFile.ods") + msg = doc.Title + '\n' + doc.Description + '\n' + doc.Keywords + bas = CreateScriptService("Basic") + bas.MsgBox(msg) + doc.CloseDocument() + + + + + List of Methods in the Document Service + + + + + Activate
+ CloseDocument
+ CreateMenu
+ ExportAsPDF
+
+
+ + + PrintOut
+ RemoveMenu
+ RunCommand
+ Save
+
+
+ + + SaveAs
+ SaveCopyAs
+ SetPrinter

+
+
+
+
+ +
+ Activate -------------------------------------------------------------------- + + Document service;Activate + +

Activate

+ Returns True if the document could be activated. Otherwise, there is no change in the actual user interface. It is equivalent to the Activate method of the UI service. + This method is useful when one needs to give focus for a document that is minimized or hidden. + + + svc.Activate(): bool + + + The example below considers that the file "My_File.ods" is already open but not active. + + + Dim oDoc As Object + Set oDoc = CreateScriptService("Document", "MyFile.ods") + oDoc.Activate() + + + + doc = CreateScriptService("Document", "MyFile.ods") + doc.Activate() + + Keep in mind that you can invoke the Document service by passing to CreateScriptService either "Document" or "SFDocuments.Document" +
+ +
+ CloseDocument ---------------------------------------------------------------- + + Document service;CloseDocument + +

CloseDocument

+ Closes the document. If the document is already closed, regardless of how the document was closed, this method has no effect and returns False. + The method will also return False if the user declines to close it. + Returns True if the document was successfully closed. + + + svc.CloseDocument(saveask: bool = True): bool + + + saveask : If True (default), the user is invited to confirm if the changes should be written on disk. This argument is ignored if the document was not modified. + + + + If oDoc.CloseDocument(True) Then + ' ... + End If + + + + if doc.CloseDocument(True): + # ... + +
+ +
+ CreateMenu --------------------------------------------------------------------------------------------- + + Document service;CreateMenu + +

CreateMenu

+ Creates a new menu entry in the menubar of a given document window. + This method returns an instance of the SFWidgets.Menu service. + The menu created is only available during the current %PRODUCTNAME session and is not saved neither in the document nor in the global application settings. Hence closing the document window will make the menu disappear. It will only reappear when the macro that creates the menu is executed again. + + + svc.CreateMenu(menuheader: str, [before: any], submenuchar: str = ">"): svc + + + menuheader: The toplevel name of the new menu. + before: The name (as a string) or position (as an integer starting at 1) of an existing menu before which the new menu will be placed. If no value is defined for this argument, the menu will be created at the last position in the menubar. + submenuchar: The delimiter used to create menu trees when calling methods as AddItem from the Menu service. The default value is ">". + + + + Dim oDoc as Object, oMenu as Object + Set oDoc = CreateScriptService("Document") + Set oMenu = oDoc.CreateMenu("My Menu") + With oMenu + ' Add items to the menu + .AddItem("Item A") + .AddItem("Item B") + ' ... + ' After creating the menu, the service instance can be disposed of + .Dispose() + End With + + + + doc = CreateScriptService("Document") + menu = doc.CreateMenu("My Menu") + menu.AddItem("Item A") + menu.AddItem("Item B") + # ... + menu.Dispose() + + +
+ +
+ ExportAsPDF -------------------------------------------------------------------------------------------- + + Document service;ExportAsPDF + +

ExportAsPDF

+ Exports the document directly as a PDF file to the specified location. Returns True if the PDF file was successfully created. + The export options can be set either manually using the File - Export As - Export as PDF dialog or by calling the methods GetPDFExportOptions and SetPDFExportOptions from the Session service. + + + svc.ExportAsPDF(filename: str, overwrite: bool = False, opt pages: str, opt password: str, opt watermark: str): bool + + + filename: The full path and file name of the PDF to be created. It must follow the SF_FileSystem.FileNaming notation. + overwrite: Specifies if the destination file can be overwritten (Default = False). An error will occur if overwrite is set to False and the destination file already exists. + pages: String specifying which pages will be exported. This argument uses the same notation as in the dialog File - Export As - Export as PDF. + password: Specifies a password to open the PDF file. + watermark: Text to be used as watermark in the PDF file, which will be drawn in every page of the resulting PDF. + + + The following example exports the current document as a PDF file, defines a password and overwrites the destination file if it already exists. + + oDoc.ExportAsPDF("C:\User\Documents\myFile.pdf", Password := "1234", Overwrite := True) + + The code snippet below gets the current PDF export options and uses them to create the PDF file. + + Dim exportSettings as Object, oSession as Object + oSession = CreateScriptService("Session") + exportSettings = oSession.GetPDFExportOptions() + ' Sets to True the option to export comments as PDF notes + exportSettings.ReplaceItem("ExportNotes", True) + oSession.SetPDFExportOptions(exportSettings) + oDoc.ExportAsPDF("C:\User\Documents\myFile.pdf") + + + + doc.ExportAsPDF(r"C:\User\Documents\myFile.pdf", password = "1234", overwrite = True) + + + session = CreateScriptService("Session") + exportSettings = oSession.GetPDFExportOptions() + exportSettings.ReplaceItem("ExportNotes", True) + session.SetPDFExportOptions(exportSettings) + doc.ExportAsPDF(r"C:\User\Documents\myFile.pdf") + +
+ +
+ PrintOut ---------------------------------------------------------------- + + Document service;PrintOut + +

PrintOut

+ This method sends the contents of the document to the default printer or to the printer defined by the SetPrinter method. + Returns True if the document was successfully printed. + + + svc.PrintOut(pages: str = "", copies: num = 1): bool + + + pages: The pages to print as a string, like in the user interface. Example: "1-4;10;15-18". Default is all pages. + copies: The number of copies. Default is 1. + + + + If oDoc.PrintOut("1-4;10;15-18", Copies := 2) Then + ' ... + End If + + + + if doc.PrintOut(copies=3, pages='45-88'): + # ... + +
+ +
+ RemoveMenu --------------------------------------------------------------------------------------------- + + Document service;RemoveMenu + +

RemoveMenu

+ Removes a toplevel menu from the menubar of a given document window. + Returns True if the specified menu could be removed. If the specified menu does not exist, the method returns False. + This method can be used to remove any menu entry from the document window, including default menus. However, none of these changes in the menubar are saved to the document or to the application settings. To restore the menubar to the default settings, simply close and reopen the document window. + + + svc.RemoveMenu(menuheader: str): bool + + + menuheader: The toplevel name of the menu to be removed. + + + + Dim oDoc as Object + Set oDoc = CreateScriptService("Document") + oDoc.RemoveMenu("My Menu") + + + + doc = CreateScriptService("Document") + doc.RemoveMenu("My Menu") + + +
+ +
+ RunCommand --------------------------------------------------------------- + + Document service;RunCommand + +

RunCommand

+ Runs a UNO command on the document window associated with the service instance. A few typical commands are: Save, SaveAs, ExportToPDF, Undo, Copy, Paste, etc. + The document itself does not need to be active to be able to run commands. + Commands can be run with or without arguments. Arguments are not validated before running the command. If the command or its arguments are invalid, then nothing will happen. + For a complete list of UNO commands that can be run in %PRODUCTNAME, refer to the Wiki page Development/DispatchCommands. + + + svc.RunCommand(command: str, [args: any]) + + + command: Case-sensitive string containing the UNO command name. The inclusion of the prefix ".uno:" in the command is optional. The command itself is not checked for correctness. If nothing happens after the command call, then the command is probably wrong. + args: For each argument to be passed to the command, specify a pair containing the argument name and value. + + + The following example runs the SelectData command in a Calc file named "MyFile.ods", which will result in the selection of the data area based on the currently selected cell. Note that this command does not require any arguments. + + Set oDoc = CreateScriptService("Document", "MyFile.ods") + oDoc.RunCommand("SelectData") + + Below is an example that runs the UNO command ReplaceAll and passes values for its arguments SearchString and ReplaceString. Running this command will replace all occurrence of the string "abc" by "ABC" in the current sheet. + + ' Arguments passed to the command: + ' SearchString = "abc" + ' ReplaceString = "ABC" + oDoc.RunCommand(".uno:ReplaceAll", "SearchString", "abc", "ReplaceString", "ABC") + + Note that calling the command ReplaceAll without arguments will open the Find and Replace dialog. + + + doc = CreateScriptService("Document", "MyFile.ods") + doc.RunCommand("SelectData") + + + doc.RunCommand(".uno:ReplaceAll", "SearchString", "abc", "ReplaceString", "ABC") + + In Python it is also possible to call RunCommand using keyword arguments: + + doc.RunCommand(".uno:ReplaceAll", SearchString = "abc", ReplaceString = "ABC") + + Each %PRODUCTNAME component has its own set of commands available. One easy way to learn commands is going to Tools - Customize - Keyboard. When you position your mouse over a function in the Function list, a tooltip will appear with the corresponding UNO command. +
+ +
+ Save ------------------------------------------------------------------------ + + Document service;Save + +

Save

+ Stores the document to the file location from which it was loaded. The method is ignored if the document was not modified. + Returns False if the document could not be saved. An error is raised if the file is open as read-only, or if it is a new file that has not been saved yet. + The document itself does not need to be active to run this method. + + + svc.Save(): bool + + + + + If Not oDoc.Save() Then + ' ... + End If + + + + if not doc.Save(): + # ... + +
+ +
+ SaveAs --------------------------------------------------------------------------------------- + + Document service;SaveAs + +

SaveAs

+ Stores the document to the given file location. The new location becomes the new file name on which simple Save method calls will be applied. + Returns False if the document could not be saved. An error is raised when overwriting the destination is rejected or when the destination has its read-only attribute set. + The document itself does not need to be active to run this method. + + + svc.SaveAs(filename: str, overwrite: bool = False, password: str = '', filtername: str = '', filteroptions: str = ''): bool + + + filename: A string containing the file name to be used. It must follow the SF_FileSystem.FileNaming notation. + overwrite: If True, the destination file may be overwritten (default = False). + password (*): A non-space string to protect the document. + filtername (*): The name of a filter that should be used for saving the document. If this argument is passed, then the filter must exist. + filteroptions (*): An optional string of options associated with the filter. + + + + oDoc.SaveAs("C:\Documents\NewCopy.odt", overwrite := True) + + + + doc.SaveAs(r"C:\Documents\NewCopy.odt", overwrite = True) + +
+ +
+ SaveCopyAs ------------------------------------------------------------------- + + Document service;SaveCopyAs + +

SaveCopyAs

+ Stores a copy of or export the document to the given file location. The actual location is unchanged. + Returns False if the document could not be saved. An error is raised when overwriting the destination is rejected or when the destination has its read-only attribute set. + The document itself does not need to be active to run this method. + + + svc.SaveCopyAs(filename: str, overwrite: bool = False, password: str = '', filtername: str = '', filteroptions: str = ''): bool + + + filename: A string containing the file name to be used. It must follow the SF_FileSystem.FileNaming notation. + overwrite: If True, the destination file may be overwritten (default = False). + password (*): A non-space string to protect the document. + filtername (*): The name of a filter that should be used for saving the document. If this argument is passed, then the filter must exist. + filteroptions (*): An optional string of options associated with the filter. + + + + oDoc.SaveCopyAs("C:\Documents\Copy2.odt", Overwrite := True) + + + + doc.SaveCopyAs(r"C:\Documents\Copy2.odt", overwrite = True) + +
+ +
+ SetPrinter ------------------------------------------------------------------- + + Document service;SetPrinter + +

SetPrinter

+ Defines the printer options for the document. + Returns True when successful. + + + svc.SetPrinter(opt printer: str, opt orientation: str, paperformat: str): bool + + +
+ printer: The name of the printer queue where to print to. When absent, the default printer is set. + orientation: Either PORTRAIT or LANDSCAPE. When absent, left unchanged with respect to the printer settings. + paperformat: Specifies the paper format as a string value that can be either A3, A4, A5, LETTER, LEGAL or TABLOID. Left unchanged when absent. +
+ + + + oDoc.SetPrinter(Orientation := "PORTRAIT") + + + + doc.SetPrinter(paperformat='TABLOID') + +
+ + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_exception.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_exception.xhp new file mode 100644 index 000000000..416c43457 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_exception.xhp @@ -0,0 +1,459 @@ + + + + + + + ScriptForge.Exception service (SF_Exception) + /text/sbasic/shared/03/sf_exception.xhp + + + +
+ + Exception service + +

ScriptForge.Exception service

+ The Exception service is a collection of methods to assist in code debugging in Basic and Python scripts and in error handling in Basic scripts. + In Basic scripts, when a run-time error occurs, the methods and properties of the Exception service help identify the error context and allow to handle it. +
+ + + The SF_Exception service is similar to the VBA Err object. + + + The Number property identifies the error. + + + Use the Raise method to interrupt processing. The RaiseWarning method can be used to trap an anomaly without interrupting the macro execution. + + + Errors and warnings raised with the Exception service are stored in memory and can be retrieved using the Console method. + + The Exception service console stores events, variable values and information about errors. Use the console when the Basic IDE is not easily accessible, for example in Calc user defined functions (UDF) or during events processing. + Use the DebugPrint method to add any relevant information to the console. Console entries can be dumped to a text file or visualized in a dialog window. + When an error occurs, an application macro may: + + Report the error in the Exception console + Inform the user about the error using either a standard message or a custom message + Optionally stop its execution + + In Python scripts the Exception service is mostly used for debugging purposes. Methods such as DebugPrint, Console and DebugDisplay are useful to quickly print messages, log data and open the console window from within a Python script. + Not all methods and properties are available for Python scripts since the Python language already has a comprehensive exception handling system. + +

Service invocation

+ + The following examples show three different approaches to call the method Raise. All other methods can be executed in a similar fashion. + + SF_Exception.Raise(...) + + + Dim exc : exc = SF_Exception + exc.Raise(...) + + + Dim exc : exc = CreateScriptService("Exception") + exc.Raise(...) + + + The code snippet below creates an instance of the Exception service, logs a message and displays the Console window. + + from scriptforge import CreateScriptService + exc = CreateScriptService("Exception") + someVar = 100 + exc.DebugPrint("Value of someVar", someVar) + exc.Console() + + +

Properties

+ The properties listed below are only available for Basic scripts. + + + + Name + + + Readonly + + + Description + + + + + Description + + + No + + + The error message text. + Default value is "" or a string containing the Basic run-time error message. + + + + + Number + + + No + + + The code of the error. It can be a numeric value or text. + Default value is 0 or the numeric value corresponding to the Basic run-time error code. + + + + + Source + + + No + + + The location in the code where the error occurred. It can be a numeric value or text. + Default value is 0 or the code line number for a standard Basic run-time error. + + +
+ Raising or clearing an Exception resets its properties. + + + + + List of Methods in the Exception Service + + + + + Clear
+ Console
+ ConsoleClear +
+
+ + + ConsoleToFile
+ DebugDisplay
+ DebugPrint

+
+
+ + + PythonPrint
+ PythonShell
+ Raise
+ RaiseWarning
+
+
+
+
+ +
+ Clear -------------------------------------------------------------------------------------------------------------------------- + + Exception service;Clear + +

Clear

+ Resets the current error status and clears the SF_Exception properties. + + + + SF_Exception.Clear() + + + The following example shows how to catch a division-by-zero exception, whose error code is 11. + + Sub Example_Clear() + Dim a, b, c + On Local Error GoTo Catch + Try: + a = 10 : b = 0 + c = a / b + '... + Exit Sub + Catch: + If SF_Exception.Number = 11 Then SF_Exception.Clear() + 'If division by zero, ignore the error + End Sub + + For a complete list of Basic run-time error codes, refer to Debugging a Basic Program. +
+ +
+ Console -------------------------------------------------------------------------------------------------------------------------- + + Exception service;Console + +

Console

+ Displays the console messages in a modal or non-modal dialog. In both modes, all the past messages issued by a DebugPrint() method or resulting from an exception are displayed. In non-modal mode, subsequent entries are added automatically. + If the console is already open, when non-modal, it is brought to the front. + A modal console can only be closed by the user. A non-modal console can either be closed by the user or upon macro termination. + + + exc.Console(modal: bool = True) + + + modal: Determine if the console window is modal (True) or non-modal (False). Default value is True. + + + + SF_Exception.Console(Modal := False) + + + + exc.Console(modal = False) + +
+ +
+ ConsoleClear -------------------------------------------------------------------------------------------------------------------------- + + Exception service;ConsoleClear + +

ConsoleClear

+ Clears the console keeping an optional number of recent messages. If the console is activated in non-modal mode, it is refreshed. + + + exc.ConsoleClear(keep: int = 0) + + + keep: The number of recent messages to be kept. Default value is 0. + + The following example clears the console keeping the 10 most recent messages. + + + SF_Exception.ConsoleClear(10) + + + + exc.ConsoleClear(10) + +
+ +
+ ConsoleToFile -------------------------------------------------------------------------------------------------------------------------- + + Exception service;ConsoleToFile + +

ConsoleToFile

+ Exports the contents of the console to a text file. If the file already exists and the console is not empty, it will be overwritten without warning. Returns True if successful. + + + exc.ConsoleToFile(filename: str): bool + + + filename: The name of the text file the console should be dumped into. The name is expressed according to the current FileNaming property of the SF_FileSystem service. By default, URL notation and the native operating system's format are both admitted. + + + + SF_Exception.ConsoleToFile("C:\Documents\myFile.txt") + + + + exc.ConsoleToFile(r"C:\Documents\myFile.txt") + +
+ +
+ DebugDisplay -------------------------------------------------------------------------------------------------------------------------- + + Exception service;DebugDisplay + +

DebugDisplay

+ Concatenates all the arguments into a single human-readable string and displays it in a MsgBox with an Information icon and an OK button. + The final string is also added to the Console. + + + exc.DebugDisplay(arg0: any, [arg1: any, ...]) + + + arg0[, arg1, ...]: Any number of arguments of any type. + + + + SF_Exception.DebugDisplay("Current Value", someVar) + + + + exc.DebugDisplay("Current Value", someVar) + +
+ +
+ DebugPrint -------------------------------------------------------------------------------------------------------------------------- + + Exception service;DebugPrint + +

DebugPrint

+ Assembles all the given arguments into a single human-readable string and adds it as a new entry in the console. + + + exc.DebugPrint(arg0: any, [arg1: any, ...]) + + + arg0[, arg1, ...]: Any number of arguments of any type. + + + + SF_Exception.DebugPrint(Null, Array(1, 2, 3), "line1" & Chr(10) & "Line2", DateSerial(2020, 04, 09)) + ' [NULL] [ARRAY] (0:2) (1, 2, 3) line1\nLine2 2020-04-09 + + + + exc.DebugPrint(None, [1, 2, 3], "line1\nline2") + # None [1, 2, 3] line1\nline2 + +
+ +
+ PythonPrint -------------------------------------------------------------------------------------------------------------------------- + + Exception service;PythonPrint + +

PythonPrint

+ Displays the list of arguments in a readable form in the Python shell (APSO) console. Arguments are separated by a TAB character (simulated by spaces). + The same string is added to the ScriptForge debug console. + + + + exc.PythonPrint(arg0: any, [arg1: any, ...]) + + + + arg0[, arg1, ...]: Any number of arguments of any type. The maximum length of each individual argument is 1024 characters. + + + exc.PythonPrint(a, Array(1, 2, 3), , "line1" & Chr(10) & "Line2", DateSerial(2020, 04, 09)) + + In python use simply the builtin print() statement. +
+ +
+ PythonShell -------------------------------------------------------------------------------------------------------------------------- + + Exception service;PythonShell + +

PythonShell

+ Opens an APSO Python shell as a non-modal window. The Python script keeps running after the shell is opened. The output from print statements inside the script are shown in the shell. + Only a single instance of the APSO Python shell can be opened at any time. Hence, if a Python shell is already open, then calling this method will have no effect. + + + + exc.PythonShell(variables: dict) + + + variables: a Python dictionary with variable names and values that will be passed on to the APSO Python shell. By default all local variables are passed using Python's builtin locals() function. + + The example below opens the APSO Python shell passing all global and local variables considering the context where the script is running. + + exc.PythonShell({**globals(), **locals()}) + + When the APSO Python shell is open, any subsequent output printed by the script will be shown in the shell. Hence, the string printed in the example below will be displayed in the Python shell. + + exc.PythonShell() + print("Hello world!") + +
+ +
+ Raise -------------------------------------------------------------------------------------------------------------------------- + + Exception service;Raise + +

Raise

+ Generates a run-time error. An error message is displayed to the user and reported in the console. The execution is stopped. The Raise() method can be placed inside the normal script flow or in a dedicated error-handling routine. + + + + SF_Exception.Raise([Number As Variant], [Source As Variant], [Description As String]) + + The code snippets presented next are equivalent. They show alternative ways to raise an exception with code 2100. + + SF_Exception.Raise(2100) + + + SF_Exception.Number = 2100 + SF_Exception.Raise() + + + SF_Exception.Raise Number := 2100 + + +
+ Number: The error code, as a number or as a string. Default value is that of Err Basic builtin function. + Source: The location of the error, as a number or as a string. Default value is that of Erl Basic builtin function. + Description: The message to display to the user and to report in the console. Default value is that of Error$ Basic builtin function. +
+ + + Sub Example_Raise() + Dim a, b, c + On Local Error GoTo Catch + Try: + a = 10 : b = 0 + c = a / b + '... + Exit Sub + Catch: + 'See variants below ... + End Sub + + To raise an exception with the standard values: + + Catch: + SF_Exception.Raise() + + To raise an exception with a specific code: + + Catch: + SF_Exception.Raise(11) + + To replace the usual message: + + Catch: + SF_Exception.Raise(, , "It is not a good idea to divide by zero.") + + To raise an application error: + + Catch: + SF_Exception.Raise("MyAppError", "Example_Raise()", "Something wrong happened !") + +
+ +
+ RaiseWarning -------------------------------------------------------------------------------------------------------------------------- + + Exception service;RaiseWarning + +

RaiseWarning

+ This method has exactly the same syntax, arguments and behavior as the Raise() method. + However, when a warning is raised, the macro execution is not stopped. + + + + SF_Exception.RaiseWarning([Number As Variant], [Source As Variant], [Description As String]) + + + + + + SF_Exception.RaiseWarning(Source:="Example_Raise()", _ + Description:="Something wrong happened !", _ + Number:="MyAppError") + +
+ +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp new file mode 100644 index 000000000..9461b7604 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_filesystem.xhp @@ -0,0 +1,1129 @@ + + + + + + + ScriptForge.FileSystem service + /text/sbasic/shared/03/sf_filesystem.xhp + + + + +
+ + FileSystem service + +
+ +
+

ScriptForge.FileSystem service

+ The FileSystem service includes routines to handle files and folders. Next are some examples of the features provided by this service: + + + Verify whether a file or folder exists. + + + Create and delete folders and files. + + + Launch dialog boxes to open/save files. + + + Access the list of files in a folder, etc. + + +
+ The methods in the FileSystem service are mostly based on the XSimpleFileAccess UNO interface. + +

Definitions

+ The table below lists the main parameters used by most of the methods in the FileSystem service. + + + + Parameter + + + Description + + + + + FileName + + + The full name of the file including the path without a path separator at the end. + + + + + FolderName + + + The full name of the folder including the path. It may or may not contain the ending path separator. + + + + + Name + + + The last component of the Folder Name or File Name including its extension. This parameter is always expressed using the native format of the operating system. + + + + + BaseName + + + The last component of the Folder Name or File Name without its extension. + + + + + NamePattern + + + Any of the above names containing wildcards in its last component. Admitted wildcards are: + + + "?" represents any single character + + + "*" represents zero, one, or multiple characters + + + + +
+ The FileSystem service allows to perform operations over multiple files at the same time. By using name patterns, user scripts can copy, move or delete multiple files. Conversely, Basic built-in methods can only handle single files. + +

File Naming Notation

+ The notation used to express file and folder names, both for arguments and returned values, is defined by the FileNaming property of the FileSystem service. + In short, the possible representation types are "URL" (URL file notation), "SYS" (operating system notation) and "ANY" (default). See more information below. + An example of the URL notation is file:///C:/Documents/my_file.odt. Whenever possible consider using the URL notation because it is a more portable alternative. + The use of the shortcut "~" (tilde), which is common in Linux-based operating systems, is not supported to express a path to a folder and file name. Instead of using "~/Documents/my_file.odt" use the full path "/home/user/Documents/my_file.odt". + +

Service invocation

+ The following code snippet invokes the FileSystem service. The method BuildPath was used as an example. + + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim FSO As Object + Set FSO = CreateScriptService("FileSystem") + FSO.BuildPath(...) + + + + from scriptforge import CreateScriptService + fs = CreateScriptService("FileSystem") + fs.BuildPath(...) + + + + FileSystem service;FileNaming property + FileSystem service;ConfigFolder property + FileSystem service;ExtensionsFolder property + FileSystem service;HomeFolder property + FileSystem service;InstallFolder property + FileSystem service;TemplatesFolder property + FileSystem service;TemporaryFolder property + FileSystem service;UserTemplatesFolder property + +

Properties

+
+ + + + Name + + + Readonly + + + Type + + + Description + + + + + FileNaming + + + No + + + String + + + Sets or returns the current files and folders notation, either "ANY", "URL" or "SYS": + + + "ANY": (default) the methods of the FileSystem service accept both URL and current operating system's notation for input arguments but always return URL strings. + + + "URL": the methods of the FileSystem service expect URL notation for input arguments and return URL strings. + + + "SYS": the methods of the FileSystem service expect current operating system's notation for both input arguments and return strings. + + + Once set, the FileNaming property remains unchanged either until the end of the %PRODUCTNAME session or until it is set again. + + + + + ConfigFolder + + + Yes + + + String + + + Returns the configuration folder of %PRODUCTNAME. + + + + + ExtensionsFolder + + + Yes + + + String + + + Returns the folder where extensions are installed. + + + + + HomeFolder + + + Yes + + + String + + + Returns the user home folder. + + + + + InstallFolder + + + Yes + + + String + + + Returns the installation folder of %PRODUCTNAME. + + + + + TemplatesFolder + + + Yes + + + String + + + Returns the folder containing the system templates files. + + + + + TemporaryFolder + + + Yes + + + String + + + Returns the temporary files folder defined in the %PRODUCTNAME path settings. + + + + + UserTemplatesFolder + + + Yes + + + String + + + Returns the folder containing the user-defined template files. + + +
+
+ + + + List of Methods in the FileSystem Service + + + + + BuildPath
+ CompareFiles
+ CopyFile
+ CopyFolder
+ CreateFolder
+ CreateTextFile
+ DeleteFile
+ DeleteFolder
+ ExtensionFolder
+
+
+ + + FileExists
+ Files
+ FolderExists
+ GetBaseName
+ GetExtension
+ GetFileLen
+ GetFileModified
+ GetName
+ GetParentFolderName
+
+
+ + + GetTempName
+ HashFile
+ MoveFile
+ MoveFolder
+ OpenTextFile
+ PickFile
+ PickFolder
+ SubFolders

+
+
+
+
+ +
+ BuildPath ----------------------------------------------------------------------------------- + + FileSystem service;BuildPath + +

BuildPath

+ Joins a folder path and the name of a file and returns the full file name with a valid path separator. The path separator is added only if necessary. + + + svc.BuildPath(foldername: str, name: str): str + + + foldername: The path with which name will be combined. The specified path does not need to be an existing folder. + name: The name of the file to be appended to foldername. This parameter uses the notation of the current operating system. + + + + Dim FSO as Object + Set FSO = CreateScriptService("FileSystem") + Dim aFileName as String + FSO.FileNaming = "URL" + aFileName = FSO.BuildPath("file:///home/user", "sample file.odt") + ' file:///home/user/sample%20file.odt + + + + fs = CreateScriptService("FileSystem") + fs.FileNaming = "URL" + aFileName = fs.BuildPath("file:///home/user", "sample file.odt") + # file:///home/user/sample%20file.odt + +
+ +
+ CompareFiles ----------------------------------------------------------------------------- + + FileSystem service;CompareFiles + +

CompareFiles

+ Compares two files and returns True when they seem identical. + Depending on the value of the comparecontents argument, the comparison between both files can be either based only on file attributes (such as the last modified date), or based on the file contents. + + + svc.CompareFiles(filename1: str, filename2: str, comparecontents: bool = False): bool + + + filename1, filename2: The files to compare. + comparecontents: When True, the contents of the files are compared (default = False). + + + + FSO.FileNaming = "SYS" + If FSO.CompareFiles("C:\myFile1.txt", "C:\myFile2.txt", CompareContents := False) Then + ' ... + End If + + + + fs.FileNaming = "SYS" + if fs.CompareFiles(r"C:\myFile1.txt", r"C:\myFile2.txt", comparecontents = False): + # ... + +
+ +
+ CopyFile ---------------------------------------------------------------------------------------- + + FileSystem service;CopyFile + +

CopyFile

+ Copies one or more files from one location to another. Returns True if at least one file has been copied or False if an error occurred. + An error will also occur if the source parameter uses wildcard characters and does not match any files. + The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred. + + + svc.CopyFile(source: str, destination: str, overwrite: bool = True): bool + + + source: It can be a FileName or a NamePattern indicating one or more files to be copied. + destination: It can be either a FileName specifying where the single source file is to be copied, or a FolderName into which the multiple files from source are to be copied. + + + If destination does not exist, it is created. + + + Wildcard characters are not allowed in destination. + + + overwrite: If True (default), files may be overwritten. The method will fail if destination is readonly, regardless of the value specified in overwrite. + + In the examples below the first line copies a single file whereas the second line copies multiple files using wildcards. + + + FSO.CopyFile("C:\Documents\my_file.odt", "C:\Temp\copied_file.odt") + FSO.CopyFile("C:\Documents\*.*", "C:\Temp\", Overwrite := False) + + + + fs.CopyFile(r"C:\Documents\my_file.odt", r"C:\Temp\copied_file.odt") + fs.CopyFile(r"C:\Documents\*.*", r"C:\Temp", overwrite = False) + + Beware that subfolders and their contents are not copied when wildcards are used in the source argument. +
+ +
+ CopyFolder ----------------------------------------------------------------------------------- + + FileSystem service;CopyFolder + +

CopyFolder

+ Copies one or more folders from one location to another. Returns True if at least one folder has been copied or False if an error occurred. + An error will also occur if the source parameter uses wildcard characters and does not match any folders. + The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred. + + + svc.CopyFolder(source: str, destination: str, overwrite: bool = True): bool + + + source: It can be a FolderName or a NamePattern indicating one or more folders to be copied. + destination: Specifies the FolderName into which the single or multiple folders defined in source are to be copied. + + + If destination does not exist, it is created. + + + Wildcard characters are not allowed in destination. + + + overwrite: If True (default), files may be overwritten. The method will fail if destination is readonly, regardless of the value specified in overwrite. + + In the examples below all files, folders and subfolders are copied. + + ' Basic + FSO.CopyFolder("C:\Documents\*", "C:\Temp\", Overwrite := False) + + + # Python + fs.CopyFolder(r"C:\Documents\*", r"C:\Temp", overwrite = False) + +
+ +
+ CreateFolder -------------------------------------------------------------------------------------------------------------------------- + + FileSystem service;CreateFolder + +

CreateFolder

+ Creates the specified FolderName. Returns True if the folder could be successfully created. + If the specified folder has a parent folder that does not exist, it is created. + + + svc.CreateFolder(foldername: str): bool + + + foldername: A string representing the folder to be created. If the folder already exists, an exception will be raised. + + + ' Basic + FSO.CreateFolder("C:\NewFolder") + + + # Python + fs.CreateFolder(r"C:\NewFolder") + +
+ +
+ CreateTextFile ------------------------------------------------------------------------------ + + FolderSystem service;CreateTextFile + +

CreateTextFile

+ Creates a specified file and returns a TextStream service instance that can be used to write to the file. + The method returns a Null object if an error occurred. + + + svc.CreateTextFile(filename: str, overwrite: bool = True, encoding: str = 'UTF-8'): svc + + + filename: The name of the file to be created. + overwrite: Boolean value that determines if filename can be overwritten (default = True). + encoding: The character set to be used. The default encoding is "UTF-8". + + + + Dim myFile As Object + FSO.FileNaming = "SYS" + Set myFile = FSO.CreateTextFile("C:\Temp\ThisFile.txt", Overwrite := True) + + + + fs.FileNaming = "SYS" + myFile = fs.CreateTextFile(r"C:\Temp\ThisFile.txt", overwrite = True) + + To learn more about the names of character sets, visit IANA's Character Set page. Beware that %PRODUCTNAME does not implement all existing character sets. +
+ +
+ DeleteFile -------------------------------------------------------------------------------------------------------------------------- + + FileSystem service;DeleteFile + +

DeleteFile

+ Deletes one or more files. Returns True if at least one file has been deleted or False if an error occurred. + An error will also occur if the filename parameter uses wildcard characters and does not match any files. + The files to be deleted must not be readonly. + The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred. + + + svc.DeleteFile(filename: str): bool + + + filename: It can be a FileName or a NamePattern indicating one or more files to be deleted. + + In the examples below only files are deleted, subfolders are not deleted. + + ' Basic + FSO.DeleteFile("C:\Temp\*.docx") + + + # Python + fs.DeleteFile(r"C:\Temp\*.docx") + +
+ +
+ DeleteFolder -------------------------------------------------------------------------------------------------------------------------- + + FileSystem service;DeleteFolder + +

DeleteFolder

+ Deletes one or more folders. Returns True if at least one folder has been deleted or False if an error occurred. + An error will also occur if the foldername parameter uses wildcard characters and does not match any folders. + The folders to be deleted must not be readonly. + The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred. + + + svc.DeleteFolder(foldername: str): bool + + + foldername: It can be a FolderName or a NamePattern indicating one or more folders to be deleted. + + In the examples below only folders and their contents are deleted. Files in the parent folder "C:\Temp" are not deleted. + + ' Basic + FSO.DeleteFolder("C:\Temp\*") + + + # Python + fs.DeleteFolder(r"C:\Temp\*") + +
+ +
+ ExtensionFolder --------------------------------------------------------------------------------------- + + FileSystem service;ExtensionFolder + +

ExtensionFolder

+ Returns a string containing the folder where the specified extension package is installed. + The current value of the property SF_FileSystem.FileNaming is used to determine the notation of the returned string. + Use the property Extensions from the Platform service to get string array with the IDs of all installed extensions. + + + svc.ExtensionFolder(extension: str): str + + + extension: A string value with the ID of the extension. If the extension is not installed, an exception is raised. + + The examples below in Basic and Python return the folder where the APSO extension is installed. + + ' Basic + sFolder = FSO.ExtensionFolder("apso.python.script.organizer") + ' file:///home/username/.config/libreoffice/4/user/uno_packages/cache/uno_packages/lu10833wz3u2i.tmp_/apso_1_2_7.oxt + + + # Python + sFolder = fs.ExtensionFolder("apso.python.script.organizer") + +
+ +
+ FileExists --------------------------------------------------------------------------------------- + + FileSystem service;FileExists + +

FileExists

+ Returns True if a given file name is valid and exists, otherwise the method returns False. + If the filename parameter is actually an existing folder name, the method returns False. + + + svc.FileExists(filename: str): bool + + + filename: A string representing the file to be tested. + + + + FSO.FileNaming = "SYS" + If FSO.FileExists("C:\Documents\my_file.odt") Then + '... + End If + + + + fs.FileNaming = "SYS" + if fs.FileExists(r"C:\Documents\my_file.odt"): + # ... + +
+ +
+ Files ------------------------------------------------------------------------------------------ + + FileSystem service;Files + +

Files

+ Returns a zero-based array of the files stored in a given folder. Each entry in the array is a string containing the full path and file name. + If the argument foldername specifies a folder that does not exist, an exception is raised. + The resulting list may be filtered with wildcards. + + + svc.Files(foldername: str, filter: str = ''): str[0..*] + + + foldername: A string representing a folder. The folder must exist. This argument must not designate a file. + filter: A string containing wildcards ("?" and "*") that will be applied to the resulting list of files (default = ""). + + + + Dim filesList As Variant, file As String + FSO.FileNaming = "SYS" + filesList = FSO.Files("/home/user/", "*.txt") + For Each file In filesList + ' ... + Next file + + + + fs.FileNaming = "SYS" + filesList = fs.Files("/home/user/", "*.txt") + for file in fileList: + # ... + +
+ +
+ FolderExists -------------------------------------------------------------------------------------- + + FileSystem service;FolderExists + +

FolderExists

+ Returns True if the specified FolderName is valid and exists, otherwise the method returns False. + If the foldername parameter is actually an existing file name, the method returns False. + + + svc.FolderExists(foldername: str): bool + + + foldername: A string representing the folder to be tested. + + + + FSO.FileNaming = "SYS" + If FSO.FolderExists("C:\Documents\Thesis") Then + '... + End If + + + + fs.FileNaming = "SYS" + if fs.FolderExists(r"C:\Documents\Thesis") + # ... + +
+ +
+ GetBaseName --------------------------------------------------------------------------------------- + + FileSystem service;GetBaseName + +

GetBaseName

+ Returns the BaseName (equal to the last component) of a folder or file name, without its extension. + The method does not check if the specified file or folder exists. + + + svc.GetBaseName(filename: str): str + + + filename: A string representing the file name and its path. + + In the examples below, the first GetBaseName method call corresponds to a folder, so the function returns the last component of the path. The second call receives a file name as input, so the name of the file is returned without its extension. + + + MsgBox FSO.GetBaseName("/home/user/Documents") ' "Documents" + MsgBox FSO.GetBaseName("/home/user/Documents/my_file.ods") ' "my_file" + + + + bas = CreateScriptService("Basic") + bas.MsgBox(fs.GetBaseName("/home/user/Documents")) # "Documents" + bas.MsgBox(fs.GetBaseName("/home/user/Documents/my_file.ods")) # "my_file" + +
+ +
+ GetExtension ------------------------------------------------------------------------------------ + + FileSystem service;GetExtension + +

GetExtension

+ Returns the extension part of a file or folder name without the dot "." character. + The method does not check for the existence of the specified file or folder. + If this method is applied to a folder name or to a file without an extension, then an empty string is returned. + + + svc.GetExtension(filename: str): str + + + filename: A string representing the file name and its path. + + + ' Basic + ext = FSO.GetExtension("C:\Windows\Notepad.exe") ' "exe" + + + # Python + ext = fs.GetExtension(r"C:\Windows\Notepad.exe") # "exe" + +
+ +
+ GetFileLen ----------------------------------------------------------------------------------- + + FileSystem service;GetFileLen + +

GetFileLen

+ The builtin FileLen Basic function returns the number of bytes contained in a file as a Long value, i.e. up to 2GB. + The GetFileLen method can handle files with much larger sizes by returning a Currency value. + + + svc.GetFileLen(filename: str): num + + + filename: A string representing an existing file. + + + + Dim fLen As Currency + FSO.FileNaming = "SYS" + fLen = FSO.GetFileLen("C:\pagefile.sys") + + + + fs.FileNaming = "SYS" + fLen = fs.GetFileLen(r"C:\pagefile.sys") + +
+ +
+ GetFileModified -------------------------------------------------------------------------------------------------------------------------- + + FileSystem service;GetFileModified + +

GetFileModified

+ Returns the last modified date of a given file. + + + svc.GetFileModified(filename: str): datetime + + + filename: A string representing an existing file. + + + + Dim aDate As Date + FSO.FileNaming = "SYS" + aDate = FSO.GetFileModified("C:\Documents\my_file.odt") + + + + fs.FileNaming = "SYS" + aDate = FSO.GetFileModified(r"C:\Documents\my_file.odt") + +
+ +
+ GetName -------------------------------------------------------------------------------------------------------------------------- + + FileSystem service;GetName + +

GetName

+ Returns the last component of a file or folder name in native operating system format. + The method does not check if the specified file or folder exists. + + + svc.GetName(filename: str): str + + + filename: A string representing the file name and its path. + + + ' Basic + a = FSO.GetName("C:\Windows\Notepad.exe") ' Notepad.exe + + + # Python + a = fs.GetName(r"C:\Windows\Notepad.exe") # Notepad.exe + +
+ +
+ GetParentFolderName ------------------------------------------------------------------------------- + + FileSystem service;GetParentFolderName + +

GetParentFolderName

+ Returns a string containing the name of the parent folder of a specified file or folder name. + The method does not check if the specified file or folder exists. + + + svc.GetParentFolderName(filename: str): str + + + filename: A string with the file or folder name to be analyzed. + + + ' Basic + a = FSO.GetParentFolderName("C:\Windows\Notepad.exe") ' C:\Windows\ + + + # Python + a = fs.GetParentFolderName(r"C:\Windows\Notepad.exe") # C:\Windows\ + +
+ +
+ GetTempName ---------------------------------------------------------------------------------------- + + FileSystem service;GetTempName + +

GetTempName

+ Returns a randomly generated temporary file name that is useful for performing operations that require a temporary file. + The returned file name does not have any suffix. The folder part of the returned string is the system's temporary folder. + The method does not create the temporary file. + + + svc.GetTempName(): str + + + + + Dim fName As String + FSO.FileNaming = "SYS" + fName = FSO.GetTempName() & ".txt" + ' "/tmp/SF_574068.txt" + + + + fs.FileNaming = "SYS" + fName = FSO.GetTempName() + ".txt" + # "/tmp/SF_574068.txt" + +
+ +
+ HashFile -------------------------------------------------------------------------------------- + + FileSystem service;HashFile + +

HashFile

+ Hash functions are used by some cryptographic algorithms, in digital signatures, message authentication codes, fraud detection, fingerprints, checksums (message integrity check), hash tables, password storage and much more. + The HashFile method returns the result of a hash function, applied on a given file and using a specified algorithm. The returned value is a string of lower-case hexadecimal digits. + The hash algorithms supported are: MD5, SHA1, SHA224, SHA256, SHA384 and SHA512. + + + svc.HashFile(filename: str, algorithm: str): str + + + filename: A string representing an existing file. + algorithm: One of the supported algorithms. + + + ' Basic + sHash = FSO.HashFile("C:\pagefile.sys", "MD5") + + + # Python + sHash = FSO.HashFile(r"C:\pagefile.sys", "MD5") + +
+ +
+ MoveFile -------------------------------------------------------------------------------------------- + + FileSystem service;MoveFile + +

MoveFile

+ Moves one or more files from one location to another. Returns True if at least one file has been moved or False if an error occurred. + An error will also occur if the source parameter uses wildcard characters and does not match any files. + The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred. + + + svc.MoveFile(source: str, destination: str): bool + + + source: It can be a FileName or NamePattern to designate one or more files to be moved. + destination: If source is a FileName then this parameter indicates the new path and file name of the moved file. + If the move operation involves multiple files, then destination must be a folder name. If it does not exist, it is created. + If source and destination have the same parent folder, the method will rename the source. + Wildcard characters are not allowed in destination. + + In the following examples only files are moved, subfolders are not. + + ' Basic + FSO.MoveFile("C:\Temp1\*.*", "C:\Temp2") + + + # Python + fs.MoveFile(r"C:\Temp1\*.*", r"C:\Temp2") + +
+ +
+ MoveFolder --------------------------------------------------------------------------------------- + + FolderSystem service;MoveFolder + +

MoveFolder

+ Moves one or more folders from one location to another. Returns True if at least one folder has been moved or False if an error occurred. + An error will also occur if the source parameter uses wildcard characters and does not match any folders. + The method stops immediately after it encounters an error. The method does not roll back nor does it undo changes made before the error occurred. + + + svc.MoveFolder(source: str, destination: str): bool + + + source: It can be a FolderName or NamePattern to designate one or more folders to be moved. + destination: If the move operation involves a single folder, then destination is the name and path of the moved folder and it must not exist. + If multiple folders are being moved, then destination designates where the folders in source will be moved into. If destination does not exist, it is created. + Wildcard characters are not allowed in destination. + + + ' Basic + FSO.MoveFolder("C:\Temp1\*", "C:\Temp2") + + + # Python + fs.MoveFolder(r"C:\Temp1\*", r"C:\Temp2") + +
+ +
+ OpenTextFile ----------------------------------------------------------------------------------------- + + FolderSystem service;OpenTextFile + +

OpenTextFile

+ Opens a file and returns a TextStream object that can be used to read from, write to, or append to the file. + Note that the method does not check if the given file is really a text file. + The method returns a Null object (in Basic) or None (in Python) if an error occurred. + + + svc.OpenTextFile(filename: str, iomode: int = 1, create: bool = False, encoding: str = 'UTF-8'): svc + + + filename: Identifies the file to open. + iomode: Indicates the input/output mode. It can be one of three constants: svc.ForReading (default), svc.ForWriting, or svc.ForAppending. + create: Boolean value that indicates whether a new file can be created if the specified filename doesn't exist: + + + If True a new file and its parent folders will be created if they do not exist; + + + If False then new files are not created (default). + + + encoding: The character set to be used. The default encoding is "UTF-8". + + + + Dim myFile As Object + FSO.FileNaming = "SYS" + Set myFile = FSO.OpenTextFile("C:\Temp\ThisFile.txt", FSO.ForReading) + If Not IsNull(myFile) Then + ' ... + End If + + + + fs.FileNaming = "SYS" + myFile = fs.OpenTextFile(r"C:\Temp\ThisFile.txt", fs.ForReading) + if myFile is not None: + # ... + +
+ +
+ PickFile --------------------------------------------------------------------------------------------- + + FileSystem service;PickFile + +

PickFile

+ Opens a dialog box to open or save files. + If the SAVE mode is set and the picked file exists, a warning message will be displayed. + + + svc.PickFile(defaultfile: str ='', mode: str = 'OPEN', filter: str = ''): str + + + defaultfile: This argument is a string composed of a folder and file name: + + + The folder part indicates the folder that will be shown when the dialog opens (default = the last selected folder). + + + The file part designates the default file to open or save. + + + mode: A string value that can be either "OPEN" (for input files) or "SAVE" (for output files). The default value is "OPEN". + filter: The extension of the files displayed when the dialog is opened (default = no filter). + + The examples below open a file picker with the "txt" filter applied. + + ' Basic + aFile = FSO.PickFile("C:\Documents", "OPEN", "txt") + + + # Python + aFile = fs.PickFile(r"C:\Documents", "OPEN", "txt") + +
+ +
+ PickFolder ---------------------------------------------------------------------------------------- + + FileSystem service;PickFolder + +

PickFolder

+ Opens a dialog box to select a folder. + + + svc.PickFolder(defaultfolder: str = '', freetext: str = ''): str + + + defaultfolder: A string containing the folder name that will be displayed when the dialog is opened (default = the last selected folder). + freetext: Text to display in the dialog (default = ""). + + + ' Basic + aFolder = FSO.PickFolder("C:\Documents", "Choose a folder or press Cancel") + + + # Python + aFolder = fs.PickFolder(r"C:\Documents", "Choose a folder or press Cancel") + +
+ +
+ SubFolders ---------------------------------------------------------------------------------------- + + FileSystem service;Files + +

SubFolders

+ Returns a zero-based array of strings corresponding to the folders stored in a given foldername. + The list may be filtered with wildcards. + + + svc.SubFolders(foldername: str, filter: str = ''): str[0..*] + + + foldername: A string representing a folder. The folder must exist. foldername must not designate a file. + filter: A string containing wildcards ("?" and "*") that will be applied to the resulting list of folders (default = ""). + + + + Dim folderList As Variant, folder As String + FSO.FileNaming = "SYS" + folderList = FSO.SubFolders("/home/user/") + For Each folder In folderList + ' ... + Next folder + + + + fs.FileNaming = "SYS" + folderList = fs.SubFolders("/home/user/") + for folder in folderList: + # ... + +
+ + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_form.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_form.xhp new file mode 100644 index 000000000..d9515a222 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_form.xhp @@ -0,0 +1,841 @@ + + + + + + SFDocuments.Form service + /text/sbasic/shared/03/sf_form.xhp + + + +
+ + Form service + +
+
+

SFDocuments.Form service

+ The Form service provides methods and properties to manage forms in %PRODUCTNAME documents. This service supports forms in Base, Calc and Writer documents and allows to: + + + Open and activate forms. + + + Navigate through records shown by the form. + + + Get access to the controls inside the form. + + + Get access to subforms of a parent form. + + +
+ The SFDocuments.Form service is available from %PRODUCTNAME 7.2 onwards. + Forms are usually used in %PRODUCTNAME documents to create user interfaces connected to relational databases. Hence, the Form service provides quick access to the linked database through the SFDatabases.Database service. + The SFDocuments.Form service is closely related to the SFDocuments.FormControl service. +

Definitions

+

FormDocument

+ Forms are usually created in Base documents, but they can be added to Writer and Calc documents as well. + In Base, each form you create using the Insert - Form functionality or through the Form Wizard is actually a FormDocument that can be handled with the Form service. Base documents can contain an unlimited number of form documents. + Below is an example showing the hierarchy of all the elements involved in accessing forms and subforms in a Base document. Suppose you have a Base file named Employees.odb and inside it you created a form document to add new employees to the database. The form document contains a main form named EmployeeData that gives access to a table. There is also a subform WorksAtPlant that allows you to associate the new employee to one of the plants of the company. + + Employees.odb (Base document) + | + |-- AddEmployee (FormDocument) + | + |-- EmployeeData (Main Form) + | + |-- WorksAtPlant (SubForm) + + A FormDocument can be seen as a set of forms that provide access to datasets such as database tables and queries from within %PRODUCTNAME documents. The names of forms and subforms inside a FormDocument can be accessed using the Form Navigator. +

Forms and Subforms

+ A form document is composed of one or more forms which, in turn, may also contain any number of subforms. A Form is an abstract set of controls that are linked to a specified data source, which can be a database table, a query or a SQL SELECT statement. + In Calc and Writer documents, each form can be linked to datasets located in different databases. On the other hand, in Base documents the database contained in the document is common to all forms. + To invoke the SFDocuments.Form service refer to the methods Forms(), FormDocuments() and OpenFormDocument() of the SFDocuments.Document service +
+

Service invocation

+ Before using the Form service the ScriptForge library needs to be loaded or imported: + + +

In Writer documents

+ The code snippet below shows how to access the form named Form1 that is inside a Writer file: + + Dim oDoc As Object, myForm As Object, ui as Object + Set ui = CreateScriptService("UI") + Set oDoc = ui.OpenDocument("/home/user/Documents/MyForm.odt") + Set myForm = oDoc.Forms("Form1") + + + + from scriptforge import CreateScriptService + ui = CreateScriptService('UI') + doc = ui.OpenDocument('/home/user/Documents/MyForm.odt') + my_form = doc.Forms('Form1') + + Forms can be accessed by their names or by their indices, as shown below: + + Set myForm = oDoc.Forms(0) + + + + my_form = doc.Forms(0) + + If you try to access a FormDocument that is currently opened in Design Mode an exception will be raised. +

In Calc documents

+ A form in a Calc file must have a unique name inside its sheet. Hence, the Forms method requires two arguments, the first indicating the sheet name and the second specifying the form name. + + Dim oDoc As Object, myForm As Object, ui as Object + Set ui = CreateScriptService("UI") + Set oDoc = ui.OpenDocument("/home/user/Documents/MyForms.ods") + Set myForm = oDoc.Forms("Sheet1", "Form1") + + This is achieved identically using Python: + + ui = CreateScriptService('UI') + doc = ui.OpenDocument('/home/user/Documents/MyForms.ods') + my_form = doc.Forms('Sheet1', 'Form1') + +

In Base documents

+ A FormDocument inside a Base document is accessed by its name. The following example opens the form document named thisFormDocument and accesses the form MainForm: + + Dim oDb As Object, myForm As Object + Set oDb = CreateScriptService("SFDocuments.Document", ThisDatabaseDocument) + ' The statement below is necessary only if the form hasn't been opened yet + oDb.OpenFormDocument("thisFormDocument") + Set myForm = oDoc.Forms("thisFormDocument", "MainForm") + ' Or, alternatively, to access the form by its index ... + Set myForm = oDb.Forms("thisFormDocument", 0) + + To perform any action on a form using the Form service, the FormDocument must have been opened either manually by the user or programmatically in a user script. The latter can be done by calling the OpenFormDocument method of the Base service. + To access a given subform of a form use the SubForms method. Note that in the example below mySubForm is a new instance of the Form service. + + Dim mySubForm As Object + Set mySubForm = myForm.SubForms("mySubForm") + + Previous examples translate in Python as: + + db = CreateScriptService('SFDocuments.Document', XSCRIPTCONTEXT.getDocument()) + # The statement below is necessary only if the form hasn't been opened yet + form_doc = db.OpenFormDocument('thisFormDocument') + form = form_doc.Forms('thisFormDocument', 'MainForm') + # Or, alternatively, to access the form by its index ... + form = form_doc.Forms('thisFormDocument', 0) + sub_form = form.SubForms('mySubForm') + +

In Form events

+ To invoke the Form service when a form event takes place: + + Sub OnEvent(ByRef poEvent As Object) + Dim myForm As Object + Set myForm = CreateScriptService("SFDocuments.FormEvent", poEvent) + '(...) + End sub + + + + def OnEvent(event: uno): + form = CreateScriptService('SFDocuments.FormEvent', event) + pass + + + It is recommended to free resources after use of the Form service. + + myForm.Dispose() ' Basic + + + form.Dispose() # Python + + This operation is done implicitly when a form document is closed with the CloseFormDocument() method described below. +
+

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + AllowDeletes + + + No + + + Boolean + + + Specifies if the form allows to delete records. + + + + + AllowInserts + + + No + + + Boolean + + + Specifies if the form allows to add records. + + + + + AllowUpdates + + + No + + + Boolean + + + Specifies if the form allows to update records. + + + + + BaseForm + + + Yes + + + String + + + Specifies the hierarchical name of the Base Form containing the actual form. + + + + + Bookmark + + + No + + + Variant + + + Specifies uniquely the current record of the form's underlying table, query or SQL statement. + + + + + CurrentRecord + + + No + + + Long + + + Identifies the current record in the dataset being viewed on a form. If the row number is positive, the cursor moves to the given row number with respect to the beginning of the result set. Row count starts at 1. If the given row number is negative, the cursor moves to an absolute row position with respect to the end of the result set. Row -1 refers to the last row in the result set. + + + + + Filter + + + No + + + String + + + Specifies a subset of records to be displayed as a SQL WHERE-clause without the WHERE keyword. + + + + + LinkChildFields + + + Yes + + + String + + + Specifies how records in a child subform are linked to records in its parent form. + + + + + LinkParentFields + + + Yes + + + String + + + Specifies how records in a child subform are linked to records in its parent form. + + + + + Name + + + Yes + + + String + + + The name of the current form. + + + + + OrderBy + + + No + + + String + + + Specifies in which order the records should be displayed as a SQL ORDER BY clause without the ORDER BY keywords. + + + + + Parent + + + Yes + + + Object + + + The parent of the current form. It can be either a SFDocuments.Form or a SFDocuments.Document object. + + + + + RecordSource + + + No + + + String + + + Specifies the source of the data, as a table name, a query name or a SQL statement. + + + + + XForm + + + Yes + + + UNO
object
+
+ + The UNO object representing interactions with the form. Refer to XForm and DataForm in the API documentation for detailed information. + +
+
+

Event properties

+ The properties below return or set URI strings that define the script triggered by the event. + + + + Name + + + ReadOnly + + + Basic IDE Description + + + + + OnApproveCursorMove + + + No + + + Before record change + + + + + OnApproveParameter + + + No + + + Fill parameters + + + + + OnApproveReset + + + No + + + Prior to reset + + + + + OnApproveRowChange + + + No + + + Before record action + + + + + OnApproveSubmit + + + No + + + Before submitting + + + + + OnConfirmDelete + + + No + + + Confirm deletion + + + + + OnCursorMoved + + + No + + + After record change + + + + + OnErrorOccurred + + + No + + + Error occurred + + + + + OnLoaded + + + No + + + When loading + + + + + OnReloaded + + + No + + + When reloading + + + + + OnReloading + + + No + + + Before reloading + + + + + OnResetted + + + No + + + After resetting + + + + + OnRowChanged + + + No + + + After record action + + + + + OnUnloaded + + + No + + + When unloading + + + + + OnUnloading + + + No + + + Before unloading + + +
+ To learn more about URI strings, refer to the Scripting Framework URI Specification. + + + List of methods in the Form service + + + + Activate
+ CloseFormDocument
+ Controls
+ GetDatabase
+
+ + MoveFirst
+ MoveLast
+ MoveNext
+ MoveNew
+
+ + MovePrevious
+ Requery
+ SubForms

+
+
+
+
+ Activate -------------------------------------------------------------------------------------------------------------------------- + + Form service;Activate + +

Activate

+ Sets the focus on the current Form instance. Returns True if focusing was successful. + The behavior of the Activate method depends on the type of document where the form is located: + + + In Writer documents: Sets the focus on that document. + + + In Calc documents: Sets the focus on the sheet to which the form belongs. + + + In Base documents: Sets the focus on the FormDocument the Form refers to. + + + + svc.Activate(): bool + + The following example assumes you want to activate the form named FormA located in Sheet1 of the currently open Calc file. It first gets access to the document using the Document service and ThisComponent and then activates the form. + + 'Gets hold of the form that will be activated + Dim oDoc as Object, myForm as Object + Set oDoc = CreateScriptService("Document", ThisComponent) + Set myForm = oDoc.Forms("Sheet1", "FormA") + 'Activates the form + myForm.Activate() + + + + doc = CreateScriptService('Document', XSCRIPTCONTEXT.getDocument()) + form = doc.Forms('Sheet1', 'FormA') + form.Activate() + + ThisComponent applies to Calc and Writer documents. For Base documents use ThisDataBaseDocument. +
+
+ CloseFormDocument -------------------------------------------------------------------------------------------------------------------------- + + Form service;CloseFormDocument + +

CloseFormDocument

+ Closes the form document containing the actual Form instance. The Form instance is disposed. + + svc.CloseFormDocument(): bool + + + myForm.CloseFormDocument() ' Basic + + + + form.CloseFormDocument() # Python + + This method only closes form documents located in Base documents. If the form is stored in a Writer or Calc document, calling CloseFormDocument will have no effect. +
+
+ Controls -------------------------------------------------------------------------------------------------------------------------- + + Form service;Controls + +

Controls

+ The value returned by the Controls method depends on the arguments provided: + + + If the method is called without arguments, then it returns the list of the controls contained in the form. Beware that the returned list does not contain any subform controls. + + + If the optional ControlName argument is provided, the method returns a FormControl class instance referring to the specified control. + + + + svc.Controls(opt controlname: str): any + + controlname : A valid control name as a case-sensitive string. If absent, the list of control names is returned as a zero-based array. + + + Dim myForm As Object, myList As Variant, myControl As Object + Set myForm = myDoc.Forms("myForm") + myList = myform.Controls() + Set myControl = myform.Controls("myTextBox") ' SFDocuments.FormControl + + + + form = doc.Forms('myForm') + form_names = form.Controls() + form_control = form.Controls('myTextBox') # SFDocuments.FormControl + +
+
+ GetDatabase -------------------------------------------------------------------------------------------------------------------------- + + Form service;GetDatabase + +

GetDatabase

+ Return a SFDatabases.Database instance giving access to the execution of SQL commands on the database the current form is connected to and/or that is stored in the current Base document. + Each form has its own database connection, except in Base documents where they all share the same connection. + + svc.GetDatabase(opt user: str, opt password: str): svc + + user, password: The login optional parameters (Default = ""). + + + Dim myDb As Object ' SFDatabases.Database + Set myDb = oForm.GetDatabase() + + + + db = form.GetDatabase() # SFDatabases.Database + +
+
+ MoveFirst -------------------------------------------------------------------------------------------------------------------------- + + Form service;MoveFirst + +

MoveFirst

+ The form cursor is positioned on the first record. Returns True if successful. + + svc.MoveFirst(): bool + + + myForm.MoveFirst() ' Basic + + + + form.MoveFirst() # Python + +
+
+ MoveLast -------------------------------------------------------------------------------------------------------------------------- + + Form service;MoveLast + +

MoveLast

+ The form cursor is positioned on the last record. Returns True if successful. + + svc.MoveLast(): bool + + + myForm.MoveLast() ' Basic + + + + form.MoveLast() # Python + +
+
+ MoveNew -------------------------------------------------------------------------------------------------------------------------- + + Form service;MoveNew + +

MoveNew

+ The form cursor is positioned on the new record area. Returns True if successful. + + svc.MoveNew(): bool + + + myForm.MoveNew() ' Basic + + + + form.MoveNew() # Python + +
+
+ MoveNext -------------------------------------------------------------------------------------------------------------------------- + + Form service;MoveNext + +

MoveNext

+ The form cursor is positioned on the next record. Returns True if successful. + + svc.MoveNext(opt offset: int): bool + + offset: The number of records to go forward (Default = 1). + + + myForm.MoveNext() ' Basic + + + + form.MoveNext() # Python + +
+
+ MovePrevious -------------------------------------------------------------------------------------------------------------------------- + + Form service;MovePrevious + +

MovePrevious

+ The form cursor is positioned on the previous record. Returns True if successful. + + svc.MovePrevious(opt offset: int): bool + + offset: The number of records to go backwards (Default = 1). + + + myForm.MovePrevious() ' Basic + + + form.MovePrevious() # Python + +
+
+ Requery -------------------------------------------------------------------------------------------------------------------------- + + Form service;Requery + +

Requery

+ Reloads the current data from the database and refreshes the form. The cursor is positioned on the first record. Returns True if successful. + + svc.Requery(): bool + + + myForm.Requery() ' Basic + + + + form.Requery() # Python + +
+
+ Subforms -------------------------------------------------------------------------------------------------------------------------- + + Form service;Subforms + +

Subforms

+ The value returned by the Subforms method depends on the arguments provided: + + + If the method is called without any arguments, then it returns the list of subforms contained in the current form or subform instance. + + + If the optional subform argument is provided, the method returns a new SFDocuments.Form instance based on the specified form/subform name or index. + + + + svc.Subforms(): str[0..*] + svc.Subforms(subform: str): svc + svc.Subforms(subform: int): svc + + subform: A subform stored in the current Form class instance given by its name or index. + When this argument is absent, the method returns a list of available subforms as a zero-based array. If the form has a single subform, you can set subform = 0 to get access to it. + + + Dim myForm As Object, myList As Variant, mySubform As Object + myList = myform.Subforms() + Set mySubform = myForm.Subforms("mySubform") ' SFDocuments.Form + + + + subform_names = form.Subforms() + subform = form.Subforms('mySubform') # SFDocuments.Form + +
+ +
+ + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_formcontrol.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_formcontrol.xhp new file mode 100644 index 000000000..4bcfaf687 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_formcontrol.xhp @@ -0,0 +1,1173 @@ + + + + + + SFDocuments.FormControl service + /text/sbasic/shared/03/sf_formcontrol.xhp + + + +
+ + FormControl service + +
+
+

SFDocuments.FormControl service

+ The FormControl service provides access to the controls that belong to a form, a subform or a table control of a FormDocument. Each instance of the FormControl service refers to a single control in the form. This service allows users to: + + + Get and set the properties of the control represented by the FormControl instance. + + + Access the current value displayed by the control. + + + Set the focus on the desired control. + + +
+ To use the FormControl service in a particular form, subform or table control, all controls must have unique names. + Radio buttons that share the same group name must also have unique control names. + The main purpose of the FormControl service is setting and getting the properties and values displayed by the controls in a form. + All controls have a Value property. However, its contents will vary according to the control type. For more information, read The Value Property below. + It is also possible to format the controls via the XControlModel and XControlView properties. + The SFDocuments.FormControl service is closely related to the SFDocuments.Form service. + + API;awt.XControl + API;awt.XControlModel + + +

Service invocation

+ Before using the FormControl service the ScriptForge library needs to be loaded or imported: + + + The FormControl service is invoked from an existing Form service instance through its Controls method. + + Dim oDoc as Object, myForm As Object, myControl As Object + Set oDoc = CreateScriptService("SFDocuments.Document", ThisDataBaseDocument) + Set myForm = oDoc.Forms("formDocumentName", "formName") ' SFDocuments.Form + Set myControl = myForm.Controls("myTextBox") ' SFDocuments.FormControl + myControl.Value = "Current time = " & Now() + + + + from scriptforge import CreateScriptService + from time import localtime, strftime + bas = CreateScriptService('ScriptForge.Basic') + doc = CreateScriptService('SFDocuments.Document', bas.ThisDatabaseDocument) + form = doc.Forms('formDocumentName', 'formName') # SFDocuments.Form + control = form.Controls('myTextBox') # SFDocuments.FormControl + control.Value = 'Current Time = ' + strftime("%a, %d %b %Y %H:%M:%S", localtime()) + + To learn more about how to open a FormDocument and get access to its forms, refer to the SFDocuments.Form service help page. + Alternatively a FormControl instance can be retrieved via the SFDocuments.FormEvent service, which returns the SFDocuments.FormControl class instance that triggered the event. + + Sub OnEvent(ByRef poEvent As Object) + Dim oControl As Object + Set oControl = CreateScriptService("SFDocuments.FormEvent", poEvent) + ' oControl now represents the instance of the FormControl class that triggered the current event + ' ... + End Sub + + + + def onEvent(event: uno): + control = CreateScriptService('SfDocuments.FormEvent', event) + + Note that in previous examples, the prefix "SFDocuments." may be omitted. + + FormEvent service + +
+ The FormEvent service is used exclusively to create instances of the SFDocuments.Form and SFDocuments.FormControl services when a form or control event takes place. +
+

Control types

+ The FormControl service is available for the following control types: + + + Button + + + CheckBox + + + ComboBox + + + CurrencyField + + + DateField + + + FileControl + + + FixedText + + + FormattedField + + + GroupBox + + + HiddenControl + + + ImageButton + + + ImageControl + + + ListBox + + + NavigationBar + + + NumericField + + + PatternField + + + RadioButton + + + ScrollBar + + + SpinButton + + + TableControl + + + TextField + + + TimeField + + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Applicable to + + + Description + + + + + Action + + + No + + + String + + + Button + + + Specifies the action triggered when the button is clicked. Accepted values are: none, submitForm, resetForm, refreshForm, moveToFirst, moveToLast, moveToNext, moveToPrev, saveRecord, moveToNew, deleteRecord, undoRecord. + + + + + Caption + + + No + + + String + + + Button, CheckBox, FixedText, GroupBox, RadioButton + + + Specifies the text displayed by the control. + + + + + ControlSource + + + Yes + + + String + + + CheckBox, ComboBox, CurrencyField, DateField, FormattedField, ImageControl, ListBox, NumericField, PatternField, RadioButton, TextField, TimeField + + + Specifies the rowset field mapped onto the current control. + + + + + ControlType + + + Yes + + + String + + + All + + + One of the control types listed above. + + + + + Default + + + No + + + Boolean + + + Button + + + Specifies whether a command button is the default OK button. + + + + + DefaultValue + + + No + + + Variant + + + CheckBox, ComboBox, CurrencyField, DateField, FileControl, FormattedField, ListBox, NumericField, PatternField, RadioButton, SpinButton, TextField, TimeField + + + Specifies the default value used to initialize a control in a new record. + + + + + Enabled + + + No + + + Boolean + + + All (except HiddenControl) + + + Specifies if the control is accessible with the cursor. + + + + + Format + + + No + + + String + + + DateField, TimeField, FormattedField (read-only) + + + Specifies the format used to display dates and times. It must be one of following strings: + For dates: "Standard (short)", "Standard (short YY)", "Standard (short YYYY)", "Standard (long)", "DD/MM/YY", "MM/DD/YY", "YY/MM/DD", "DD/MM/YYYY", "MM/DD/YYYY" , "YYYY/MM/DD", "YY-MM-DD", "YYYY-MM-DD". + For times: "24h short", "24h long", "12h short", "12h long". + + + + + ListCount + + + Yes + + + Long + + + ComboBox, ListBox + + + Returns the number of rows in a ListBox or a ComboBox. + + + + + ListIndex + + + No + + + Long + + + ComboBox, ListBox + + + Specifies which item is selected in a ListBox or ComboBox. In case of multiple selection, the index of the first item is returned or only one item is set. + + + + + ListSource + + + No + + + Variant + + + ComboBox, ListBox + + + Specifies the data contained in a ComboBox or a ListBox as a zero-based array of string values. + Combined with ListSourceType, may also contain the name of a table, a query or a complete SQL statement. + + + + + ListSourceType + + + No + + + Integer + + + ComboBox, ListBox + + + Specifies the type of data contained in a combobox or a listbox. + It must be one of the com.sun.star.form.ListSourceType.* constants. + + + + + Locked + + + No + + + Boolean + + + ComboBox, CurrencyField, DateField, FileControl, FileControl, FormattedField, ImageControl, ListBox, NumericField, PatternField, TextField, TimeField + + + Specifies if the control is read-only. + + + + + MultiSelect + + + No + + + Boolean + + + ListBox + + + Specifies whether the user can select multiple items in a listbox. + + + + + Name + + + Yes + + + String + + + All + + + The name of the control. + + + + + Parent + + + Yes + + + Object + + + All + + + Depending on the parent type, a form, a subform or a tablecontrol, returns the parent SFDocuments.Form or SFDocuments.FormControl class object instance. + + + + + Picture + + + No + + + String + + + Button, ImageButton, ImageControl + + + Specifies the file name containing a bitmap or other type of graphic to be displayed on the control. The filename must comply with the FileNaming attribute of the ScriptForge.FileSystem service. + + + + + Required + + + No + + + Boolean + + + CheckBox, ComboBox, CurrencyField, DateField, ListBox, NumericField, PatternField, RadioButton, SpinButton, TextField, TimeField + + + A control is said required when the underlying data must not contain a null value. + + + + + Text + + + Yes + + + String + + + ComboBox, DateField, FileControl, FormattedField, PatternField, TextField, TimeField + + + Gives access to the text being displayed by the control. + + + + + TipText + + + No + + + String + + + All (except HiddenControl) + + + Specifies the text that appears as a tooltip when you hover the mouse pointer over the control. + + + + + TripleState + + + No + + + Boolean + + + CheckBox + + + Specifies if the checkbox control may appear dimmed (grayed) or not. + + + + + Value + + + No + + + Variant + + + + This property depends on the current control type. Refer to The Value property for more information. + + + + + Visible + + + No + + + Boolean + + + All (except HiddenControl) + + + Specifies if the control is hidden or visible. + + + + + XControlModel + + + Yes + + + UNO
object
+
+ + All + + + The UNO object representing the control model. Refer to XControlModel and UnoControlModel in the API documentation for more information. + +
+ + + XControlView + + + Yes + + + UNO
object
+
+ + All + + + The UNO object representing the control view. Refer to XControl and UnoControl in the API documentation for more information. + +
+
+

The Value property

+ + + + Control type + + + Type + + + Description + + + + + Button + + + Boolean + + + Applicable to toggle buttons only. + + + + + CheckBox + + + Boolean or Integer + + + 0, False: not checked
1, True: checked
2: grayed out, don't know (applicable if TripleState is True)
+
+
+ + + ComboBox + + + String + + + The selected value, as a String. The ListIndex property is an alternate option to access the index of the selected value. + + + + + CurrencyField + + + Numeric + + + + + + + + DateField + + + Date + + + + + + + + FileControl + + + String + + + A file name formatted in accordance with the FileNaming property of the ScriptForge.FileSystem service + + + + + FormattedField + + + String or Numeric + + + + + + + + HiddenControl + + + String + + + + + + + + ListBox + + + String or array of strings + + + The selected row(s) as a single string or an array of strings. Only a single value can be set. If the box is linked to a database, this property gets or sets the underlying data. Otherwise it gets or sets the data being displayed. + + + + + NumericField + + + Numeric + + + + + + + + PatternField + + + String + + + + + + + + RadioButton + + + Boolean + + + Each button has its own name. Multiple RadioButton controls are linked together when they share the same group name. If a RadioButton is set to True, the other related buttons are automatically set to False + + + + + ScrollBar + + + Numeric + + + Must be within the predefined bounds + + + + + SpinButton + + + Numeric + + + Must be within the predefined bounds + + + + + TextField + + + String + + + The text appearing in the field + + + + + TimeField + + + Date + + + + + +
+

Event properties

+ The properties below return or set URI strings that define the script triggered by the event. + + + + Name + + + ReadOnly + + + Description as labeled in the Basic IDE + + + + + OnActionPerformed + + + No + + + Execute action + + + + + OnAdjustmentValueChanged + + + No + + + While adjusting + + + + + OnApproveAction + + + No + + + Approve action + + + + + OnApproveReset + + + No + + + Prior to reset + + + + + OnApproveUpdate + + + No + + + Before updating + + + + + OnChanged + + + No + + + Changed + + + + + OnErrorOccurred + + + No + + + Error occurred + + + + + OnFocusGained + + + No + + + When receiving focus + + + + + OnFocusLost + + + No + + + When losing focus + + + + + OnItemStateChanged + + + No + + + Item status changed + + + + + OnKeyPressed + + + No + + + Key pressed + + + + + OnKeyReleased + + + No + + + Key released + + + + + OnMouseDragged + + + No + + + Mouse moved while key presses + + + + + OnMouseEntered + + + No + + + Mouse inside + + + + + OnMouseExited + + + No + + + Mouse outside + + + + + OnMouseMoved + + + No + + + Mouse moved + + + + + OnMousePressed + + + No + + + Mouse button pressed + + + + + OnMouseReleased + + + No + + + Mouse button released + + + + + OnResetted + + + No + + + After resetting + + + + + OnTextChanged + + + No + + + Text modified + + + + + OnUpdated + + + No + + + After updating + + +
+ To learn more about URI strings, refer to the Scripting Framework URI Specification. + + + List of Methods in the FormControl Service + + + + Controls
+
+ + SetFocus
+
+
+
+ +
+ Controls -------------------------------------------------------------------------------------------------------------------------- + + FormControl service;Controls + +

Controls

+ This method is applicable only to controls of the TableControl type. The returned value depends on the arguments provided. + If the optional argument controlname is absent, then a zero-based Array containing the names of all controls is returned. + On the other hand, if a controlname is provided, the method returns a FormControl class instance corresponding to the specified control. + + svc.Controls(): str[0..*] + svc.Controls(controlname: str): svc + + controlname: A valid control name as a case-sensitive string. If absent, the list of control names is returned as a zero-based array. + + + Dim myGrid As Object, myList As Variant, myControl As Object + Set myGrid = myForm.Controls("myTableControl") ' SFDocuments.FormControl + ' Returns an Array with the names of all controls in "myTableControl" + myList = myGrid.Controls() + ' Returns a FormControl class instance corresponding to "myCheckBox" + Set myControl = myGrid.Controls("myCheckBox") + + Using Python: + + grid = form.Controls('myTableControl') # SFDocuments.FormControl + control_names = form.Controls() + control = grid.Controls('myCheckBox') # SFDocuments.FormControl + +
+
+ SetFocus -------------------------------------------------------------------------------------------------------------------------- + + FormControl service;SetFocus + +

SetFocus

+ Sets the focus on the control. Returns True if focusing was successful. + This method is often called from a form or control event. + + svc.SetFocus(): bool + + + Dim oDoc As Object, oForm As Object, oControl As Object + Set oDoc = CreateScriptService("SFDocuments.Document", ThisComponent) + Set oForm = oDoc.Forms(0) + Set oControl = oForm.Controls("thisControl") ' SFDocuments.FormControl + oControl.SetFocus() + + + + bas = CreateScriptService('ScriptForge.Basic') + doc = CreateScriptService('SFDocuments.Document', bas.ThisComponent) + form = doc.Forms(0) + control = form.Controls('thisControl') # SFDocuments.FormControl + control.SetFocus() + +
+ Additional examples -------------------------------------------------------------------------------------------------------------------------- +

Additional examples

+ Below are two examples that illustrate the use of the FormControl service. + The first example reads the current value in a ComboBox containing city names and writes it to a FixedTest control in a Form: + + Dim oDoc as Object, myForm as Object, myControl as Object + Set oDoc = CreateScriptService("SFDocuments.Document", ThisDataBaseDocument) + myForm = oDoc.Forms("formDocumentName", "formName") + Dim lbCity : lbCity = myForm.Controls("labelCity") + Dim cbCity : cbCity = myForm.Controls("comboboxCity") + lbCity.Caption = "Selected City: " & cbCity.Value + + + + bas = CreateScriptService('ScriptForge.Basic') # Basic-like methods + doc = CreateScriptService('SFDocuments.Document', bas.ThisDatabaseDocument) + form = doc.Forms('formDocumentName', 'formName') + lbl_city = form.Controls('labelCity') + combo_city = form.Controls('comboboxCity') + lbl_city.Caption = "Selected city: " + combo_city.Value + + The following code snippet can be used to process RadioButton controls that share the same group name. In this example, suppose there are three radio buttons with names optA, optB and optC and we wish to display the caption of the selected control. + + Dim oDoc as Object, myForm as Object + Set oDoc = CreateScriptService("SFDocuments.Document", ThisDataBaseDocument) + myForm = oDoc.Forms("formDocumentName", "formName") + Dim optNames As Object : optNames = Array("optA", "optB", "optC") + Dim optControl as Object, opt as Variant + For Each opt In optNames + optControl = myForm.Controls(opt) + If optControl.Value = True Then + MsgBox "Selected option: " & optControl.Caption + Exit For + End If + Next opt + + + + bas = CreateScriptService('ScriptForge.Basic') # Basic-like methods + doc = CreateScriptService('SFDocuments.Document', bas.ThisDatabaseDocument) + form = doc.Forms('formDocumentName', 'formName') + radio_buttons = ['optA', 'optB', 'optC'] + for name in radio_buttons: + control = form.controls(name) + if control.Value == True: + bas.MsgBox('Selected option: ' + control.Caption) + break + + +
+ + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_intro.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_intro.xhp new file mode 100644 index 000000000..98081e545 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_intro.xhp @@ -0,0 +1,181 @@ + + + + + + + Creating Python Scripts with ScriptForge + /text/sbasic/shared/03/sf_intro.xhp + + + + + + Python scripts with ScriptForge + +

Creating Python Scripts with ScriptForge

+

Differences between Basic and Python

+ The ScriptForge library is available both for Basic and Python. Most services, methods and properties work identically in both programming languages. However, due to differences in how each language works, ScriptForge users must be aware of some characteristics of the library when using Python: + + + Methods and Property names: In Python, all methods and properties can be used in lowercased, ProperCased or camelCased formats. + + + Arguments: All keyword arguments passed on to methods are lowercased. + + + Dates: All date objects are passed and returned as datetime.datetime native Python objects. + + + Arrays: One-dimensional arrays are passed and returned as tuples (which is an immutable object). Two-dimensional arrays are passed and returned as tuples of tuples. + + + None: Python's None keyword is equivalent to Basic's Null, Empty or Nothing. + + + UNO objects: All UNO structures are exchanged between Basic and Python without any changes. + + + Debugging: Whenever an error occurs in Python scripts that use ScriptForge, the error message provided by the Python execution stack displays the line of code that triggered the error. In Basic error messages do not display this information. + + + Visit %PRODUCTNAME Python Scripts Help for more information on Python scripting using %PRODUCTNAME. +

Running Python scripts on %PRODUCTNAME

+ Depending on what you intend to achieve, you may choose one of the following approaches to running Python scripts in %PRODUCTNAME: + + + Run Scripts inside the current %PRODUCTNAME process: Python scripts are executed from within the %PRODUCTNAME process by using the Tools - Macros - Run Macro menu or the APSO extension to call user scripts stored in the Python scripts folder. You can also use the APSO Python shell to interactively run Python scripts. + + + Run Scripts separately from the %PRODUCTNAME process: Python scripts are executed from an external process that connects to an ongoing %PRODUCTNAME process using a socket. + + + If you plan to run scripts from inside the %PRODUCTNAME process, it is recommended to install the APSO (Alternative Script Organizer for Python) extension. However, to develop Python scripts from outside %PRODUCTNAME, you can choose your preferred Python IDE. + +

Running Scripts from inside the %PRODUCTNAME process

+

Using the APSO extension

+ The easiest way to get started with Python scripting in %PRODUCTNAME is by installing the APSO extension. After installing it, open any %PRODUCTNAME component and go to Tools - Macros - Organize Python Scripts. + In APSO's main window go to Menu - Python Shell. + Alternatively you can open APSO using the default shortcut Alt + Shift + F11. + Now you can start typing Python commands and the shell will print the corresponding output after each line of code is executed. + To start using the ScriptForge library, you need to import the CreateScriptService method, with which you will be able to access the services provided by the library. The example below uses the Basic service to display a message box. + + from scriptforge import CreateScriptService + bas = CreateScriptService("Basic") + bas.MsgBox("Hello!") + + To run the example above, enter each line in the Python shell, one by one, pressing the Enter key after you type each line of code. + Now you can start executing Python commands using any of the ScriptForge services. For example, the code snippet below uses the UI service to create a blank Writer document. + + ui = CreateScriptService("UI") + doc = ui.CreateDocument("Writer") + + +

Creating Python script files

+ You can create your own Python files and edit them with your preferred text editor. Later you can call them from within any %PRODUCTNAME component. + The first step is to locate where your user scripts are stored. For that, refer to Python Scripts Organization and Location help page. + Now you can create a text file inside your Python user scripts folder, for instance sf_test.py, and start typing your scripts. + Next is a simple example that gets the numeric value from a Calc cell and increments it by 1. Simply type the following code into the sf_test.py file. + + from scriptforge import CreateScriptService + doc = CreateScriptService("Calc") + + def increment_cell(args=None): + value = doc.GetValue("A1") + value += 1 + doc.SetValue("A1", value) + + g_exportedScripts = (increment_cell, ) + + This example creates the increment_cell function. Note that g_exportedScripts is a tuple that tells which functions will be displayed in %PRODUCTNAME as user scripts. + To run this script from within a Calc document: + + + Create or open a Calc file. + + + Enter some numeric value into cell "A1" in the current sheet. + + + Go to Tools - Macros - Run Macros . + + + Choose My Macros - sf_test in the library selector. Then choose the increment_cell function under the Macro Name list. + + + Click Run. Note that the value in cell "A1" was incremented by 1. + + + You can also use APSO to run Python scripts in a similar manner: + + + First open APSO by going to Tools - Macros - Organize Python Scripts. + + + In the macro list, navigate to My Macros - sf_test - increment_cell. + + + Click Execute. + + + +

Running Scripts separately from the %PRODUCTNAME process

+
+

Determining the Installation Path

+ The first step to run scripts from a separate process is to find the folder where %PRODUCTNAME is installed. There are several ways to do that, but ScriptForge provides a quick way to identify your installation path. For that, open APSO's Python shell and type: + + from scriptforge import CreateScriptService + fs = CreateScriptService("FileSystem") + fs.FileNaming = "SYS" + inst_dir = fs.InstallFolder + print(inst_dir) + + The output from the code above is the base directory where %PRODUCTNAME is installed. Now you need to add the "program" subfolder to the resulting path. This is the base folder from which you will run Python scripts from a separate process. + For example, suppose you get /usr/lib/libreoffice/ as the result from running the Python code above. Then you need to consider /usr/lib/libreoffice/program as the path to run your Python scripts. +
+ +

Start %PRODUCTNAME with socket settings

+ To run Python scripts from a separate process, you need to start %PRODUCTNAME with a few additional options that specify the hostname and port through which the external process will communicate with the %PRODUCTNAME component process. + Open the your operating system's command prompt, navigate to the program folder of your %PRODUCTNAME installation directory and type: + ./soffice --accept='socket,host=localhost,port=2021;urp;' + The command above will start %PRODUCTNAME with a communication channel open so that other processes can exchange messages with it. + Note that the previous example opens %PRODUCTNAME start center. If you want to open a specific component, for instance Writer, you can add the --writer flag to the command, as follows. + ./soffice --writer --accept='socket,host=localhost,port=2021;urp;' + Take note of the host and port parameters, which in this example are localhost and 2021, respectively. + +

Running an External Python Shell

+ Start the Python shell from within the program folder inside your %PRODUCTNAME installation path. Follow the steps above to learn how to find your installation path. + On Linux / Mac OS: + $ cd /usr/lib/libreoffice/program + $ python + On Windows: + $ cd C:\Program Files\LibreOffice\program\ + $ python.exe + This will open the Python shell and now you can start typing commands that will be executed by %PRODUCTNAME. But first you need to set up the socket connection. + + from scriptforge import ScriptForge, CreateScriptService + ScriptForge(hostname='localhost', port=2021) + + The second line of code above defines the host and port settings so that the Python shell can communicate with an ongoing %PRODUCTNAME process opened with the same socket settings. + Now you can run other Python commands and they will be able to communicate with the %PRODUCTNAME process. For example: + + ui = CreateScriptService("UI") + bas = CreateScriptService("Basic") + doc = ui.OpenDocument("~/Documents/myFile.ods") + bas.MsgBox(doc.DocumentType) + + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_l10n.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_l10n.xhp new file mode 100644 index 000000000..453fe345a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_l10n.xhp @@ -0,0 +1,375 @@ + + + + + + + ScriptForge.L10N service + /text/sbasic/shared/03/sf_l10n.xhp + + + +
+ + L10N service + +
+ +
+

ScriptForge.L10N service

+ This service provides a number of methods related to the translation of strings with minimal impact on the program's source code. The methods provided by the L10N service can be used mainly to: + + + Create POT files that can be used as templates for translation of all strings in the program. + + + Get translated strings at runtime for the language defined in the Locale property. + + +
+ + The acronym L10N stands for Localization and refers to a set of procedures for translating software to a specific country or region. + PO files have long been promoted in the free software community as a means to providing multilingual user interfaces. This is accomplished through the use of human-readable text files with a well defined structure that specifies, for any given language, the source language string and the localized string. + The main advantage of the PO format is dissociation of the programmer and the translator. PO files are independent text files, so the programmer can send POT template files to translators, who will then translate their contents and return the translated PO files for each supported language. + The L10N service is based on the GNU implementation of PO (portable object) files. To learn more about this file format, visit GNU gettext Utilities: PO Files. + This service implements the methods listed below: + + + AddText: Used by the programmer to build a set of strings that will be translated later. + + + AddTextsFromDialog: Extracts all strings from a Dialog service instance. + + + ExportToPOTFile: Exports the strings added by the AddText method to a POT file. + + + GetText: Gets the translated strings at runtime. + + + Note that the first two methods are used to build a set of translatable strings and export them to a POT file. However, it is not mandatory to create POT files using these methods. Since they are text files, the programmer could have created them using any text editor. + +

Service invocation

+ Before using the L10N service the ScriptForge library needs to be loaded or imported: + + + There are several ways to invoke the L10N service using up to five optional arguments that specify the folder where PO files are stored, the locale and encoding to be used, as well as a fallback PO file and its encoding. + + + CreateScriptService("L10N", opt foldername: str, opt locale: str, encoding: str = "UTF-8", opt locale2: str, encoding2: str = "UTF-8"): svc + + foldername: The folder containing the PO files. It must be expressed in the FileSystem.FileNaming notation. + locale: A string in the form "la-CO" (language-COUNTRY) or in the form "la" (language) only. + encoding: The character set to be used. The default encoding is "UTF-8". + locale2: A string specifying the fallback locale to be used in case the PO file corresponding to the locale defined the locale parameter does not exist. This parameter is expressed in the form "la-CO" (language-COUNTRY) or "la" (language) only. + encoding2: The character set of the fallback PO file corresponding to the locale2 argument. The default encoding is "UTF-8". + To learn more about the names of character sets, visit IANA's Character Set page. Beware that %PRODUCTNAME does not implement all existing character sets. + + + The following example instantiates the L10N service without any optional arguments. This will only enable the AddText and ExportToPOTFile methods, which is useful for creating POT files. + + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + Dim myPO As Variant + Set myPO = CreateScriptService("L10N") + + The example below specifies the folder containing the PO files. Because the locale is not defined, the service instance will use the locale defined for the %PRODUCTNAME user interface, which is the same locale defined in the OfficeLocale property of the Platform service. + + Set myPO = CreateScriptService("L10N", "C:\myPOFiles") + + The example above will result in an runtime error if the PO file corresponding to the OfficeLocale locale does not exist in the specified folder. + In the example below, the locale is explicitly defined to be Belgian French ("fr-BE"), hence the service will load the file "fr-BE.po" from the folder "C:\myPOFiles". If the file does not exist, an error will occur. + + Set myPO = CreateScriptService("L10N", "C:\myPOFiles", "fr-BE", "UTF-8") + + To avoid errors, it is possible to specify a preferred and a fallback locale and encoding. The following example will first try to load the file "fr-BE.po" from the specified folder and if it does not exist, the file "en-US.po" will be loaded. + + Set myPO = CreateScriptService("L10N", "C:\myPOFiles", "fr-BE", "UTF-8", "en-US", "UTF-8") + + PO files must be named in the form "la-CO.po" or "la.po", where "la" refers to the language and "CO" is the country. Some examples are: "en-US.po", "fr-BE.po" or "fr.po". + It is recommended to free resources after use: + + Set myPO = myPO.Dispose() + + + The examples above can be translated to Python as follows: + + from scriptforge import CreateScriptService + myPO = CreateScriptService('L10N') + + + myPO = CreateScriptService('L10N', r'C:\myPOFiles') + + + myPO = CreateScriptService('L10N', r'C:\myPOFiles', 'fr-BE') + + + myPO = CreateScriptService('L10N', r'C:\myPOFiles', 'fr-BE', 'UTF-8', 'en-US', 'UTF-8') + myPO = myPO.Dispose() + + Several instances of the L10N service may coexist. However, each instance must use a separate directory for its PO files. + + + L10N service;Folder + L10N service;Languages + L10N service;Locale + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + Folder + + + Yes + + + String + + + The folder containing the PO files (see the FileSystem.FileNaming property to learn about the notation used). + + + + + Languages + + + Yes + + + Array + + + A zero-based array listing all the base names (without the ".po" extension) of the PO-files found in the specified Folder. + + + + + Locale + + + Yes + + + String + + + The currently active language-COUNTRY combination. This property will be initially empty if the service was instantiated without any of the optional arguments. + + +
+ + + + + List of Methods in the L10N Service + + + + + + AddText
+ AddTextsFromDialog +
+
+ + + ExportToPOTFile

+
+
+ + + GetText

+
+
+
+
+ + +
+ AddText ----------------------------------------------------------------------------------------------- + + L10N service;AddText + +

AddText

+ Adds a new entry in the list of localizable strings. It must not exist yet. + The method returns True if successful. + + + svc.AddText(context: str = '', msgid: str = '', comment: str = ''): bool + + + context: The key to retrieve the translated string with the GetText method. This parameter has a default value of "". + msgid: The untranslated string, which is the text appearing in the program code. It must not be empty. The msgid becomes the key to retrieve the translated string via GetText method when context is empty. + The msgid string may contain any number of placeholders (%1 %2 %3 ...) for dynamically modifying the string at runtime. + comment: Optional comment to be added alongside the string to help translators. + + The example below creates a set of strings in English: + + + myPO.AddText(, "This is a string to be included in a POT file") + myPO.AddText("CTX1", "A string with a context") + myPO.AddText(, "Provide a String value", Comment := "Do not translate the word String") + + + + myPO.AddText(msgid = 'This is a string to be included in a POT file') + myPO.AddText('CTX1', 'A string with a context') + myPO.AddText(msgid = 'Provide a String value', comment = 'Do not translate the word String') + +
+ +
+ AddTextsFromDialog ------------------------------------------------------------------------------------- + + L10N service;AddTextsFromDialog + +

AddTextsFromDialog

+ Automatically extracts strings from a dialog and adds them to the list of localizable text strings. The following strings are extracted: +
+ + + The title of the dialog. + + + The caption of the following control types: Button, CheckBox, FixedLine, FixedText, GroupBox and RadioButton. + + + Static strings in ListBoxes and ComboBoxes. + + + The tooltip or help text displayed when the mouse hovers over the control. + + +
+ The method returns True if successful. + The dialog from which strings will be extracted must not be open when the method is called. + When a L10N service instance is created from an existing PO file, use the GetTextsFromL10N method from the Dialog service to automatically load all translated strings into the dialog. + + + svc.AddTextsFromDialog(dialog: svc): bool + + + dialog: a Dialog service instance corresponding to the dialog from which strings will be extracted. + + The following example extracts all strings from the dialog "MyDialog" stored in the "Standard" library and exports them to a POT file: + + + oDlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "MyDialog") + myPO = CreateScriptService("L10N") + myPO.AddTextsFromDialog(oDlg) + myPO.ExportToPOTFile("en-US.pot") + + + + dlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "Dialog1") + myPO = CreateScriptService("L10N") + myPO.AddTextsFromDialog(dlg) + myPO.ExportToPOTFile("en-US.pot") + +
+ +
+ ExportToPOTFile --------------------------------------------------------------------------------------- + + L10N service;ExportToPOTFile + +

ExportToPOTFile

+ Exports a set of untranslated strings as a POT file. + To build a set of strings you can use either a succession of AddText method calls, or by a successful invocation of the L10N service with the foldername argument present. It is also possible to use a combination of both techniques. + The method returns True if successful. + + + svc.ExportToPOTFile(filename: str, header: str = '', encoding:str = 'UTF-8'): bool + + + filename: The output file in FileSystem.FileNaming notation. + header: Comments that will be added on top of the generated POT file. + Do not include any leading "#" characters. If you want the header to be broken into multiple lines, insert escape sequences (\n) where relevant. A standard header will be added alongside the text specified in the header argument. + encoding: The character set to be used (Default = "UTF-8"). + + + ' Basic + myPO.ExportToPOTFile("myFile.pot", Header := "First line of the header\nSecond line of the header") + + + # Python + myPO.ExportToPOTFile('myFile.pot', header = 'First line of the header\nSecond line of the header') + + The generated file should successfully pass the msgfmt --check GNU command. +
+ +
+ GetText ----------------------------------------------------------------------------------------------- + + L10N service;GetText + +

GetText

+ Gets the translated string corresponding to the given msgid argument. + A list of arguments may be specified to replace the placeholders (%1, %2, ...) in the string. + If no translated string is found, the method returns the untranslated string after replacing the placeholders with the specified arguments. + + This method can be called either by the full name GetText or by the shortcut _ (a single underscore): + + svc.GetText(msgid: str, args: any[0..*]): str + + + svc._(msgid: str, args: any[0..*]): str + + In the ScriptForge library, all methods starting with the "_" character are reserved for internal use only. However, the shortcut _ used for GetText is the only exception to this rule, hence it can be safely used in Basic and Python scripts. + + msgid: The untranslated string, which is the text appearing in the program code. It must not be empty. It may contain any number of placeholders (%1 %2 %3 ...) that can be used to dynamically insert text at runtime. + Besides using a single msgid string, this method also accepts the following formats: + + + The context string with which the method will retrieve the msgid in the PO file, or; + + + A combination context|msgid, instructing the method to retrieve the msgid using specified context value. The second part of the argument is used to improve code readability. + + + args: Values to be inserted into the placeholders. Any variable type is allowed, however only strings, numbers and dates will be considered. + + + Consider the following code is running on a %PRODUCTNAME installation with locale set to "es-ES". Additionally, there is a file "es-ES.po" inside the specified folder that translates the string passed to the GetText method: + + myPO = CreateScriptService("L10N", "C:\myPOFiles\") + myPO.GetText("Welcome %1! Hope you enjoy this program", "John") + ' "¡Bienvenido John! Espero que disfrutes de este programa" + + + + myPO = CreateScriptService('L10N', r"C:\myPOFiles") + myPO.GetText('Welcome %1! Hope you enjoy this program', 'John') + # "¡Bienvenido John! Espero que disfrutes de este programa" + +
+ + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_menu.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_menu.xhp new file mode 100644 index 000000000..162c63083 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_menu.xhp @@ -0,0 +1,324 @@ + + + + + + SFWidgets.Menu service + /text/sbasic/shared/03/sf_menu.xhp + + + +
+ + Menu service + +
+
+

SFWidgets.Menu service

+ The Menu service can be used to create and remove menus from the menubar of a %PRODUCTNAME document window. Each menu entry can be associated with a script or with a UNO command. This service provides the following capabilities: + + + Creation of menus with custom entries, checkboxes, radio buttons and separators. + + + Decoration of menu items with icons and tooltips. + + +
+ Menus created with this service are available only for a specified document window. They are not saved into the document or as application settings. Closing and opening the document will restore the default menubar settings. + When OLE objects such as Math formulas or Calc charts are edited from within a document, %PRODUCTNAME reconfigures the menubar according to the object. When this happens, the menus created with the Menu service are removed and are not be restored after editing the OLE object. + +

Service invocation

+ Before using the Menu service the ScriptForge library needs to be loaded or imported: + + + + The Menu service is instantiated by calling the CreateMenu method from the Document service. The code snippet below creates a menu named My Menu in the current document window with two entries Item A and Item B. + + Sub CreateMenu() + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + Dim oDoc as Object, oMenu as Object + Set oDoc = CreateScriptService("Document") + Set oMenu = oDoc.CreateMenu("My Menu") + With oMenu + .AddItem("Item A", Command := "About") + .AddItem("Item B", Script := "vnd.sun.star.script:Standard.Module1.ItemB_Listener?language=Basic&location=application") + .Dispose() + End With + End Sub + + After creating the menu, it is recommended to call the Dispose method to free the resources used by the Menu service instance. + In the example above, Item A is associated with the UNO command .uno:About whereas Item B is associated with the script ItemB_Listener defined in Module1 of the Standard library of the My Macros container. + The following example defines ItemB_Listener that will be called when Item B is clicked. This listener simply splits the argument string passed to the Sub and shows them in a message box. + + Sub ItemB_Listener(args As String) + ' Process the argument string passed to the listener + Dim sArgs as Object + sArgs = Split(args, ",") + MsgBox "Menu name: " & sArgs(0) & Chr(13) & _ + "Menu item: " & sArgs(1) & Chr(13) & _ + "Item ID: " & sArgs(2) & Chr(13) & _ + "Item status: " & sArgs(3) + End Sub + + As shown in the example above, menu entries associated with a script receive a comma-separated string argument with the following values: + + + The toplevel name of the menu. + + + The string ID of the selected menu entry. + + + The numeric ID of the selected menu entry. + + + The current state of the menu item. This is useful for checkboxes and radio buttons. If the item is checked, the value "1" is returned, otherwise "0" is returned. + + + + + The examples above can be written in Python as follows: + + from scriptforge import CreateScriptService + + def create_menu(args=None): + oDoc = CreateScriptService("Document") + oMenu = oDoc.CreateMenu("My Menu") + oMenu.AddItem("Item A", command="About") + oMenu.AddItem("Item B", script="vnd.sun.star.script:my_macros.py$item_b_listener?language=Python&location=user") + oMenu.Dispose() + + + def item_b_listener(args): + bas = CreateScriptService("Basic") + s_args = args.split(",") + msg = f"Menu name: {s_args[0]}\n" + msg += f"Menu item: {s_args[1]}\n" + msg += f"Item ID: {s_args[2]}\n" + msg += f"Item status: {s_args[3]}" + bas.MsgBox(msg) + + + + PopupService service;ShortcutCharacter + PopupService service;SubmenuCharacter + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + ShortcutCharacter + + + No + + + String + + + Character used to define the access key of a menu item. The default character is "~". + + + + + SubmenuCharacter + + + No + + + String + + + Character or string that defines how menu items are nested. The default character is ">". + + +
+ +

Menu and Submenus

+ To create a menu with submenus, use the character defined in the SubmenuCharacter property while creating the menu entry to define where it will be placed. For instance, consider the following menu/submenu hierarchy. + + ' Item A + ' Item B > Item B.1 + ' Item B.2 + ' ------ (line separator) + ' Item C > Item C.1 > Item C.1.1 + ' Item C.1.2 + ' Item C > Item C.2 > Item C.2.1 + ' Item C.2.2 + ' ------ (line separator) + ' Item C.2.3 + ' Item C.2.4 + + The code below uses the default submenu character ">" to create the menu/submenu hierarchy defined above: + + oMenu.AddItem("Item A") + oMenu.AddItem("Item B>Item B.1") + oMenu.AddItem("Item B>Item B.2") + oMenu.AddItem("---") + oMenu.AddItem("Item C>Item C.1>Item C.1.1") + oMenu.AddItem("Item C>Item C.1>Item C.1.2") + oMenu.AddItem("Item C>Item C.2>Item C.2.1") + oMenu.AddItem("Item C>Item C.2>Item C.2.2") + oMenu.AddItem("Item C>Item C.2>---") + oMenu.AddItem("Item C>Item C.2>Item C.2.3") + oMenu.AddItem("Item C>Item C.2>Item C.2.4") + + The string "---" is used to define line separators in menus or submenus. + + +

Methods

+ + + List of Methods in the Menu Service + + + + + AddCheckBox
+
+
+ + + AddItem
+
+
+ + + AddRadioButton
+
+
+
+
+ +
+ AddCheckBox ----------------------------------------------------------------------------------------- + + Menu service;AddCheckBox + +

AddCheckBox

+ Inserts a check box in the menu. Returns an integer value that identifies the inserted item. + + + svc.AddCheckBox(menuitem: str, opt name: str, opt status: bool, opt icon: str, opt tooltip: str, opt command: str, opt script: str): int + + + menuitem: Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character. + name: String value used to identify the menu item. By default, the last component of the menu hierarchy is used. + status: Defines whether the item is selected when the menu is created (Default = False). + icon: Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used. + tooltip: Text to be displayed as tooltip. + command: The name of a UNO command without the .uno: prefix. If the command name does not exist, nothing happens. + script: The URI for a Basic or Python script that will be executed when the item is clicked. + + + + + ' Menu entry associated with the .uno:Paste command + oMenu.AddCheckBox("Item A", Status := True, ToolTip := "Paste values", Command := "Paste") + ' Runs the Basic script Standard.Module1.MyListener stored in the document + oMenu.AddCheckBox("Item B", Status := False, Script := "vnd.sun.star.script:Standard.Module1.MyListener?language=Basic&location=document") + ' Runs the Python script MyListener located in file myScripts.py in the user scripts folder + oMenu.AddCheckBox("Item C", Status := True, Script := "vnd.sun.star.script:myScripts.py$MyListener?language=Python&location=user") + + + + oMenu.AddCheckBox("Item A", status=True, tooltip="Paste values", command="Paste") + oMenu.AddCheckBox("Item B", status=False, script="vnd.sun.star.script:Standard.Module1.MyListener?language=Basic&location=document") + oMenu.AddCheckBox("Item C", Status=True, Script="vnd.sun.star.script:myScripts.py$MyListener?language=Python&location=user") + +
+ +
+ AddItem ----------------------------------------------------------------------------------------- + + Menu service;AddItem + +

AddItem

+ Inserts a label entry in the menu. Returns an integer value that identifies the inserted item. + + + svc.AddItem(menuitem: str, opt name: str, opt icon: str, opt tooltip: str, opt command: str, opt script: str): int + + + menuitem: Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character. + name: String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used. + icon: Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used. + tooltip: Text to be displayed as tooltip. + command: The name of a UNO command without the .uno: prefix. If the command name does not exist, nothing happens. + script: The URI for a Basic or Python script that will be executed when the item is clicked. + + + + + oMenu.AddItem("Item A", Tooltip := "A descriptive message") + + + + oMenu.AddItem("Item A", tooltip = "A descriptive message") + +
+ +
+ AddRadioButton --------------------------------------------------------------------------------------- + + Menu service;AddRadioButton + +

AddRadioButton

+ Inserts a radio button entry in the menu. Returns an integer value that identifies the inserted item. + + + svc.AddRadioButton(menuitem: str, opt name: str, opt status: str, opt icon: str, opt tooltip: str, opt command: str, opt script: str): int + + + menuitem: Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character. + name: String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used. + status: Defines whether the item is selected when the menu is created (Default = False). + icon: Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used. + tooltip: Text to be displayed as tooltip. + command: The name of a UNO command without the .uno: prefix. If the command name does not exist, nothing happens. + script: The URI for a Basic or Python script that will be executed when the item is clicked. + + + + + oMenu.AddRadioButton("Item A", Name := "A", Status := True) + + + + oMenu.AddRadioButton("Item A", name="A", status=True) + +
+ + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_methods.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_methods.xhp new file mode 100644 index 000000000..219669b9f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_methods.xhp @@ -0,0 +1,211 @@ + + + + + + ScriptForge Method Signatures + /text/sbasic/shared/03/sf_methods.xhp + + + +

ScriptForge Method Signatures

+ + ScriptForge; Method signatures + + ScriptForge libraries aggregate macro scripting resources for %PRODUCTNAME to be invoked from Basic macros or Python scripts. Its modules and classes are invoked from user scripts as "Services" that expose properties, methods and events. + + + Whenever service methods are proposed solely for %PRODUCTNAME Basic, their syntax presentation matches that of Basic subroutines, functions or properties. + + + Whenever service methods are proposed for Python and Basic, or solely for Python, their syntax and arguments use a specific textual layout. + + + +

Basic only service method

+ Typographical characters such as brackets, ellipsis or curly braces denote optional, repetitive or compulsory arguments: + +

+ + FSO.HashFile(FileName As String, _ + Algorithm As String = {MD5|SHA1|SHA224|SHA256|SHA384|SHA512}) As String + SF_Array.ImportFromCSVFile(FileName As String, _ + [Delimiter = ","], [DateFormat As String]) As Variant + SF_String.SplitNotQuoted(InputStr As String, _ + [Delimiter As String], [Occurrences As Long], [QuoteChar As String]) As Variant + + +

Python or Basic service methods

+ The following typographical rules are mixing the UML notation, the API documentation layout and the UNO object inspector user interface: + + + Optional parameters are indicated with either opt, '=' accompanying a default value, or '[ ]' brackets. + + + arguments are lowercased, in order to comply with Python PEP 8 while Basic is case-agnostic. + + + Collections arguments or API sequences are denoted using UML multiplicity. That applies also to return values. + + + Basic data types and Python annotations are syntactically transposed as: + + + + + + %PRODUCTNAME
Basic
+
+ + Syntax + + + Python + +
+ + + Boolean + + + bool + + + bool + + + + + Date + + + datetime + + + datetime + + + + + Double + + + float + + + float + + + + + Integer + + + int + + + int + + + + + Long + + + int + + + int + + + + + Object + + + obj + + + + + + + + Single + + + float + + + float + + + + + String + + + str + + + str + + + + + Variant + + + any + + + + + + + + UNO Object + + + uno + + + + + + + + User Defined
Type (UDT)
+
+ + obj + + + + +
+ + + ScriptForge
service
+
+ + svc + + + + +
+
+

+ svc.Forms( opt form: any ): svc[0..*] + svc.MsgBox( prompt: str, buttons = svc.MB_OK , opt title: str ): opt str + svc.InputBox( prompt: str, default = "", [ title: str ], [ xpostwips: int, ypostwips: int ] ): str + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_platform.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_platform.xhp new file mode 100644 index 000000000..c9283925b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_platform.xhp @@ -0,0 +1,412 @@ + + + + + + ScriptForge.Platform service + /text/sbasic/shared/03/sf_platform.xhp + + + +
+ + Platform service + +
+
+

ScriptForge.Platform service

+ The Platform service provides a collection of properties about the current execution environment and context, such as: + + + The hardware platform (architecture, CPU count, machine type, etc) + + + Operating system information (OS type, release, version, etc) + + + The %PRODUCTNAME version + + + The current user name + + +
+ All properties of the Platform service are read-only. +

Service invocation

+ Before using the Platform service the ScriptForge library needs to be loaded or imported: + + + The examples below in Basic and Python instantiate the Platform service and access the Architecture property. + + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim platform As Variant + platform = CreateScriptService("Platform") + MsgBox platform.Architecture + + + + from scriptforge import CreateScriptService + svc = CreateScriptService("Platform") + bas = CreateScriptService("Basic") + bas.MsgBox(svc.Architecture) + + + Platform service;Architecture + Platform service;ComputerName + Platform service;CPUCount + Platform service;CurrentUser + Platform service;Extensions + Platform service;Fonts + Platform service;FormatLocale + Platform service;Locale + Platform service;Machine + Platform service;OfficeLocale + Platform service;OfficeVersion + Platform service;OSName + Platform service;OSPlatform + Platform service;OSRelease + Platform service;OSVersion + Platform service;Printers + Platform service;Processor + Platform service;PythonVersion + Platform service;SystemLocale + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + Architecture + + + Yes + + + String + + + The hardware bit architecture. Example: '32bit' or '64bit' + + + + + ComputerName + + + Yes + + + String + + + The computer's network name. + + + + + CPUCount + + + Yes + + + Integer + + + The number of central processing units. + + + + + CurrentUser + + + Yes + + + String + + + The name of the currently logged user. + + + + + Extensions + + + Yes + + + String array + + + Returns a zero-based array of strings containing the internal IDs of all installed extensions. + + + + + FilterNames + + + Yes + + + String array + + + Returns a zero-based unsorted array of strings containing the available document import and export filter names. + + + + + Fonts + + + Yes + + + String array + + + Returns a zero-based array of strings containing the names of all available fonts. + + + + + FormatLocale + + + Yes + + + String + + + Returns the locale used for numbers and dates as a string in the format "la-CO" (language-COUNTRY). + + + + + Locale + + + Yes + + + String + + + Returns the locale of the operating system as a string in the format "la-CO" (language-COUNTRY). This is equivalent to the SystemLocale property. + + + + + Machine + + + Yes + + + String + + + The machine type. Examples are: 'i386' or 'x86_64'. + + + + + OfficeLocale + + + Yes + + + String + + + Returns the locale of the user interface as a string in the format "la-CO" (language-COUNTRY). + + + + + OfficeVersion + + + Yes + + + String + + + The actual %PRODUCTNAME version expressed as
' %PRODUCTNAME w.x.y.z (The Document Foundation)'.
+ Example: 'LibreOffice 7.4.1.2 (The Document Foundation, Debian and Ubuntu)' +
+
+ + + OSName + + + Yes + + + String + + + The operating system type. Example: 'Darwin, Linux' or 'Windows'. + + + + + OSPlatform + + + Yes + + + String + + + A single string identifying the underlying platform with as much useful and human-readable information as possible. + Example: 'Linux-5.8.0-44-generic-x86_64-with-glibc2.32' + + + + + OSRelease + + + Yes + + + String + + + The operating system's release. Example: '5.8.0-44-generic' + + + + + OSVersion + + + Yes + + + String + + + The operating system's build or version. + Example: '#50-Ubuntu SMP Tue Feb 9 06:29:41 UTC 2021' + + + + + Printers + + + Yes + + + String
array
+
+ + The list of available printers as a zero-based array. + The default printer is put in the first position of the list (index = 0). + +
+ + + Processor + + + Yes + + + String + + + The real processor name. Example: 'amdk6'. + This property may return the same value as the Machine property. + + + + + PythonVersion + + + Yes + + + String + + + Returns the version of the Python interpreter being used as a string in the format "Python major.minor.patchlevel" (ex: "Python 3.9.7"). + + + + + SystemLocale + + + Yes + + + String + + + Returns the locale of the operating system as a string in the format "la-CO" (language-COUNTRY). This is equivalent to the Locale property. + + +
+ + The following examples in Basic and Python illustrate how to use the Fonts property to write the names of all available fonts to the current Calc sheet starting at cell "A1": + + + Dim oDoc as Object + Dim allFonts as Object + Dim svcPlatform as Object + Set oDoc = CreateScriptService("Calc") + Set svcPlatform = CreateScriptService("Platform") + allFonts = svcPlatform.Fonts + oDoc.setArray("~.A1", allFonts) + + + + from scriptforge import CreateScriptService + svc_platform = CreateScriptService("Platform") + doc = CreateScriptService("Calc") + all_fonts = svc_platform.Fonts + doc.setArray("~.A1", all_fonts) + + +
+ + Platform information with INFO("system") Calc formula + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_popupmenu.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_popupmenu.xhp new file mode 100644 index 000000000..b36ebbda3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_popupmenu.xhp @@ -0,0 +1,348 @@ + + + + + + + SFWidgets.PopupMenu service + /text/sbasic/shared/03/sf_popupmenu.xhp + + + +
+ + PopupMenu service + +
+
+

SFWidgets.PopupMenu service

+ The PopupMenu service can be used to create popup menus that can be associated with events or executed by scripts. This service provides the following capabilities: + + + Creation of popup menus with custom entries, checkboxes and radio buttons. + + + Decoration of menu items with icons and tooltips. + + +
+ +

Service invocation

+ Before using the PopupMenu service the ScriptForge library needs to be loaded or imported: + + + + The PopupMenu service can be instantiated in multiple ways. The example below creates a popup menu without associating it with a mouse or application event. + + Sub ShowPopup + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + Dim myPopup As Object + Set myPopup = CreateScriptService("SFWidgets.PopupMenu", , 300, 300) + myPopup.AddItem("Item ~A") + myPopup.AddItem("Item ~B") + vResponse = myPopup.Execute() + MsgBox("Selected item ID: " & vResponse) + myPopup.Dispose() + End Sub + + Running the Sub defined above will create a popup menu with two entries in the position X=300 and Y=300 on the screen. + The prefix SFWidgets can be suppressed while invoking the PopupMenu service. + The following example defines a Sub that can be associated with a mouse event: + + Sub MyPopupClick(Optional poMouseEvent as Object) + Dim myPopup As Object + Set myPopup = CreateScriptService("PopupMenu", poMouseEvent) + ' Populate popupmenu with items + Dim vResponse As Variant + vResponse = myPopup.Execute(False) + ' Do something based on vResponse + ' ... + myPopup.Dispose() + End Sub + + Use the Dispose method to free resources after executing the popup menu. + It is also possible to associate a popup menu with events triggered by %PRODUCTNAME applications, form and dialog controls. Events such as "Mouse button pressed" and "Mouse button released" are commonly associated with popup menus. + + Sub MyPopupClick(Optional poEvent as Object) + Dim myPopup As Object + Set myPopup = CreateScriptService("PopupMenu", poEvent) + ' ... + End Sub + + + + The examples above can be written in Python as follows: + + from scriptforge import CreateScriptService + + def show_popup(args=None): + my_popup = CreateScriptService("SFWidgets.PopupMenu", None, 300, 300) + bas = CreateScriptService("Basic") + my_popup.AddItem("Item ~A") + my_popup.AddItem("Item ~B") + response = my_popup.Execute() + bas.MsgBox(f"Selected item ID: {response}") + my_popup.Dispose() + + + def my_popup_click(poEvent=None): + my_popup = CreateScriptService("SFWidgets.PopupMenu", poEvent) + # Populate popupmenu with items + response = my_popup.Execute() + # Do something based on response + my_popup.Dispose() + + + + PopupService service;ShortcutCharacter + PopupService service;SubmenuCharacter + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + ShortcutCharacter + + + No + + + String + + + Character used to define the access key of a menu item. The default character is "~". + + + + + SubmenuCharacter + + + No + + + String + + + Character or string that defines how menu items are nested. The default character is ">". + + +
+ +

Menu and Submenus

+ To create a popup menu with submenus, use the character defined in the SubmenuCharacter property while creating the menu entry to define where it will be placed. For instance, consider the following menu/submenu hierarchy. + + ' Item A + ' Item B > Item B.1 + ' Item B.2 + ' ------ (line separator) + ' Item C > Item C.1 > Item C.1.1 + ' Item C.1.2 + ' Item C > Item C.2 > Item C.2.1 + ' Item C.2.2 + ' ------ (line separator) + ' Item C.2.3 + ' Item C.2.4 + + The code below uses the default submenu character ">" to create the menu/submenu hierarchy defined above: + + myPopup.AddItem("Item A") + myPopup.AddItem("Item B>Item B.1") + myPopup.AddItem("Item B>Item B.2") + myPopup.AddItem("---") + myPopup.AddItem("Item C>Item C.1>Item C.1.1") + myPopup.AddItem("Item C>Item C.1>Item C.1.2") + myPopup.AddItem("Item C>Item C.2>Item C.2.1") + myPopup.AddItem("Item C>Item C.2>Item C.2.2") + myPopup.AddItem("Item C>Item C.2>---") + myPopup.AddItem("Item C>Item C.2>Item C.2.3") + myPopup.AddItem("Item C>Item C.2>Item C.2.4") + + The string "---" is used to define line separators in menus or submenus.. +
+

Using icons

+ Items in the menu can have icons, which are specified as arguments in the AddCheckBox, AddItem and AddRadioButton methods. + All icons available in %PRODUCTNAME can be used by specifying their path relative to the folder where icon files are located in the installation folder. Icons are located in the following folder: + INSTALLDIR/share/config + Use the InstallFolder property of the FileSystem service to determine where %PRODUCTNAME is installed in your system. + This folder contains a series of ZIP files containing the image files of each available icon set. The images inside these ZIP files are organized into folders. To use an icon, specify the icon file with the path to its location inside the ZIP file. + The example below uses the icon "sc_newdoc.svg" that is located inside the "cmd" folder. The forward slash "/" character is used as the path separator regardless of the operating system. + + + myMenu.AddItem("Item A", Icon := "cmd/sc_newdoc.svg") + + + + myMenu.AddItem("Item A", icon="cmd/sc_newdoc.svg") + + All icon sets have the same internal structure. The actual icon displayed depends on the icon set currently in use. +
+ +

Methods

+ + + List of Methods in the PopupMenu Service + + + + + AddCheckBox
+ AddItem +
+
+ + + AddRadioButton

+
+
+ + + Execute

+
+
+
+
+ +
+ AddCheckBox ----------------------------------------------------------------------------------------- + + PopupMenu service;AddCheckBox + +

AddCheckBox

+ Inserts a check box in the popup menu. Returns an integer value that identifies the inserted item. + + + svc.AddCheckBox(menuitem: str, opt name: str, opt status: bool = False, opt icon: str, opt tooltip: str): int + + + menuitem: Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character. + name: String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used. + status: Defines whether the item is selected when the menu is created (Default = False). + icon: Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used. + tooltip: Text to be displayed as tooltip. + + + + myPopup.AddCheckBox("Option A", Status := True) + + + + my_popup.AddCheckBox("Option A", status=True) + +
+ +
+ AddItem ----------------------------------------------------------------------------------------- + + PopupMenu service;AddItem + +

AddItem

+ Inserts a menu entry in the popup menu. Returns an integer value that identifies the inserted item. + + + svc.AddItem(menuitem: str, opt name: str, opt icon: str, opt tooltip: str): int + + + menuitem: Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character. + name: String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used. + icon: Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used. + tooltip: Text to be displayed as tooltip. + + + + myPopup.AddItem("Item A", Tooltip := "A descriptive message") + + + + my_popup.AddItem("Item A", tooltip = "A descriptive message") + +
+ +
+ AddRadioButton --------------------------------------------------------------------------------------- + + PopupMenu service;AddRadioButton + +

AddRadioButton

+ Inserts a radio button entry in the popup menu. Returns an integer value that identifies the inserted item. + + + svc.AddRadioButton(menuitem: str, opt name: str, opt status: bool = False, opt icon: str, opt tooltip: str): int + + + menuitem: Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character. + name: String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used. + status: Defines whether the item is selected when the menu is created (Default = False). + icon: Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used. + tooltip: Text to be displayed as tooltip. + + + + myPopup.AddRadioButton("Option A", Name := "A", Status := True) + + + + my_popup.AddRadioButton("Option A", name="A", status=True) + +
+ +
+ Execute --------------------------------------------------------------------------------------- + + PopupMenu service;Execute + +

Execute

+ Displays the popup menu and waits for a user action. Returns the item clicked by the user. + If the user clicks outside the popup menu or presses the Esc key, then no item is selected. In such cases, the returned value depends on the returnid parameter. If returnid = True and no item is selected, then the value 0 (zero) is returned. Otherwise an empty string "" is returned. + + + svc.Execute(opt returnid: bool = True): any + + + returnid: If True the selected item ID is returned. If False the method returns the item's name (Default = True). + + In the examples below, a popup menu is created and the item's name is returned because the returnid argument is set to False. + + + myPopup.AddItem("Item A", Name := "A") + myPopup.AddItem("Item B", Name := "B") + Dim vResponse as Variant + vResponse = myPopup.Execute(False) + + + + my_popup.AddItem("Item A", name="A") + my_popup.AddItem("Item B", name="B") + response = my_popup.Execute(False) + +
+ + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_region.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_region.xhp new file mode 100644 index 000000000..2fee97f17 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_region.xhp @@ -0,0 +1,605 @@ + + + + + + ScriptForge.Region service + /text/sbasic/shared/03/sf_region.xhp + + + +
+ + Region service + +
+
+

ScriptForge.Region service

+ The Region service provides a collection of properties and methods to handle locale and region-related aspects of programming, such as: + + + Accessing locale and region-dependent settings such as number formatting, currency and timezones. + + + Converting timezones and calculate Daylight Saving Time (DST) offsets. + + + Transforming numbers into text in any supported language. + + +
+ +

Definitions

+

Locale or Region

+ A string combining a language and a country in the format "la-CO". The language part is expressed with 2 or 3 lowercase characters followed by a dash and 2 uppercase characters representing the country. + For instance, "en-US" corresponds to the English language in the United States; "fr-BE" corresponds to the French language in Belgium, and so forth. + On some situations the full locale is not required and only the language or country may be specified. + Most properties and methods accept a locale as argument. If no locale is specified, then the user-interface locale is used, which is defined in the OfficeLocale property of the Platform service. +

Timezone

+ A string in the format "Region/City" such as "Europe/Berlin", or a timezone ID such as "UTC" or "GMT-8:00". Refer to the wiki page List of tz database and timezones for a list of possible timezone names and IDs. + Providing an invalid timezone string to any of the methods in the Region service will not result in a runtime error. Instead, methods as UTCDateTime and UTCNow will return the current operating system date and time. + The time offset between the timezone and the Greenwich Meridian Time (GMT) is expressed in minutes. + The Daylight Saving Time (DST) is an additional offset. + The timezone and DST offsets may be positive or negative. + +

Service invocation

+ Before using the Region service the ScriptForge library needs to be loaded or imported: + + The examples below in Basic and Python instantiate the Region service and access the Country property. + + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim oRegion As Variant + oRegion = CreateScriptService("Region") + MsgBox oRegion.Country("en-US") ' United States + + + + from scriptforge import CreateScriptService + oRregion = CreateScriptService("Region") + bas = CreateScriptService("Basic") + bas.MsgBox(oRegion.Country("en-US")) + + + + Region service;Country + Region service;Currency + Region service;DatePatterns + Region service;DateSeparator + Region service;DayAbbrevNames + Region service;DayNames + Region service;DayNarrowNames + Region service;DecimalPoint + Region service;Language + Region service;ListSeparator + Region service;MonthAbbrevNames + Region service;MonthNames + Region service;MonthNarrowNames + Region service;ThousandSeparator + Region service;TimeSeparator + + +

Properties

+ All properties listed below accept a locale argument, provided as a string. Some properties require this argument to be in the format "la-CO", whereas others may receive "la" or "CO" as input. + + + + + Name + + + Readonly + + + Type + + + Locale + + + Description + + + + + Country + + + Yes + + + String + + + "la‑CO"
"CO"
+
+ + Returns the country name in English corresponding to a given region. + +
+ + + Currency + + + Yes + + + String + + + "la-CO"
"CO"
+
+ + Returns the ISO 4217 currency code of the specified region. + +
+ + + DatePatterns + + + Yes + + + String array + + + "la-CO" + + + Returns a zero-based array of strings containing the date acceptance patterns for the specified region. + + + + + DateSeparator + + + Yes + + + String + + + "la-CO" + + + Returns the date separator used in the given region. + + + + + DayAbbrevNames + + + Yes + + + String array + + + "la-CO"
"la"
+
+ + Returns a zero-based array of strings containing the list of abbreviated weekday names in the specified language. + +
+ + + DayNames + + + Yes + + + String array + + + "la-CO"
"la"
+
+ + Returns a zero-based array of strings containing the list of weekday names in the specified language. + +
+ + + DayNarrowNames + + + Yes + + + String array + + + "la-CO"
"la"
+
+ + Returns a zero-based array of strings containing the list of the initials of weekday names in the specified language. + +
+ + + DecimalPoint + + + Yes + + + String + + + "la-CO" + + + Returns the decimal separator used in numbers in the specified region. + + + + + Language + + + Yes + + + String + + + "la-CO"
"la"
+
+ + Returns the name of the language, in English, of the specified region. + +
+ + + ListSeparator + + + Yes + + + String + + + "la-CO" + + + Returns the list separator used in the specified region. + + + + + MonthAbbrevNames + + + Yes + + + String array + + + "la-CO"
"la"
+
+ + Returns a zero-based array of strings containing the list of abbreviated month names in the specified language. + +
+ + + MonthNames + + + Yes + + + String array + + + "la-CO"
"la"
+
+ + Returns a zero-based array of strings containing the list of month names in the specified language. + +
+ + + MonthNarrowNames + + + Yes + + + String array + + + "la-CO"
"la"
+
+ + Returns a zero-based array of strings containing the list of the initials of month names in the specified language. + +
+ + + ThousandSeparator + + + Yes + + + String + + + "la-CO" + + + Returns the thousands separator used in numbers in the specified region. + + + + + TimeSeparator + + + Yes + + + String + + + "la-CO" + + + Returns the separator used to format times in the specified region. + + +
+ + + + List of Methods in the Region Service + + + + + DSTOffset
+ LocalDateTime
+
+
+ + + Number2Text
+ TimeZoneOffset
+
+
+ + + UTCDateTime
+ UTCNow
+
+
+
+
+ +
+ DSTOffset ---------------------------------------------------------------------------------------------- + + Region service;DSTOffset + +

DSTOffset

+ Computes the additional Daylight Saving Time (DST) offset, in minutes, that is applicable to a given region and timezone. + + + svc.DSTOffset(localdatetime: date, timezone: str, opt locale: str): int + + + localdatetime: the local date and time expressed as a date. + timezone: the timezone for which the offset will be calculated. + locale: the locale specifying the country for which the offset will be calculated, given either in "la-CO" or "CO" formats. The default value is the locale defined in the OfficeLocale property of the Platform service. + + + + ' Calculates the offset applicable in the "America/Los_Angeles" timezone + Dim aDateTime As Date, offset As Integer + aDateTime = DateSerial(2022, 7, 1) + TimeSerial(16, 0, 0) + offset = oRegion.DSTOffset(aDateTime, "America/Los_Angeles", "US") ' 60 (minutes) + aDateTime = DateSerial(2022, 1, 1) + TimeSerial(16, 0, 0) + offset = oRegion.DSTOffset(aDateTime, "America/Los_Angeles", "US") ' 0 (minutes) + + + + import datetime + aDateTime = datetime.datetime(2022, 7, 1, 16, 0, 0) + offset = oRegion.DSTOffset(aDateTime, "America/Los_Angeles", "US") ' 60 (minutes) + aDateTime = datetime.datetime(2022, 1, 1, 16, 0, 0) + offset = oRegion.DSTOffset(aDateTime, "America/Los_Angeles", "US") ' 0 (minutes) + +
+ +
+ LocalDateTime ------------------------------------------------------------------------------------------ + + Region service;LocalDateTime + +

LocalDateTime

+ Computes the local date and time from a UTC date and time. + + + svc.LocalDateTime(utcdatetime: date, timezone: str, opt locale: str): date + + + utcdatetime: the UTC date and time, expressed using a date object. + timezone: the timezone for which the local time will be calculated. + locale: the locale specifying the country for which the local time will be calculated, given either in "la-CO" or "CO" formats. The default value is the locale defined in the OfficeLocale property of the Platform service. + + + + ' June 6th, 2022 at 10:30:45 (used here as UTC time) + Dim UTCTime As Date, localTime As Date + UTCTime = DateSerial(2022, 6, 23) + TimeSerial(10, 30, 45) + ' Calculates local time in Sao Paulo, Brazil + ' June 6th, 2022 at 07:30:45 + localTime = oRegion.LocalDateTime(UTCTime, "America/Sao_Paulo", "BR") + + + + import datetime + utcTime = datetime.datetime(2022, 6, 23, 10, 30, 45) + localTime = oRegion.LocalDateTime(utcTime, "America/Sao_Paulo", "BR") + +
+ +
+ Number2Text ------------------------------------------------------------------------------------------- + + Region service;Number2Text + +

Number2Text

+ Converts numbers and monetary values into written text for any of the currently supported languages. + For a list of all supported languages visit the XNumberText Interface API reference. + + + svc.Number2Text(number: any, opt locale: str): str + + + number: the number to be converted into written text. It can be provided either as a numeric type or as a string. When a string is provided, it can be preceded by a prefix informing how the numbers should be written. It is also possible to include ISO 4217 currency codes. See examples below for more information. + locale: the locale defining the language into which the number will be converted to, given either in "la-CO" or "la" formats. The default value is the locale defined in the OfficeLocale property of the Platform service. + + + + ' Returns "one hundred five" + Dim numText As String + numText = oRegion.Number2Text(105, "en-US") + ' Returns: "two point four two" + numText = oRegion.Number2Text(2.42, "en-US") + ' Returns: "twenty-five euro and ten cents" Notice the "EUR" currency symbol + numText = oRegion.Number2Text("EUR 25.10", "en-US") + ' Returns: "fifteenth"; Notice the "ordinal" prefix + numText = oRegion.Number2Text("ordinal 15", "en-US") + + + + numText = oRegion.Number2Text(105, "en-US") + numText = oRegion.Number2Text(2.42, "en-US") + numText = oRegion.Number2Text("EUR 25.10", "en-US") + numText = oRegion.Number2Text("ordinal 15", "en-US") + + To get a list of all supported prefixes in a given language, call Number2Text with the special "help" argument, as shown in the example below: + + prefixes = oRegion.Number2Text("help") + MsgBox prefixes + ' Considering the "en-US" locale the message box will show the following text + ' one, two, three + ' ordinal: first, second, third + ' ordinal-number: 1st, 2nd, 3rd + ' year: nineteen ninety-nine, two thousand, two thousand one + ' currency (for example, USD): two U.S. dollars and fifty cents + ' money USD: two and 50/100 U.S. dollars + + The first line in the message box does not have a prefix, which means that it is the standard format. The subsequent lines include the prefix and some examples of numbers using its format. + Each language has its own set of supported prefixes. +
+ +
+ TimeZoneOffset ----------------------------------------------------------------------------------------- + + Region service;TimeZoneOffset + +

TimeZoneOffset

+ Returns the offset between GMT and the given timezone and locale, in minutes. + + + svc.TimeZoneOffset(timezone: str, opt locale: str): int + + + timezone: the timezone for which the offset to the GMT will be calculated. + locale: the locale specifying the country for which the offset will be calculated, given either in "la-CO" or "CO" formats. The default value is the locale defined in the OfficeLocale property of the Platform service. + + + + Dim offset As Integer + offset = oRegion.TimeZoneOffset("America/New_York", "US") ' -300 + offset = oRegion.TimeZoneOffset("Europe/Berlin", "DE") ' 60 + + + + offset = oRegion.TimeZoneOffset("America/New_York", "US") # -300 + offset = oRegion.TimeZoneOffset("Europe/Berlin", "DE") # 60 + +
+ +
+ UTCDateTime ----------------------------------------------------------------------------------------- + + Region service;UTCDateTime + +

UTCDateTime

+ Returns the UTC date and time considering a given local date and time in a timezone. + + + svc.UTCDateTime(localdatetime: date, timezone: str, opt locale: str): date + + + localdatetime: the local date and time in a specific timezone expressed as a date. + timezone: the timezone for which the localdatetime argument was given. + locale: the locale specifying the country for which the localdatetime argument was given, expressed either in "la-CO" or "CO" formats. The default value is the locale defined in the OfficeLocale property of the Platform service. + + + + ' Date/Time in Berlin, June 23, 2022 at 14:30:00 + Dim localDT As Date, utcTime As Date + localDT = DateSerial(2022, 6, 23) + TimeSerial(14, 30, 0) + ' The UTC date/time is June 23, 2022 at 12:30:00 + utcTime = oRegion.UTCDateTime(localDT, "Europe/Berlin", "DE") + + + + import datetime + localDT = datetime.datetime(2022, 6, 23, 14, 30, 0) + utcTime = oRegion.UTCDateTime(localDT, "Europe/Berlin", "DE") + +
+ +
+ UTCNow ----------------------------------------------------------------------------------------- + + Region service;UTCNow + +

UTCNow

+ Returns the current UTC date and time, given a timezone and locale. + This method uses the current date and time of your operating system to calculate the UTC time. + + + svc.UTCNow(timezone: str, opt locale: str): date + + + timezone: the timezone for which the current UTC time will be calculated. + locale: the locale specifying the country for which the current UTC time will be calculated, given either in "la-CO" or "CO" formats. The default value is the locale defined in the OfficeLocale property of the Platform service. + + + + ' Suppose the operating system time is June 23rd, 2022 at 10:42:00 + ' If the computer is in Europe/Berlin, then UTC time is June 23rd, 2022 at 08:42:00 + Dim utcTime As Date + utcTime = oRegion.UTCNow("Europe/Berlin", "DE") + + + + utcTime = oRegion.UTCNow("Europe/Berlin", "DE") + +
+ +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_services.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_services.xhp new file mode 100644 index 000000000..e8462b426 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_services.xhp @@ -0,0 +1,107 @@ + + + + + + + ScriptForge.Services service + /text/sbasic/shared/03/sf_services.xhp + + + +
+ + Services service + +

ScriptForge.Services service

+ The main purpose of the Services module is to provide access to the CreateScriptService method, which can be called in user scripts to instantiate services that are implemented using the ScriptForge framework. +
+In ScriptForge terminology a service is a collection of methods and properties that can be used for a common purpose. For example, the String service provides methods for manipulating strings whereas the FileSystem service allows for the manipulation of files and folders. +The Services module of the ScriptForge library provides additional methods that are used either internally to register available services or by developers who are interested in extending ScriptForge by creating new services. The only method that is relevant for user scripts is CreateScriptService. + +
+ CreateScriptService ----------------------------------------------------------------------------------- + + Services service;CreateScriptService + +

CreateScriptService

+ This method is used to instantiate a ScriptForge service so it can be called in user scripts. + The returned value is a Basic object or Nothing if an error occurred. + + + svc.CreateScriptService(service: str, [arg0: any] ...): svc + + + service: The name of the service identified as a string in the format "library.service": + + + The library is a Basic library that must exist in the GlobalScope. The default value is "ScriptForge". + + + The service is one of the services registered by the ScriptForge library. + + + arg0, ...: A list of arguments required by the invoked service. + If the first argument refers to an event manager, then arg0 is mandatory and must be the UNO object representing the event provided as argument to the user macro. + + + + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + ' To be done once + Dim svc As Object + Set svc = CreateScriptService("Array") + ' Refers to the "ScriptForge.Array" service or SF_Array + Set svc = CreateScriptService("ScriptForge.Dictionary") + ' Returns a new empty dictionary class instance; "ScriptForge." is optional + Set svc = CreateScriptService("SFDocuments.Calc") + ' Refers to the Calc service, implemented in the associated SFDocuments library + Set svc = CreateScriptService("Timer", True) + ' Returns a Timer class instance starting immediately + Set svc = CreateScriptService("SFDocuments.DocumentEvent", oEvent) + ' Refers to the DocumentEvent service implemented in the associated SFDocuments library + ' Returns the instance of the Document class that fired the event + + + + from scriptforge import CreateScriptService + svc = CreateScriptService("Array") + svc = CreateScriptService("ScriptForge.Dictionary") + svc = CreateScriptService("SFDocuments.Calc") + svc = CreateScriptService("Timer", True) + svc = CreateScriptService("SFDocuments.DocumentEvent", oEvent) + + Python scripts support keyword arguments when calling CreateScriptService. The following example illustrates this concept by instantiating the Timer and Document services using keyword arguments. + + from scriptforge import CreateScriptService + # Timer + my_timer = CreateScriptService("Timer", start = True) + # Document + my_doc = CreateScriptService("Document", windowname = "some_file.ods") + + To make writing Python scripts more fluid, ScriptForge provides the Basic service which allows Python scripts to call a collection of methods with the same syntax and meaning as their homonymous native Basic functions. + The following example instantiates the Basic service and calls the MsgBox method, which is equivalent to the MsgBox function available in Basic: + + from scriptforge import CreateScriptService + bas = CreateScriptService("Basic") + bas.MsgBox("Hello World!") + + Beware that the Basic service has to be instantiated in Python scripts using the CreateScriptService method. +
+ + + +
+ + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_session.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_session.xhp new file mode 100644 index 000000000..ff4124323 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_session.xhp @@ -0,0 +1,693 @@ + + + + + + + ScriptForge.Session service + /text/sbasic/shared/03/sf_session.xhp + + + +
+ + Session service + +

ScriptForge.Session service

+ The Session service gathers various general-purpose methods about: + + + the installation or execution environment + + + UNO introspection + + + the invocation of external scripts or programs + + +
+ +

Service invocation

+ Before using the Session service the ScriptForge library needs to be loaded or imported: + + + + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim session As Variant + session = CreateScriptService("Session") + + + + from scriptforge import CreateScriptService + session = CreateScriptService("Session") + +

Constants

+ Below is a list of constants available to ease the designation of the library containing a Basic or Python script to invoke. Use them as session.CONSTANT. +
+ + + + CONSTANT + + + Value + + + Where to find the library? + + + Applicable + + + + + SCRIPTISEMBEDDED + + + "document" + + + in the document + + + Basic + Python + + + + + SCRIPTISAPPLICATION + + + "application" + + + in any shared library + + + Basic + + + + + SCRIPTISPERSONAL + + + "user" + + + in My Macros + + + Python + + + + + SCRIPTISPERSOXT + + + "user:uno_packages" + + + in an extension installed for the current user + + + Python + + + + + SCRIPTISSHARED + + + "share" + + + in %PRODUCTNAME macros + + + Python + + + + + SCRIPTISSHAROXT + + + "share:uno_packages" + + + in an extension installed for all users + + + Python + + + + + SCRIPTISOXT + + + "uno_packages" + + + in an extension but the installation parameters are unknown + + + Python + + +
+
+ + + + List of Methods in the Session Service + + + + + ExecuteBasicScript
+ ExecuteCalcFunction
+ ExecutePythonScript
+ GetPDFExportOptions
+ HasUnoMethod
+
+
+ + + HasUnoProperty
+ OpenURLInBrowser
+ RunApplication
+ SendMail
+ SetPDFExportOptions
+
+
+ + + UnoMethods
+ UnoProperties
+ UnoObjectType
+ WebService

+
+
+
+
+ + Execute... methods in Session service behave as follows: +
Arguments are passed by value. Changes made by the called function to the arguments do not update their values in the calling script. +
A single value or an array of values is returned to the calling script. +
+ +
+ ExecuteBasicScript ------------------------------------------------------------------------------------- + + Session service;ExecuteBasicScript + +

ExecuteBasicScript

+ Execute the Basic script given its name and location and fetch its result if any. + If the script returns nothing, which is the case of procedures defined with Sub, the returned value is Empty. + + + session.ExecuteBasicScript(scope: str, script: str, args: any[0..*]): any + + + scope: String specifying where the script is stored. It can be either "document" (constant session.SCRIPTISEMBEDDED) or "application" (constant session.SCRIPTISAPPLICATION). + script: String specifying the script to be called in the format "library.module.method" as a case-sensitive string. + + + The library is loaded in memory if necessary. + + + The module must not be a class module. + + + The method may be a Sub or a Function. + + + args: The arguments to be passed to the called script. + + Consider the following Basic function named DummyFunction that is stored in "My Macros" in the "Standard" library inside a module named "Module1". + The function simply takes in two integer values v1 and v2 and return the sum of all values starting in v1 and ending in v2. + + Function DummyFunction(v1 as Integer, v2 as Integer) As Long + Dim result as Long, i as Integer + For i = v1 To v2 + result = result + i + Next i + DummyFunction = result + End Function + + The examples below show how to call DummyFunction from within Basic and Python scripts. + + + Dim session : session = CreateScriptService("Session") + Dim b_script as String, result as Long + b_script = "Standard.Module1.DummyFunction" + result = session.ExecuteBasicScript("application", b_script, 1, 10) + MsgBox result ' 55 + + + + session = CreateScriptService("Session") + bas = CreateScriptService("Basic") + b_script = 'Standard.Module1.DummyFunction' + result = session.ExecuteBasicScript('application', b_script, 1, 10) + bas.MsgBox(result) # 55 + +
+ +
+ ExecuteCalcFunction ------------------------------------------------------------------------------------ + + Session service;ExecuteCalcFunction + +

ExecuteCalcFunction

+ Execute a Calc function using its English name and based on the given arguments. +
If the arguments are arrays, the function is executed as an array formula.
+ + + session.ExecuteCalcFunction(calcfunction: str, args: any[0..*]): any + + + calcfunction: The name of the Calc function to be called, in English. + args: The arguments to be passed to the called Calc function. Each argument must be either a string, a numeric value or an array of arrays combining those types. + + + + session.ExecuteCalcFunction("AVERAGE", 1, 5, 3, 7) ' 4 + session.ExecuteCalcFunction("ABS", Array(Array(-1, 2, 3), Array(4, -5, 6), Array(7, 8, -9)))(2)(2) ' 9 + session.ExecuteCalcFunction("LN", -3) + ' Generates an error. + + + + session.ExecuteCalcFunction("AVERAGE", 1, 5, 3, 7) # 4 + session.ExecuteCalcFunction("ABS", ((-1, 2, 3), (4, -5, 6), (7, 8, -9)))[2][2] # 9 + session.ExecuteCalcFunction("LN", -3) + +
+ +
+ ExecutePythonScript ------------------------------------------------------------------------------------ + + Session service;ExecutePythonScript + +

ExecutePythonScript

+ Execute the Python script given its location and name, fetch its result if any. Result can be a single value or an array of values. + If the script is not found, or if it returns nothing, the returned value is Empty. + + + + session.ExecutePythonScript(scope: str, script: str, args: any[0..*]): any + + + scope: One of the applicable constants listed above. The default value is session.SCRIPTISSHARED. + script: Either "library/module.py$method" or "module.py$method" or "myExtension.oxt|myScript|module.py$method" as a case-sensitive string. + + library: The folder path to the Python module. + myScript: The folder containing the Python module. + module.py: The Python module. + method: The Python function. + + args: The arguments to be passed to the called script. + + Consider the Python function odd_integers defined below that creates a list with odd integer values between v1 and v2. Suppose this function is stored in a file named my_macros.py in your user scripts folder. + + def odd_integers(v1, v2): + odd_list = [v for v in range(v1, v2 + 1) if v % 2 != 0] + return odd_list + + Read the help page Python Scripts Organization and Location to learn more about where Python scripts can be stored. + The following examples show how to call the function odd_integers from within Basic and Python scripts. + + + Dim script as String, session as Object + script = "my_macros.py$odd_integers" + session = CreateScriptService("Session") + Dim result as Variant + result = session.ExecutePythonScript(session.SCRIPTISPERSONAL, script, 1, 9) + MsgBox SF_String.Represent(result) + + + + session = CreateScriptService("Session") + script = "my_macros.py$odd_integers" + result = session.ExecutePythonScript(session.SCRIPTISPERSONAL, script, 1, 9) + bas.MsgBox(repr(result)) + +
+ +
+ GetPDFExportOptions ------------------------------------------------------------------------------------ + + Session service;GetPDFExportOptions + +

GetPDFExportOptions

+ Returns the current PDF export settings defined in the PDF Options dialog, which can be accessed by choosing File - Export as - Export as PDF. + Export options set with the PDF Options dialog are kept for future use. Hence GetPDFExportOptions returns the settings currently defined. In addition, use SetPDFExportOptions to change current PDF export options. + This method returns a Dictionary object wherein each key represent export options and the corresponding values are the current PDF export settings. + Read the PDF Export wiki page to learn more about all available options. + + + session.GetPDFExportOptions(): obj + + + + + Dim expSettings As Object, msg As String, key As String, optLabels As Variant + expSettings = session.GetPDFExportOptions() + optLabels = expSettings.Keys + For Each key in optLabels + msg = msg + key & ": " & expSettings.Item(key) & Chr(10) + Next key + MsgBox msg + ' Zoom: 100 + ' Changes: 4 + ' Quality: 90 + ' ... + + +
+ +
+ HasUnoMethod ------------------------------------------------------------------------------------------- + + Session service;HasUnoMethod + +

HasUnoMethod

+ Returns True if an UNO object contains the given method. Returns False when the method is not found or when an argument is invalid. + + + session.HasUnoMethod(unoobject: uno, methodname: str): bool + + + unoobject: The object to inspect. + methodname: the method as a case-sensitive string + + + + Dim a As Variant + a = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox session.HasUnoMethod(a, "callFunction") ' True + + + + bas = CreateScriptService("Basic") + a = bas.createUnoService("com.sun.star.sheet.FunctionAccess") + result = session.HasUnoMethod(a, "callFunction") + bas.MsgBox(result) # True + +
+ +
+ HasUnoProperty ----------------------------------------------------------------------------------------- + + Session service;HasUnoProperty + +

HasUnoProperty

+ Returns True if a UNO object has the given property. Returns False when the property is not found or when an argument is invalid. + + + session.HasUnoProperty(unoobject: uno, propertyname: str): bool + + + unoobject: The object to inspect. + propertyname: the property as a case-sensitive string + + + + Dim svc As Variant + svc = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox session.HasUnoProperty(svc, "Wildcards") + + + + bas = CreateScriptService("Basic") + a = bas.createUnoService("com.sun.star.sheet.FunctionAccess") + result = session.HasUnoProperty(a, "Wildcards") + bas.MsgBox(result) # True + +
+ +
+ OpenURLInBrowser --------------------------------------------------------------------------------------- + + Session service;OpenURLInBrowser + +

OpenURLInBrowser

+ Open a Uniform Resource Locator (URL) in the default browser. + + + session.OpenURLInBrowser(url: str) + + + url: The URL to open. + + + ' Basic + session.OpenURLInBrowser("help.libreoffice.org/") + + + # Python + session.OpenURLInBrowser("help.libreoffice.org/") + +
+ +
+ RunApplication ---------------------------------------------------------------------------------------- + + Session service;RunApplication + +

RunApplication

+ Executes an arbitrary system command and returns True if it was launched successfully. + + + session.RunApplication(command: str, parameters: str): bool + + + command: The command to execute. This may be an executable file or a document which is registered with an application so that the system knows what application to launch for that document. The command must be expressed in the current SF_FileSystem.FileNaming notation. + parameters: A list of space separated parameters as a single string. The method does not validate the given parameters, but only passes them to the specified command. + + + + session.RunApplication("Notepad.exe") + session.RunApplication("C:\myFolder\myDocument.odt") + session.RunApplication("kate", "/home/user/install.txt") ' GNU/Linux + + + + session.RunApplication("Notepad.exe") + session.RunApplication(r"C:\myFolder\myDocument.odt") + session.RunApplication("kate", "/home/user/install.txt") # GNU/Linux + +
+ +
+ SendMail ------------------------------------------------------------------------------------------------ + + Session service;SendMail + +

SendMail

+ Send a message - with optional attachments - to recipients from the user's mail client. The message may be edited by the user before sending or, alternatively, be sent immediately. + + + session.SendMail(recipient: str, cc: str = '', bcc: str = '', subject: str = '', body: str = '', filenames: str = '', editmessage: bool = True) + + + recipient: An email address (the "To" recipient). + cc: A comma-separated list of email addresses (the "carbon copy" recipients). + bcc: A comma-separated list of email addresses (the "blind carbon copy" recipients). + subject: the header of the message. + body: The contents of the message as an unformatted text. + filenames: a comma-separated list of file names. Each file name must respect the SF_FileSystem.FileNaming notation. + editmessage: When True (default), the message is edited before being sent. + + + + session.SendMail("someone@example.com" _ + , Cc := "b@other.fr, c@other.be" _ + , FileNames := "C:\myFile1.txt, C:\myFile2.txt") + + + + session.SendMail("someone@example.com", + cc="john@other.fr, mary@other.be" + filenames=r"C:\myFile1.txt, C:\myFile2.txt") + +
+ +
+ SetPDFExportOptions ------------------------------------------------------------------------------------ + + Session service;SetPDFExportOptions + +

SetPDFExportOptions

+ Modifies the PDF export settings defined in the PDF Options dialog, which can be accessed by choosing File - Export as - Export as PDF. + Calling this method changes the actual values set in the PDF Options dialog, which are used by the ExportAsPDF method from the Document service. + This method returns True when successful. + Read the PDF Export wiki page to learn more about all available options. + + + session.SetPDFExportOptions(pdfoptions: obj): bool + + + pdfoptions: Dictionary object that defines the PDF export settings to be changed. Each key-value pair represents an export option and the value that will be set in the dialog. + + + The following example changes the maximum image resolution to 150 dpi and exports the current document as a PDF file. + + Dim newSettings As Object, oDoc As Object + Set oDoc = CreateScriptService("Document") + Set newSettings = CreateScriptService("Dictionary") + newSettings.Add("ReduceImageResolution", True) + newSettings.Add("MaxImageResolution", 150) + session.SetPDFExportOptions(newSettings) + oDoc.ExportAsPDF("C:\Documents\myFile.pdf", Overwrite := True) + + +
+ +
+ UnoMethods --------------------------------------------------------------------------------------------- + + Session service;UnoMethods + +

UnoMethods

+ Returns a list of the methods callable from an UNO object. The list is a zero-based array of strings and may be empty. + + + session.UnoMethods(unoobject: uno): str[0..*] + + + unoobject: The object to inspect. + + + + Dim svc : svc = CreateUnoService("com.sun.star.sheet.FunctionAccess") + Dim methods : methods = session.UnoMethods(svc) + Dim msg as String + For Each m in methods + msg = msg & m & Chr(13) + Next m + MsgBox msg + + + + bas = CreateScriptService("Basic") + a = bas.createUnoService("com.sun.star.sheet.FunctionAccess") + methods = session.UnoMethods(a) + msg = "\n".join(methods) + bas.MsgBox(msg) + +
+ +
+ UnoProperties ------------------------------------------------------------------------------------------- + + Session service;UnoProperties + +

UnoProperties

+ Returns a list of the properties of an UNO object. The list is a zero-based array of strings and may be empty. + + + session.UnoProperties(unoobject: uno): str[0..*] + + + unoobject: The object to inspect. + + + + Dim svc As Variant + svc = CreateUnoService("com.sun.star.sheet.FunctionAccess") + MsgBox SF_Array.Contains(session.UnoProperties(svc), "Wildcards") ' True + + + + bas = CreateScriptService("Basic") + svc = bas.createUnoService("com.sun.star.sheet.FunctionAccess") + properties = session.UnoProperties(a) + b = "Wildcards" in properties + bas.MsgBox(str(b)) # True + +
+ +
+ UnoObjectType ------------------------------------------------------------------------------------------ + + Session service;UnoObjectType + +

UnoObjectType

+ Identify the type of a UNO object as a string. + + + session.UnoObjectType(unoobject: uno): str + + + unoobject: The object to identify. + + + + Dim svc As Variant, txt As String + svc = CreateUnoService("com.sun.star.system.SystemShellExecute") + txt = session.UnoObjectType(svc) ' "com.sun.star.comp.system.SystemShellExecute" + svc = CreateUnoStruct("com.sun.star.beans.Property") + txt = session.UnoObjectType(svc) ' "com.sun.star.beans.Property" + + + + bas = CreateScriptService("Basic") + svc = bas.createUnoService("com.sun.star.system.SystemShellExecute") + txt = session.UnoObjectType(svc) # "com.sun.star.comp.system.SystemShellExecute" + svc = bas.createUnoService("com.sun.star.beans.Property") + txt = session.UnoObjectType(svc) # "com.sun.star.beans.Property" + +
+ +
+ WebService ---------------------------------------------------------------------------------------------- + + Session service;WebService + +

WebService

+ Get some web content from a URI. + + + session.WebService(uri: str): str + + + uri: URI address of the web service. + + + + session.WebService("wiki.documentfoundation.org/api.php?" _ + & "hidebots=1&days=7&limit=50&action=feedrecentchanges&feedformat=rss") + + + + session.WebService(("wiki.documentfoundation.org/api.php?" + "hidebots=1&days=7&limit=50&action=feedrecentchanges&feedformat=rss")) + +
+ + + +
+ + + + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_string.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_string.xhp new file mode 100644 index 000000000..2ca692c21 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_string.xhp @@ -0,0 +1,1501 @@ + + + + + + + ScriptForge.String service (SF_String) + /text/sbasic/shared/03/sf_string.xhp + + + + +
+ + String service + +
+ +
+

ScriptForge.String service

+ The String service provides a collection of methods for string processing. These methods can be used to: + + + Validate the contents of strings + + + Format strings by trimming, justifying or wrapping their contents + + + Use regular expressions to search and replace substrings + + + Apply hash algorithms on strings, etc. + + +
+ +

Definitions

+ +

Line breaks

+ The String service recognizes the following line breaks: + + + + Symbolic name + + + ASCII number + + + + + + Line feed
+ Vertical tab
+ Carriage return
+ Line feed + Carriage return
+ File separator
+ Group separator
+ Record separator
+ Next line
+ Line separator
+ Paragraph separator +
+
+ + + 10
12
13
10 + 13
28
29
30
133
8232
8233 +
+
+
+
+ +

Whitespaces

+ The String service recognizes the following whitespaces: + + + + Symbolic name + + + ASCII number + + + + + + Space
+ Horizontal tab
+ Line feed
+ Vertical tab
+ Form feed
+ Carriage return
+ Next line
+ No-break space
+ Line separator
+ Paragraph separator +
+
+ + + 32
9
10
11
12
13
133
160
8232
8233 +
+
+
+
+ +

Escape sequences

+ Below is a list of escape sequences that can be used in strings. + + + + Escape Sequence + + + Symbolic name + + + ASCII number + + + + + + \n
\r
\t +
+
+ + + Line feed
+ Carriage return
+ Horizontal tab +
+
+ + + 10
13
9 +
+
+
+
+ To have the escape sequence "\n" interpreted as an actual string, simply use "\\n" instead of "\" & Chr(10). + +

Non-printable characters:

+ Characters defined in the Unicode Character Database as “Other” or “Separator” are considered as non-printable characters. + Control characters (ascii code <= 0x1F) are also considered as non-printable. + +

Quotes inside strings:

+ To add quotes in strings use \' (single quote) or \" (double quote). For example: + + + The string [str\'i\'ng] is interpreted as [str'i'ng] + + + The string [str\"i\"ng] is interpreted as [str"i"ng] + + + +

Service invocation

+ Before using the ScriptForge.String service the ScriptForge library needs to be loaded using: + + + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + + Loading the library will create the SF_String object that can be used to call the methods in the String service. + The following code snippets show the three ways to call methods from the String service (the Capitalize method is used as an example): + + Dim s as String : s = "abc def" + s = SF_String.Capitalize(s) ' Abc Def + + + Dim s as String : s = "abc def" + Dim svc : svc = SF_String + s = svc.Capitalize(s) ' Abc Def + + + Dim s as String : s = "abc def" + Dim svc : svc = CreateScriptService("String") + s = svc.Capitalize(s) ' Abc Def + + + The code snippet below illustrates how to invoke methods from the String service in Python scripts. The IsIPv4 method is used as an example. + + from scriptforge import CreateScriptService + svc = CreateScriptService("String") + ip_address = '192.168.0.14' + svc.IsIPv4(ip_address) # True + + +

Properties

+ The SF_String object provides the following properties for Basic scripts: + + + + Name + + + ReadOnly + + + Description + + + + + sfCR + + + Yes + + + Carriage return: Chr(13) + + + + + sfCRLF + + + Yes + + + Carriage return + Linefeed: Chr(13) & Chr(10) + + + + + sfLF + + + Yes + + + Linefeed: Chr(10) + + + + + sfNEWLINE + + + Yes + + + Carriage return + Linefeed, which can be
1) Chr(13) & Chr(10) or +
2) Linefeed: Chr(10) +
depending on the operating system.
+
+
+ + + sfTAB + + + Yes + + + Horizontal tabulation: Chr(9) + + +
+ You can use the properties above to identify or insert the corresponding characters inside strings. For example, the Linefeed can be replaced by SF_String.sfLF. + + + + List of Methods in the String Service + + + + + Capitalize
+ Count
+ EndsWith
+ Escape
+ ExpandTabs
+ FilterNotPrintable
+ FindRegex
+ HashStr
+ HtmlEncode
+ IsADate
+ IsAlpha
+ IsAlphaNum
+ IsAscii
+ IsDigit
+ IsEmail
+
+
+ + + IsFileName
+ IsHexDigit
+ IsIBAN
+ IsIPv4
+ IsLike
+ IsLower
+ IsPrintable
+ IsRegex
+ IsSheetName
+ IsTitle
+ IsUpper
+ IsUrl
+ IsWhitespace
+ JustifyCenter
+ JustifyLeft
+
+
+ + + JustifyRight
+ Quote
+ ReplaceChar
+ ReplaceRegex
+ ReplaceStr
+ Represent
+ Reverse
+ SplitLines
+ SplitNotQuoted
+ StartsWith
+ TrimExt
+ Unescape
+ Unquote
+ Wrap

+
+
+
+
+ The first argument of most methods is the string to be considered. It is always passed by reference and left unchanged. Methods such as Capitalize, Escape, etc return a new string after their execution. + Because Python has comprehensive built-in string support, most of the methods in the String service are available for Basic scripts only. The methods available for Basic and Python are: HashStr, IsADate, IsEmail, IsFileName, IsIBAN, IsIPv4, IsLike, IsSheetName, IsUrl, SplitNotQuoted and Wrap. + +
+ Capitalize -------------------------------------------------------------------------------------------- + + String service;Capitalize + +

Capitalize

+ Capitalizes the first character from each word in the input string. + + + svc.Capitalize(inputstr: str): str + + + inputstr: The string to be capitalized. + + + Dim sName as String : sName = "john smith" + Dim sCapitalizedName as String + sCapitalizedName = SF_String.Capitalize(sName) + MsgBox sCapitalizedName 'John Smith + +
+ +
+ Count ------------------------------------------------------------------------------------------------- + + String service;Count + +

Count

+ Counts the number of occurrences of a substring or a regular expression within a string. + + + svc.Count(inputstr: str, substring: str, [isregex: bool], [casesensitive: bool]): int + + + inputstr: The input string to be examined + substring: The substring or the regular expression to be used during search + isregex: Use True if the substring is a regular expression (Default = False) + casesensitive: The search can be case sensitive or not (Default = False). + + + 'Counts the occurrences of the substring "or" inside the input string (returns 2) + MsgBox SF_String.Count("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "or", CaseSensitive := False) + 'Counts the number of words with only lowercase letters (returns 7) + MsgBox SF_String.Count("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "\b[a-z]+\b", IsRegex := True, CaseSensitive := True) + + To learn more about regular expressions, refer to the Python's documentation on Regular Expression Operations. +
+ +
+ EndsWith ---------------------------------------------------------------------------------------------- + + String service;EndsWith + +

EndsWith

+ Returns True if a string ends with a specified substring. + The function returns False when either the string or the substring have a length = 0 or when the substring is longer than the string. + + + svc.EndsWith(inputstr: str, substring: str, [casesensitive: bool]): bool + + + inputstr: The string to be tested. + substring: The substring to be searched at the end of inputstr. + casesensitive: The search can be case sensitive or not (Default = False). + + + 'Returns True because the method was called with the default CaseSensitive = False + MsgBox SF_String.EndsWith("abcdefg", "EFG") + 'Returns False due to the CaseSensitive parameter + MsgBox SF_String.EndsWith("abcdefg", "EFG", CaseSensitive := True) + +
+ +
+ Escape ------------------------------------------------------------------------------------------------ + + String service;Escape + +

Escape

+ Converts linebreaks and tabs contained in the input string to their equivalent escaped sequence (\\, \n, \r, \t). + + + svc.Escape(inputstr: str): str + + + inputstr: The string to be converted. + + + 'Returns the string "abc\n\tdef\\n" + MsgBox SF_String.Escape("abc" & Chr(10) & Chr(9) & "def\n") + +
+ +
+ ExpandTabs -------------------------------------------------------------------------------------------- + + String service;ExpandTabs + +

ExpandTabs

+ Replaces Tab characters Chr(9) by space characters to replicate the behavior of tab stops. + If a line break is found, a new line is started and the character counter is reset. + + + svc.ExpandTabs(inputstr: str, [tabsize: int]): str + + + inputstr: The string to be expanded + tabsize: This parameter is used to determine the Tab stops using the formula: TabSize + 1, 2 * TabSize + 1 , ... N * TabSize + 1 (Default = 8) + + + Dim myText as String + myText = "100" & SF_String.sfTAB & "200" & SF_String.sfTAB & "300" & SF_String.sfNEWLINE & _ + "X" & SF_String.sfTAB & "Y" & SF_String.sfTAB & "Z" + MsgBox SF_String.ExpandTabs(myText) + '100 200 300 + 'X Y Z + +
+ +
+ FilterNotPrintable ------------------------------------------------------------------------------------ + + String service;FilterNotPrintable + +

FilterNotPrintable

+ Replaces all non-printable characters in the input string by a given character. + + + svc.FilterNotPrintable(inputstr: str, [replacedby: str]): str + + + inputstr: The string to be searched + replacedby: Zero, one or more characters that will replace all non-printable characters in inputstr (Default = "") + + + Dim LF : LF = Chr(10) + Dim myText as String + myText = "àén ΣlPµ" & LF & " Русский" & "\n" + MsgBox SF_String.FilterNotPrintable(myText) + ' "àén ΣlPµ Русский\n" + +
+ +
+ FindRegex --------------------------------------------------------------------------------------------- + + String service;FindRegex + +

FindRegex

+ Finds in a string a substring matching a given regular expression. + + + svc.FindRegex(inputstr: str, regex: str, [start: int], [casesensitive: bool], [forward: bool]): str + + + inputstr: The string to be searched + regex: The regular expression + start: The position in the string where the search will begin. This parameter is passed by reference, so after execution the value of start will point to the first character of the found substring. If no matching substring is found, start will be set to 0. + casesensitive: The search can be case sensitive or not (Default = False). + forward: Determines the direction of the search. If True, search moves forward. If False search moves backwards (Default = True) + At the first iteration, if forward = True, then start should be equal to 1, whereas if forward = False then start should be equal to Len(inputstr) + + + Dim lStart As Long : lStart = 1 + Dim result as String + result = SF_String.FindRegex("abCcdefghHij", "C.*H", lStart, CaseSensitive := True) + MsgBox lStart & ": " & result + '3: CcdefghH + + In the example above, the new value of lStart can be used to keep searching the same input string by setting the Start parameter to lStart + Len(result) at the next iteration. +
+ +
+ HashStr ----------------------------------------------------------------------------------------------- + + String service;HashStr + +

HashStr

+ Hash functions are used inside some cryptographic algorithms, in digital signatures, message authentication codes, manipulation detection, fingerprints, checksums (message integrity check), hash tables, password storage and much more. + The HashStr method returns the result of a hash function applied on a given string and using a specified algorithm, as a string of lowercase hexadecimal digits. + The hash algorithms supported are: MD5, SHA1, SHA224, SHA256, SHA384 and SHA512. + + + svc.HashStr(inputstr: str, algorithm: str): str + + + inputstr: The string to hash. It is presumed to be encoded in UTF-8. The hashing algorithm will consider the string as a stream of bytes. + algorithm: One of the supported algorithms listed above, passed as a string. + + + + MsgBox SF_String.HashStr("œ∑¡™£¢∞§¶•ªº–≠œ∑´®†¥¨ˆøπ‘åß∂ƒ©˙∆˚¬", "MD5") + ' c740ccc2e201df4b2e2b4aa086f35d8a + + + + svc = CreateScriptService("String") + bas = CreateScriptService("Basic") + a_string = "œ∑¡™£¢∞§¶•ªº–≠œ∑´®†¥¨ˆøπ‘åß∂ƒ©˙∆˚¬" + hash_value = svc.HashStr(a_string, "MD5") + bas.MsgBox(hash_value) + # c740ccc2e201df4b2e2b4aa086f35d8a + +
+ +
+ HtmlEncode -------------------------------------------------------------------------------------------- + + String service;HtmlEncode + +

HtmlEncode

+ Encodes the input string into the HTML character codes, replacing special characters by their & counterparts. + For example, the character é would be replaced by &eacute; or an equivalent numerical HTML code. + + + svc.HtmlEncode(inputstr: str): str + + + inputstr: The string to encode. + + + MsgBox SF_String.HtmlEncode("<a href=""https://a.b.com"">From α to ω</a>") + ' "&lt;a href=&quot;https://a.b.com&quot;&gt;From &#945; to &#969;&lt;/a&gt;" + +
+ +
+ IsADate ---------------------------------------------------------------------------------------------- + + String service;IsADate + +

IsADate

+ Returns True if the input string is a valid date according to a specified date format. + + + svc.IsADate(inputstr: str, [dateformat: str]): bool + + + inputstr: The string to be checked. If empty, the method returns False + dateformat: The date format, as a string. It can be either "YYYY-MM-DD" (default), "DD-MM-YYYY" or "MM-DD-YYYY" + The dash (-) may be replaced by a dot (.), a slash (/) or a space. + If the format is invalid, the method returns False. + + + + MsgBox SF_String.IsADate("2020-12-31", "YYYY-MM-DD") ' True + + This method checks the format of the input string without performing any calendar-specific checks. Hence it does not test the input string for leap years or months with 30 or 31 days. For that, refer to the IsDate built-in function. + The example below shows the difference between the methods IsADate (ScriptForge) and the IsDate (built-in) function. + + Dim myDate as String : myDate = "2020-02-30" + MsgBox SF_String.IsADate(myDate, "YYYY-MM-DD") 'True + MsgBox IsDate(myDate) ' False + + + + svc = CreateScriptService("String") + s_date = "2020-12-31" + result = svc.IsADate(s_date) # True + +
+ +
+ IsAlpha ---------------------------------------------------------------------------------------------- + + String service;IsAlpha + +

IsAlpha

+ Returns True if all characters in the string are alphabetic. + Alphabetic characters are those characters defined in the Unicode Character Database as Letter. + + + svc.IsAlpha(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsAlpha("àénΣlPµ") ' True + MsgBox SF_String.IsAlpha("myVar3") ' False + +
+ +
+ IsAlphaNum -------------------------------------------------------------------------------------------- + + String service;IsAlphanum + +

IsAlphaNum

+ Returns True if all characters in the string are alphabetic, digits or "_" (underscore). The first character must not be a digit. + + + svc.IsAlphaNum(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsAlphaNum("_ABC_123456_abcàénΣlPµ") ' True + MsgBox SF_String.IsAlphaNum("123ABC") ' False + +
+ +
+ IsAscii ----------------------------------------------------------------------------------------------- + + String service;IsAscii + +

IsAscii

+ Returns True if all characters in the string are Ascii characters. + + + svc.IsAscii(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsAscii("a%?,25") ' True + MsgBox SF_String.IsAscii("abcàénΣlPµ") ' False + +
+ +
+ IsDigit ---------------------------------------------------------------------------------------------- + + String service;IsDigit + +

IsDigit

+ Returns True if all characters in the string are digits. + + + svc.IsDigit(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsDigit("123456") ' True + MsgBox SF_String.IsDigit("_12a") ' False + +
+ +
+ IsEmail ----------------------------------------------------------------------------------------------- + + String service;IsEmail + +

IsEmail

+ Returns True if the string is a valid email address. + + + svc.IsEmail(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + + MsgBox SF_String.IsEmail("first.last@something.org") ' True + MsgBox SF_String.IsEmail("first.last@something.com.br") ' True + MsgBox SF_String.IsEmail("first.last@something.123") ' False + + + + svc = CreateScriptService("String") + bas = CreateScriptService("Basic") + bas.MsgBox(svc.IsEmail("first.last@something.org")) # True + bas.MsgBox(svc.IsEmail("first.last@something.com.br")) # True + bas.MsgBox(svc.IsEmail("first.last@something.123")) # False + +
+ +
+ IsFileName -------------------------------------------------------------------------------------------- + + String service;IsFileName + +

IsFileName

+ Returns True if the string is a valid filename in a given operating system. + + + svc.IsFileName(inputstr: str, [osname: str]): bool + + + inputstr: The string to be checked. If empty, the method returns False. + osname: The operating system name, as a string. It can be "WINDOWS", "LINUX", "MACOSX" or "SOLARIS". + The default value is the current operating system on which the script is running. + + + + MsgBox SF_String.IsFileName("/home/user/Documents/a file name.odt", "LINUX") ' True + MsgBox SF_String.IsFileName("C:\home\a file name.odt", "LINUX") ' False + MsgBox SF_String.IsFileName("C:\home\a file name.odt", "WINDOWS") ' True + + + + svc = CreateScriptService("String") + bas = CreateScriptService("Basic") + bas.MsgBox(svc.IsFileName("/home/user/Documents/a file name.odt", "LINUX")) # True + bas.MsgBox(svc.IsFileName(r"C:\home\a file name.odt", "LINUX")) # False + bas.MsgBox(svc.IsFileName(r"C:\home\a file name.odt", "WINDOWS")) # True + +
+ +
+ IsHexDigit ------------------------------------------------------------------------------------------- + + String service;IsHexDigit + +

IsHexDigit

+ Returns True if all characters in the string are hexadecimal digits. + + + svc.IsHexDigit(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + The hexadecimal digits may be prefixed with "0x" or "&H". + + + MsgBox SF_String.IsHexDigit("&H00FF") ' True + MsgBox SF_String.IsHexDigit("08AAFF10") ' True + MsgBox SF_String.IsHexDigit("0x18LA22") ' False + +
+ +
+ IsIBAN ------------------------------------------------------------------------------------------------ + + String service;IsIBAN + +

IsIBAN

+ Returns True if the string is a valid International Bank Account Number (IBAN). The comparison is not case-sensitive. + + + svc.IsIBAN(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + True if the string contains a valid IBAN number. + + + ' Basic + MsgBox SF_String.IsIBAN("BR15 0000 0000 0000 1093 2840 814 P2") ' True + + + # Python + result = svc.IsIBAN("BR15 0000 0000 0000 1093 2840 814 P2") # True + +
+ +
+ IsIPv4 ------------------------------------------------------------------------------------------------ + + String service;IsIPv4 + +

IsIPv4

+ Returns True if the string is a valid IP(v4) address. + + + svc.IsIPv4(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + + MsgBox SF_String.IsIPv4("192.168.1.50") ' True + MsgBox SF_String.IsIPv4("192.168.50") ' False + MsgBox SF_String.IsIPv4("255.255.255.256") ' False + + + + svc = CreateScriptService("String") + bas = CreateScriptService("Basic") + bas.MsgBox(svc.IsIPv4("192.168.1.50")) # True + bas.MsgBox(svc.IsIPv4("192.168.50")) # False + bas.MsgBox(svc.IsIPv4("255.255.255.256")) # False + +
+ +
+ IsLike ------------------------------------------------------------------------------------------------ + + String service;IsLike + +

IsLike

+ Returns True if the whole input string matches a given pattern containing wildcards. + + + svc.IsLike(inputstr: str, pattern: str, [casesensitive: bool]): bool + + + inputstr: The string to be checked. If empty, the method returns False. + pattern: The pattern as a string. Wildcards are: + + + "?" represents any single character; + + + "*" represents zero, one, or multiple characters. + + + casesensitive: The search can be case sensitive or not (Default = False). + + + + MsgBox SF_String.IsLike("aAbB", "?A*") ' True + MsgBox SF_String.IsLike("C:\a\b\c\f.odb", "?:*.*") ' True + MsgBox SF_String.IsLike("name:host", "?*@?*") ' False + MsgBox SF_String.IsLike("@host", "?*@?*") ' False + + + + svc = CreateScriptService("String") + bas = CreateScriptService("Basic") + bas.MsgBox(svc.IsLike("aAbB", "?A*")) # True + bas.MsgBox(svc.IsLike(r"C:\a\b\c\f.odb", "?:*.*")) # True + bas.MsgBox(svc.IsLike("name:host", "?*@?*")) # False + bas.MsgBox(svc.IsLike("@host", "?*@?*")) # False + +
+ +
+ IsLower ----------------------------------------------------------------------------------------------- + + String service;IsLower + +

IsLower

+ Returns True if all characters in the string are in lowercase. Non-alphabetic characters are ignored. + + + svc.IsLower(inputstr: str): bool + + + InputStr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsLower("abc'(-xy4z") ' True + MsgBox SF_String.IsLower("1234") ' True + MsgBox SF_String.IsLower("abcDefg") ' False + +
+ +
+ IsPrintable ------------------------------------------------------------------------------------------- + + String service;IsPrintable + +

IsPrintable

+ Returns True if all characters in the string are printable. + + + svc.IsPrintable(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsPrintable("àén ΣlPµ Русский") ' True + MsgBox SF_String.IsPrintable("First line." & Chr(10) & "Second Line.") ' False + +
+ +
+ IsRegex ----------------------------------------------------------------------------------------------- + + String service;IsRegex + +

IsRegex

+ Returns True if the whole input string matches a given regular expression. + + + svc.IsRegex(inputstr: str, regex: str, [casesensitive: bool]): bool + + + inputstr: The string to be checked. If empty, the method returns False. + regex: The regular expression. If empty, the method returns False. + casesensitive: The search can be case sensitive or not (Default = False). + + + MsgBox SF_String.IsRegex("aAbB", "[A-Za-z]+") ' True + MsgBox SF_String.IsRegex("John;100", "[A-Za-z]+;[0-9]+") ' True + MsgBox SF_String.IsRegex("John;100;150", "[A-Za-z]+;[0-9]+") ' False + +
+ +
+ IsSheetName ------------------------------------------------------------------------------------------- + + String service;IsSheetName + +

IsSheetName

+ Returns True if the input string is a valid Calc sheet name. + + + svc.IsSheetName(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + + MsgBox SF_String.IsSheetName("1àbc + ""déf""") ' True + MsgBox SF_String.IsSheetName("[MySheet]") ' False + + + + svc = CreateScriptService("String") + bas = CreateScriptService("Basic") + bas.MsgBox(svc.IsSheetName("1àbc + ""déf""")) # True + bas.MsgBox(svc.IsSheetName("[MySheet]")) # False + + A sheet name must not contain the characters [ ] * ? : / \ or the character ' (apostrophe) as first or last character. +
+ +
+ IsTitle ----------------------------------------------------------------------------------------------- + + String service;IsTitle + +

IsTitle

+ Returns True if the first character of every word is in uppercase and the other characters are in lowercase. + + + svc.IsTitle(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsTitle("This Is The Title Of My Book") ' True + MsgBox SF_String.IsTitle("This is the Title of my Book") ' False + MsgBox SF_String.IsTitle("Result Number 100") ' True + +
+ +
+ IsUpper ----------------------------------------------------------------------------------------------- + + String service;IsUpper + +

IsUpper

+ Returns True if all characters in the string are in uppercase. Non alphabetic characters are ignored. + + + svc.IsUpper(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsUpper("ABC'(-XYZ") ' True + MsgBox SF_String.IsUpper("A Title") ' False + +
+ +
+ IsUrl ------------------------------------------------------------------------------------------------- + + String service;IsUrl + +

IsUrl

+ Returns True if the string is a valid absolute URL (Uniform Resource Locator) address. Only the http, https and ftp protocols are supported. + + + svc.IsUrl(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + + MsgBox SF_String.IsUrl("http://foo.bar/?q=Test%20URL-encoded%20stuff") ' True + MsgBox SF_String.IsUrl("www.somesite.org") ' False + + + + svc = CreateScriptService("String") + bas = CreateScriptService("Basic") + bas.MsgBox(svc.IsUrl("http://foo.bar/?q=Test%20URL-encoded%20stuff")) # True + bas.MsgBox(svc.IsUrl("www.somesite.org")) # False + +
+ +
+ IsWhitespace ----------------------------------------------------------------------------------------- + + String service;IsWhitespace + +

IsWhitespace

+ Returns True if all characters in the string are whitespaces + + + svc.IsWhitespace(inputstr: str): bool + + + inputstr: The string to be checked. If empty, the method returns False. + + + MsgBox SF_String.IsWhitespace(" ") ' True + MsgBox SF_String.IsWhitespace(" " & Chr(9) & Chr(10)) ' True + MsgBox SF_String.IsWhitespace("") ' False + +
+ +
+ JustifyCenter ----------------------------------------------------------------------------------------- + + String service;JustifyCenter + +

JustifyCenter

+ Returns the input string center-justified. + The leading and trailing white spaces are stripped and the remaining characters are completed left and right up to a specified total length with the character padding. + + + svc.JustifyCenter(inputstr: str, [length: int], [padding: str]): str + + + inputstr: The string to be center-justified. If empty, the method returns an empty string. + length: The length of the resulting string (default = the length of the input string). + If the specified length is shorter than the center-justified input string, then the returned string is truncated. + padding: The single character to be used as padding (default = the Ascii space " "). + + + MsgBox SF_String.JustifyCenter("Title", Length := 11) ' " Title " + MsgBox SF_String.JustifyCenter(" ABCDEF", Padding := "_") ' "__ABCDEF__" + MsgBox SF_String.JustifyCenter("A Long Title", Length := 5) ' "ong T" + +
+ +
+ JustifyLeft ------------------------------------------------------------------------------------------- + + String service;JustifyLeft + +

JustifyLeft

+ Returns the input string left-justified. + The leading white spaces are stripped and the remaining characters are completed to the right up to a specified total length with the character padding. + + + svc.JustifyLeft(inputstr: str, [length: int], [padding: str]): str + + + inputstr: The string to be left-justified. If empty, the method returns an empty string. + length: The length of the resulting string (default = the length of the input string). + If the specified length is shorter than the left-justified input string, then the returned string is truncated. + padding: The single character to be used as padding (default = the Ascii space " "). + + + MsgBox SF_String.JustifyLeft("Title", Length := 10) ' "Title " + MsgBox SF_String.JustifyLeft(" ABCDEF", Padding := "_") ' "ABCDEF____" + MsgBox SF_String.JustifyLeft("A Long Title", Length := 5) ' "A Lon" + +
+ +
+ JustifyRight ------------------------------------------------------------------------------------------ + + String service;JustifyRight + +

JustifyRight

+ Returns the input string right-justified. + The leading white spaces are stripped and the remaining characters are completed to the left up to a specified total length with the character padding. + + + svc.JustifyRight(inputstr: str, [length: int], [padding: str]): str + + + inputstr: The string to be right-justified. If empty, the method returns an empty string. + length: The length of the resulting string (default = the length of the input string). + If the specified length is shorter than the right-justified input string, then the returned string is truncated. + padding: The single character to be used as padding (default = the Ascii space " "). + + + MsgBox SF_String.JustifyRight("Title", Length := 10) ' " Title" + MsgBox SF_String.JustifyRight(" ABCDEF ", Padding := "_") ' "____ABCDEF" + MsgBox SF_String.JustifyRight("A Long Title", Length := 5) ' "Title" + +
+ +
+ Quote ------------------------------------------------------------------------------------------------- + + String service;Quote + +

Quote

+ Returns the input string enclosed in single or double quotes. Existing quotes are left unchanged, including leading and/or trailing quotes. + + + svc.Quote(inputstr: str, [quotechar: str]): str + + + inputstr: The string to quote. + quotechar: Either the single (') or double (") quote (default). + + + MsgBox SF_String.Quote("Text Value") + ' "Text Value" + MsgBox SF_String.Quote("Book Title: ""The Arabian Nights""", "'") + ' 'Book Title: "The Arabian Nights"' + + This method can be useful while preparing a string field to be stored in a csv-like file, which requires that text values be enclosed with single or double quotes. +
+ +
+ ReplaceChar ------------------------------------------------------------------------------------------- + + String service;ReplaceChar + +

ReplaceChar

+ Replaces all occurrences of the characters specified in the Before parameter by the corresponding characters specified in After. + If the length of Before is greater than the length of After, the residual characters in Before are replaced by the last character in After. + + + svc.ReplaceChar(inputstr: str, before: str, after: str): str + + + inputstr: The input string on which replacements will occur. + before: A string with the characters that will be searched in the input string for replacement. + after: A string with the new characters that will replace those defined in before. + + + ' Replaces accented characters + MsgBox SF_String.ReplaceChar("Protégez votre vie privée", "àâãçèéêëîïôöûüýÿ", "aaaceeeeiioouuyy") + ' "Protegez votre vie privee" + MsgBox SF_String.ReplaceChar("Protégez votre vie privée", "àâãçèéêëîïôöûüýÿ", "") + ' "Protgez votre vie prive" + MsgBox SF_String.ReplaceChar("àâãçèéêëîïôöûüýÿ", "àâãçèéêëîïôöûüýÿ", "aaaceeeeiioouuyy") + ' "aaaceeeeiioouuyy" + + The SF_String service provides useful public constants for the Latin character sets, as shown in the example below: + + MsgBox SF_String.ReplaceChar("Protégez votre vie privée", SF_String.CHARSWITHACCENT, SF_String.CHARSWITHOUTACCENT) + ' "Protegez votre vie privee" + +
+ +
+ ReplaceRegex ------------------------------------------------------------------------------------------ + + String service;ReplaceRegex + +

ReplaceRegex

+ Replaces all occurrences of a given regular expression by a new string. + + + svc.ReplaceRegex(inputstr: str, regex: str, newstr: str, [casesensitive: bool]): str + + + inputstr: The input string on which replacements will occur. + regex: The regular expression. + newstr: The replacing string. + casesensitive: The search can be case sensitive or not (Default = False). + + + MsgBox SF_String.ReplaceRegex("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "[a-z]", "x", CaseSensitive := True) + ' "Lxxxx xxxxx xxxxx xxx xxxx, xxxxxxxxxxx xxxxxxxxxx xxxx." (each lowercase letter is replaced by "x") + MsgBox SF_String.ReplaceRegex("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "\b[a-z]+\b", "x", CaseSensitive := False) + ' "x x x x x, x x x." (each word is replaced by "x") + +
+ +
+ ReplaceStr -------------------------------------------------------------------------------------------- + + String service;ReplaceStr + +

ReplaceStr

+ Replaces in a string some or all occurrences of an array of strings by an array of new strings. + + + svc.ReplaceStr(inputstr: str, oldstr: str, newstr: str, [occurrences: int], [casesensitive: bool]): str + + + inputstr: The input string on which replacements will occur. + oldstr: A single string or an array of strings. Zero-length strings are ignored. + newstr: The replacing string or the array of replacing strings. + If oldstr is an array, each occurrence of any of the items in oldstr is replaced by newstr. + If oldstr and newstr are arrays, replacements occur one by one up to the UBound(newstr). + If oldstr has more entries than newstr, then the residual elements in oldstr are replaced by the last element in newstr. + occurrences: The maximum number of replacements. The default value is 0, meaning that all occurrences will be replaced. + When oldstr is an array, the occurrence parameter is computed separately for each item in the array. + casesensitive: The search can be case sensitive or not (Default = False). + + + MsgBox SF_String.ReplaceStr("100 xxx 200 yyy", Array("xxx", "yyy"), Array("(1)", "(2)"), CaseSensitive := False) + ' "100 (1) 200 (2)" + MsgBox SF_String.ReplaceStr("abCcdefghHij", Array("c", "h"), Array("Y", "Z"), CaseSensitive := False) + ' "abYYdefgZZij" + +
+ +
+ Represent --------------------------------------------------------------------------------------------- + + String service;Represent + +

Represent

+ Returns a string with a readable representation of the argument, truncated at a given length. This is useful mainly for debugging or logging purposes. + If the anyvalue parameter is an object, it will be enclosed with square brackets "[" and "]". + In strings, tabs and line breaks are replaced by \t, \n or \r. + If the final length exceeds the maxlength parameter, the latter part of the string is replaced by " ... (N)" where N is the total length of the original string before truncation. + + + svc.Represent(anyvalue: any, [maxlength: int]): str + + + anyvalue: The input value to be represented. It can be any value, such as a string, an array, a Basic object, a UNO object, etc. + maxlength: The maximum length of the resulting string. The default value is 0, meaning there is no limit to the length of the resulting representation. + + + MsgBox SF_String.Represent("this is a usual string") ' "this is a usual string" + MsgBox SF_String.Represent("this is a usual string", 15) ' "this i ... (22)" + MsgBox SF_String.Represent("this is a" & Chr(10) & " 2-lines string") ' "this is a\n 2-lines string" + MsgBox SF_String.Represent(Empty) ' "[EMPTY]" + MsgBox SF_String.Represent(Null) ' "[NULL]" + MsgBox SF_String.Represent(Pi) ' "3.142" + MsgBox SF_String.Represent(CreateUnoService("com.sun.star.util.PathSettings")) ' "[com.sun.star.comp.framework.PathSettings]" + + Note that the representation of data types such as Arrays and ScriptForge.Dictionary object instances include both the data type and their values: + + ' An example with a Basic built-in Array + MsgBox SF_String.Represent(Array(1, 2, "Text" & Chr(9) & "here")) + ' "[ARRAY] (0:2) (1, 2, Text\there)" + ' An example with a ScriptForge Array + Dim aValues as Variant + aValues = SF_Array.RangeInit(1, 5) + MsgBox SF_String.Represent(aValues) + ' "[ARRAY] (0:4) (1.0, 2.0, 3.0, 4.0, 5.0)" + ' An example with a ScriptForge Dictionary + Dim myDict As Variant : myDict = CreateScriptService("Dictionary") + myDict.Add("A", 1) : myDict.Add("B", 2) + MsgBox SF_String.Represent(myDict) + ' "[Dictionary] ("A":1, "B":2)" + +
+ +
+ Reverse ---------------------------------------------------------------------------------------------- + + String service;Reverse + +

Reverse

+ Returns the input string in reversed order. + This method is equivalent to the built-in StrReverse Basic function. + To use the StrReverse function, the statement Option VBASupport 1 must be present in the module. + + + svc.Reverse(inputstr: str): str + + + inputstr: The string to be reversed. + + + MsgBox SF_String.Reverse("abcdefghij") ' "jihgfedcba" + +
+ +
+ SplitLines -------------------------------------------------------------------------------------------- + + String service;SplitLines + +

SplitLines

+ Returns a zero-based array of strings with the lines in the input string. Each item in the array is obtained by splitting the input string at newline characters. + + + svc.SplitLines(inputstr: str, [keepbreaks: int]): str[0..*] + + + inputstr: The string to be split. + keepbreaks: When True, line breaks are preserved in the output array (default = False). + + + Dim a as Variant + a = SF_String.SplitLines("Line1" & Chr(10) & "Line2" & Chr(13) & "Line3") + ' a = Array("Line1", "Line2", "Line3") + a = SF_String.SplitLines("Line1" & Chr(10) & "Line2" & Chr(13) & "Line3" & Chr(10)) + ' a = Array("Line1", "Line2", "Line3", "") + a = SF_String.SplitLines("Line1" & Chr(10) & "Line2" & Chr(13) & "Line3" & Chr(10), KeepBreaks := True) + ' a = Array("Line1\n", "Line2\r", "Line3\n", "") + +
+ +
+ SplitNotQuoted ---------------------------------------------------------------------------------------- + + String service;SplitNotQuoted + +

SplitNotQuoted

+ Splits a string into an array of elements using a specified delimiter. + If a quoted substring contains a delimiter, it is ignored. This is useful when parsing CSV-like records that contain quoted strings. + + + svc.SplitNotQuoted(inputstr: str, [delimiter: str], [occurrences: int], [quotechar: str]): str[0..*] + + + inputstr: The string to be split. + delimiter: A string of one or more characters that will be used as delimiter. The default delimiter is the Ascii space " " character. + occurrences: The maximum number of substrings to return. The default value is 0, meaning that there is no limit to the number of returned strings. + quotechar: Either the single (') or double (") quote. + + + + arr1 = SF_String.SplitNotQuoted("abc def ghi") + ' arr1 = Array("abc", "def", "ghi") + arr2 = SF_String.SplitNotQuoted("abc,""def,ghi""", ",") + ' arr2 = Array("abc", """def,ghi""") + arr3 = SF_String.SplitNotQuoted("abc,""def\"",ghi""", ",") + ' arr3 = Array("abc", """def\"",ghi""") + arr4 = SF_String.SplitNotQuoted("abc,""def\"",ghi"""",", ",") + ' arr4 = Array("abc", """def\"",ghi""", "") + + + + svc = CreateScriptService("String") + arr1 = svc.SplitNotQuoted('abc def ghi') + # arr1 = ('abc', 'def', 'ghi') + arr2 = svc.SplitNotQuoted('abc,"def,ghi"', ",") + # arr2 = ('abc', '"def,ghi"') + arr3 = svc.SplitNotQuoted(r'abc,"def\",ghi"', ",") + # arr3 = ('abc', '"def\\",ghi"') + arr4 = svc.SplitNotQuoted(r'abc,"def\",ghi"",', ",") + # arr4 = ('abc', '"def\\",ghi""', '') + + Beware of the differences between Basic and Python when representing strings. For example, in Basic two "" characters inside a string are interpreted as a single " character. In Python, strings enclosed with single quotes can contain " characters without having to double them. +
+ +
+ StartsWith -------------------------------------------------------------------------------------------- + + String service;StartsWith + +

StartsWith

+ Returns True if the first characters of a string are identical to a given substring. + This method returns False if either the input string or the substring have a length = 0 or when the substring is longer than the input string. + + + svc.StartsWith(inputstr: str, substring: str, [casesensitive: bool]): bool + + + inputstr: The string to be tested. + substring: The substring to be searched at the start of inputstr. + casesensitive: The search can be case sensitive or not (Default = False). + + + MsgBox SF_String.StartsWith("abcdefg", "ABC") 'True + MsgBox SF_String.StartsWith("abcdefg", "ABC", CaseSensitive := True) 'False + +
+ +
+ TrimExt ----------------------------------------------------------------------------------------------- + + String service;TrimExt + +

TrimExt

+ Returns the input string without its leading and trailing whitespaces. + + + svc.TrimExt(inputstr: str): str + + + inputstr: The string to trim. + + + MsgBox SF_String.TrimExt(" Some text. ") ' "Some text." + MsgBox SF_String.TrimExt(" ABCDEF" & Chr(9) & Chr(10) & Chr(13) & " ") ' "ABCDEF" + +
+ +
+ Unescape ---------------------------------------------------------------------------------------------- + + String service;Unescape + +

Unescape

+ Converts any escaped sequence (\\, \n, \r, \t) in the input string to their corresponding Ascii character. + + + svc.Unescape(inputstr: str): str + + + inputstr: The string to be converted. + + + MsgBox SF_String.Unescape("abc\n\tdef\\n") + ' "abc" & Chr(10) & Chr(9) & "def\n" + +
+ +
+ Unquote ----------------------------------------------------------------------------------------------- + + String service;Unquote + +

Unquote

+ Removes the single or double quotes enclosing the input string. + This is useful when parsing CSV-like records that contain quoted strings. + + + svc.Unquote(inputstr: str, [quotechar: str]): str + + + inputstr: The string to unquote. + quotechar: Either the single (') or double (") quote (default). + + + Dim s as String + ' s = "Some text" (without enclosing quotes) + s = SF_String.Unquote("""Some text""") + ' The string below does not have enclosing quotes, so it remains unchanged + ' s = "Some text" (unchanged) + s = SF_String.Unquote("Some text") + ' Quotes inside the string are not removed + ' s = "The ""true"" meaning" (unchanged) + s = SF_String.Unquote("The ""true"" meaning") + +
+ +
+ Wrap ------------------------------------------------------------------------------------------------- + + String service;Wrap + +

Wrap

+ Converts the input string into an array of substrings so that each item in the array has at most a given number of characters. + In practice, this method returns a zero-based array of output lines, without newlines at the end, except for the pre-existing line-breaks. + Tabs are expanded using the same procedure performed by the ExpandTabs method. + Symbolic line breaks are replaced by their equivalent Ascii characters. + If the wrapped output has no content, the returned array is empty. + + + svc.Wrap(inputstr: str, [width: int], [tabsize: int]): str + + + inputstr: The string to wrap. + width: The maximum number of characters in each line (Default = 70). + tabsize: Before wrapping the text, the existing TAB Chr(9) characters are replaced with spaces. The argument tabsize defines the TAB stops at TabSize + 1, 2 * TabSize + 1 , ... N * TabSize + 1 (Default = 8). + + + + a = "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..." + b = SF_String.Wrap(a, 20) + ' Array("Neque porro ", "quisquam est qui ", "dolorem ipsum quia ", "dolor sit amet, ", "consectetur, ", "adipisci velit...") + + + + a = "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..." + b = svc.Wrap(a, 20) + # ('Neque porro ', 'quisquam est qui ', 'dolorem ipsum quia ', 'dolor sit amet, ', 'consectetur, ', 'adipisci velit...') + +
+ + + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_textstream.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_textstream.xhp new file mode 100644 index 000000000..7505f09c2 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_textstream.xhp @@ -0,0 +1,376 @@ + + + + + + + ScriptForge.TextStream service + /text/sbasic/shared/03/sf_textstream.xhp + + + + + +
+ + TextStream service + +
+ +
+

ScriptForge.TextStream service

+ The TextStream service is used to sequentially read from and write to files opened or created using the ScriptForge.FileSystem service. + The methods OpenTextFile and CreateTextFile from the FileSystem service return an instance of the TextStream service. +
+ Line delimiters may be specified by the user. In input operations CR, LF or CR+LF are supported. In output operations, the default line delimiter is the one used by the operating system. + The line delimiter for the operating system where the macro is being executed can be accessed using the SF_String.sfNEWLINE property. + All operations needed to read from or write to a file (open, read/write and close) are presumed to happen during the same macro run. + +

Service invocation

+ The examples below in Basic and Python use the OpenTextFile method to create an instance of the TextStream Service. + + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim FSO As Variant + FSO = CreateScriptService("FileSystem") + Set myFile = FSO.OpenTextFile("C:\Temp\ThisFile.txt", FSO.ForReading) + + The file must be closed with the CloseFile method after all read or write operations have been executed: + + myFile.CloseFile() + + Optionally, the resources used by the TextStream instance can be released using the Dispose method: + + Set myFile = myFile.Dispose() + + The methods in the TextStream service are mostly based on the XTextInputStream and XTextOutputStream UNO interfaces. + + + from scriptforge import CreateScriptService + fs = CreateScriptService("FileSystem") + myFile = fs.OpenTextFile(r"C:\Temp\ThisFile.txt", fs.ForReading) + # ... + myFile.CloseFile() + myFile = myFile.Dispose() + + +

Properties

+ + TextStream service;AtEndOfStream + TextStream service;Encoding + TextStream service;FileName + TextStream service;IOMode + TextStream service;Line + TextStream service;NewLine + + + + + Name + + + Readonly + + + Type + + + Description + + + + + AtEndOfStream + + + Yes + + + Boolean + + + Used in read mode. A True value indicates that the end of the file has been reached. A test using this property should precede calls to the ReadLine method. + + + + + Encoding + + + Yes + + + String + + + The character set to be used. The default encoding is "UTF-8". + + + + + FileName + + + Yes + + + String + + + Returns the name of the current file either in URL format or in the native operating system's format, depending on the current value of the FileNaming property of the FileSystem service. + + + + + IOMode + + + Yes + + + String + + + Indicates the input/output mode. Possible values are "READ", "WRITE" or "APPEND". + + + + + Line + + + Yes + + + Long + + + Returns the number of lines read or written so far. + + + + + NewLine + + + No + + + String + + + Sets or returns the current delimiter to be inserted between two successive written lines. The default value is the native line delimiter in the current operating system. + + +
+ To learn more about the names of character sets, visit IANA's Character Set page. Beware that %PRODUCTNAME does not implement all existing character sets. + + + List of Methods in the TextStream Service + + + + + CloseFile
+ ReadAll
+
+
+ + + ReadLine
+ SkipLine
+
+
+ + + WriteBlankLines
+ WriteLine
+
+
+
+
+ +
+ CloseFile ------------------------------------------------------------------------------------------ + + TextStream service;CloseFile + +

CloseFile

+ Closes the current input or output stream and empties the output buffer if relevant. Returns True if the file was successfully closed. + + + myFile.CloseFile(): bool + +
+ +
+ ReadAll -------------------------------------------------------------------------------------------- + + TextStream service;ReadAll + +

ReadAll

+ Returns all the remaining lines in the text stream as a single string. Line breaks are not removed. + The resulting string can be split in lines either by using the Split built-in Basic function if the line delimiter is known, or with the SF_String.SplitLines method. + For large files, using the ReadAll method wastes memory resources. In such cases it is recommended to read the file line by line using the ReadLine method. + + + myFile.ReadAll(): str + + + Consider the text file "Students.txt" with the following contents (a name in each line): + + Herbie Peggy + Hardy Jarrett + Edith Lorelle + Roderick Rosamund + Placid Everette + + The examples below in Basic and Python use the ReadAll and SplitLines methods to read the contents of the file into an array of strings: + + + 'Loads the FileSystem service + Dim FSO : FSO = CreateScriptService("FileSystem") + 'Opens the text file with the names to be read + Dim inputFile as Object + Set inputFile = FSO.OpenTextFile("/home/user/Documents/Students.txt") + 'Reads all the contents in the input file as a single string + Dim allData as String + allData = inputFile.ReadAll() + 'Splits the string into an array + Dim arrNames as Variant + arrNames = SF_String.SplitLines(allData) + ' (...) + inputFile.CloseFile() + + + + fs = CreateScriptService("FileSystem") + inputFile = fs.OpenTextFile("/home/user/Documents/Students.txt") + allData = inputFile.ReadAll() + arrNames = allData.split(inputFile.NewLine) + # ... + inputFile.CloseFile() + +
+ +
+ ReadLine ------------------------------------------------------------------------------------------- + + TextStream service;ReadLine + +

ReadLine

+ Returns the next line in the text stream as a string. Line breaks are removed from the returned string. + The AtEndOfStream test should precede the ReadLine method like in the example below. + An error will be raised if the AtEndOfStream was reached during the previous ReadLine or SkipLine method call. + + + myFile.ReadLine(): str + + + + + Dim sLine As String + Do While Not myFile.AtEndOfStream + sLine = myFile.ReadLine() + ' (...) + Loop + + + + while not myFile.AtEndOfStream: + sLine = myFile.ReadLine() + # ... + +
+ +
+ SkipLine ------------------------------------------------------------------------------------------- + + TextStream service;SkipLine + +

SkipLine

+ Skips the next line in the input stream when reading a TextStream file. + This method can result in AtEndOfStream being set to True. + + + myFile.SkipLine() + +
+ +
+ WriteBlankLines ------------------------------------------------------------------------------------ + + TextStream service;WriteBlankLines + +

WriteBlankLines

+ Writes a specified number of empty lines to the output stream. + + + myFile.WriteBlankLines(lines: int) + + + lines: The number of empty lines to write to the file. +
+ +
+ WriteLine ------------------------------------------------------------------------------------------ + + TextStream service;WriteLine + +

WriteLine

+ Writes the given string to the output stream as a single line. + The character defined in the NewLine property is used as the line delimiter. + + + myFile.WriteLine(line: str) + + + line: The line to write, may be empty. + + The examples below in Basic and Python create a text file in CSV format in which each line contains a value and its square until lastValue is reached. + + + Sub SquaredValuesFile(lastValue as Integer) + 'Instantiates the FileSystem Service + Dim FSO as Variant : FSO = CreateScriptService("FileSystem") + 'Creates a text file + Dim myFile as Variant : myFile = FSO.CreateTextFile("/home/user/Documents/squares.csv") + 'Writes the Value and Value squared, separated by ";" + Dim value as Integer + myFile.WriteLine("Value;Value Squared") + For value = 1 To lastValue + myFile.WriteLine(value & ";" & value ^ 2) + Next value + 'Closes the file and free resources + myFile.CloseFile() + Set myFile = myFile.Dispose() + End Sub + + + + def squared_values_file(lastValue): + fs = CreateScriptService("FileSystem") + myFile = fs.CreateTextFile("/home/user/Documents/squares.csv") + myFile.WriteLine("Value;Value Squared") + for value in range(1, lastValue + 1): + myFile.WriteLine("{};{}".format(value, value ** 2)) + myFile.CloseFile() + myFile = myFile.Dispose() + +
+ + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_timer.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_timer.xhp new file mode 100644 index 000000000..b3c2ea2dd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_timer.xhp @@ -0,0 +1,315 @@ + + + + + + + ScriptForge.Timer service + /text/sbasic/shared/03/sf_timer.xhp + + + + +
+ + Timer service + +
+ +
+

ScriptForge.Timer service

+ The Timer service measures the amount of time it takes to run user scripts. + A Timer measures durations. It can be: + + + Started, to indicate when to start measuring time. + + + Suspended, to pause measuring running time. + + + Resumed, to continue tracking running time after the Timer has been suspended. + + + Restarted, which will cancel previous measurements and start the Timer at zero. + + +
+ Durations are expressed in seconds with a precision of 3 decimal digits (milliseconds). A duration value of 12.345 means 12 seconds and 345 milliseconds + +

Service invocation

+ Before using the Timer service the ScriptForge library needs to be loaded or imported: + + + + The example below creates a Timer object named myTimer and starts it immediately. + + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Dim myTimer As Variant + myTimer = CreateScriptService("Timer", True) + 'The timer starts immediately when the second argument = True, default = False + + It is recommended to free resources after use: + + Set myTimer = myTimer.Dispose() + + + + from scriptforge import CreateScriptService + myTimer = CreateScriptService("Timer", start = True) + # ... + myTimer = myTimer.Dispose() + + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + Duration + + + Yes + + + Double + + + The actual running time elapsed since start or between start and stop (does not consider suspended time) + + + + + IsStarted + + + Yes + + + Boolean + + + True when timer is started or suspended + + + + + IsSuspended + + + Yes + + + Boolean + + + True when timer is started and suspended + + + + + SuspendDuration + + + Yes + + + Double + + + The actual time elapsed while suspended since start or between start and stop + + + + + TotalDuration + + + Yes + + + Double + + + The actual time elapsed since start or between start and stop (including suspensions and running time) + + +
+ Note that the TotalDuration property is equivalent to summing the Duration and SuspendDuration properties. + +

Methods

+ All methods do not require arguments and return a Boolean value. + If the returned value is False, then nothing happened. + + Timer service;Continue + Timer service;Restart + Timer service;Start + Timer service;Suspend + Timer service;Terminate + + + + + Name + + + Description + + + Returned value + + + + + Continue + + + Resumes the Timer if it has been suspended + + + False if the timer is not suspended + + + + + Restart + + + Terminates the Timer and discards its current property values, restarting as a new clean Timer + + + False if the timer is inactive + + + + + Start + + + Starts a new clean timer + + + False if the timer is already started + + + + + Suspend + + + Suspends a running timer + + + False if the timer is not started or already suspended + + + + + Terminate + + + Stops a running timer + + + False if the timer is neither started nor suspended + + +
+ + + The examples below in Basic and Python illustrate the use of the methods and properties in the Timer service. + + + myTimer.Start() + Wait 500 + myTimer.Suspend() + 'The time elapsed while the Dialog box is open will be counted as suspended time + MsgBox myTimer.Duration & " " & myTimer.SuspendDuration & " " & myTimer.TotalDuration + myTimer.Continue() + Wait 500 + 'The time elapsed while the Dialog box is open will be counted as running time + MsgBox myTimer.Duration & " " & myTimer.SuspendDuration & " " & myTimer.TotalDuration + myTimer.Terminate() + 'Shows the final time measurements + MsgBox myTimer.Duration & " " & myTimer.SuspendDuration & " " & myTimer.TotalDuration + + If you call the Terminate method, subsequent calls for the Continue method will not resume time measurement. Similarly, after a Timer has been terminated, calling the Start method will restart it as if it were a clean new Timer. + + + from time import sleep + bas = CreateScriptService("Basic") + myTimer.Start() + sleep(0.5) + myTimer.Suspend() + bas.MsgBox("{} {} {}".format(myTimer.Duration, myTimer.SuspendDuration, myTimer.TotalDuration)) + myTimer.Continue() + sleep(0.5) + bas.MsgBox("{} {} {}".format(myTimer.Duration, myTimer.SuspendDuration, myTimer.TotalDuration)) + myTimer.Terminate() + bas.MsgBox("{} {} {}".format(myTimer.Duration, myTimer.SuspendDuration, myTimer.TotalDuration)) + + Beware that the Wait function in Basic takes in a duration argument in milliseconds whereas the sleep function in Python uses seconds in its argument. + +

Working with Multiple Timers

+ It is possible to instantiate multiple Timer services in parallel, which gives flexibility in measuring time in different parts of the code. + The following example illustrates how to create two Timer objects and start them separately. + + + Dim myTimerA as Variant, myTimerB as Variant + myTimerA = CreateScriptService("Timer") + myTimerB = CreateScriptService("Timer") + 'Starts myTimerA + myTimerA.Start() + Wait 1000 'Wait 1 second (1,000 milliseconds) + MsgBox myTimerA.Duration & " " & myTimerB.Duration + 'Starts myTimerB + myTimerB.Start() + Wait 1000 + MsgBox myTimerA.Duration & " " & myTimerB.Duration + 'Terminate both timers + myTimerA.Terminate() + myTimerB.Terminate() + + + + from time import sleep + myTimerA = CreateScriptService("Timer") + myTimerB = CreateScriptService("Timer") + myTimerA.Start() + sleep(1) + bas.MsgBox("{} {}".format(myTimerA.Duration, myTimerB.Duration)) + myTimerB.Start() + sleep(1) + bas.MsgBox("{} {}".format(myTimerA.Duration, myTimerB.Duration)) + myTimerA.Terminate() + myTimerB.Terminate() + + + + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_ui.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_ui.xhp new file mode 100644 index 000000000..313577f48 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_ui.xhp @@ -0,0 +1,704 @@ + + + + + + + ScriptForge.UI service + /text/sbasic/shared/03/sf_ui.xhp + + + +
+ + UI service + + +

ScriptForge.UI service

+ +The UI (User Interface) service simplifies the identification and the manipulation of the different windows composing the whole %PRODUCTNAME application: + + + Windows selection + + + Windows moving and resizing + + + Statusbar settings + + + Display of a floating progress bar + + + Creation of new windows + + + Access to the underlying "documents" + + +
+ +The UI service is the starting point to open, create or access to the content of new or existing documents from a user script. + +

Definitions

+ +
+

WindowName

+ A window can be designated using various ways: + + + a full path and file name + + + the last component of the full file name or even only the last component without its suffix + + + the title of the window + + + for new documents, something like "Untitled 1" + + + one of the special windows "BASICIDE" and "WELCOMESCREEN" + + + The window name is case-sensitive. +

Document object

+
+ The methods CreateDocument, CreateBaseDocument, GetDocument, OpenBaseDocument and OpenDocument, described below, generate document objects. When a window contains a document, an instance of the Document class represents that document. A counterexample the Basic IDE is not a document but is a window in our terminology. Additionally a document has a type: Calc, Impress, Writer, ... + The specific properties and methods applicable on documents are implemented in a document class. + The implementation of the document objects class is done in the SFDocuments associated library. See its "Document" service. + +

Service invocation

+ Before using the UI service the ScriptForge library needs to be loaded or imported: + + + + + Dim ui As Variant + GlobalScope.BasicLibraries.LoadLibrary("ScriptForge") + Set ui = CreateScriptService("UI") + + + + from scriptforge import CreateScriptService + ui = CreateScriptService("UI") + + +

Properties

+ + + + Name + + + ReadOnly + + + Type + + + Description + + + + + ActiveWindow + + + Yes + + + String + + + a valid and unique WindowName for the currently active window. When the window cannot be identified, a zero-length string is returned. + + + + + Documents + + + Yes + + + String array + + + The list of the currently open documents. Special windows are ignored. This list consists of a zero-based one dimensional array either of filenames (in SF_FileSystem.FileNaming notation) or of window titles for unsaved documents. + + + + + Height + + + Yes + + + Integer + + + Returns the height of the active window in pixels. + + + + + Width + + + Yes + + + Integer + + + Returns the width of the active window in pixels. + + + + + X + + + Yes + + + Integer + + + Returns the X coordinate of the active window, which is the distance to the left edge of the screen in pixels. + + + + + Y + + + Yes + + + Integer + + + Returns the Y coordinate of the active window, which is the distance to the top edge of the screen in pixels. This value does not consider window decorations added by your operating system, so even when the window is maximized this value may not be zero. + + +
+ +
+

Constants

+ + + + Name + + + Value + + + Description + + + + + MACROEXECALWAYS + + + 2 + + + Macros are always executed + + + + + MACROEXECNEVER + + + 1 + + + Macros are never executed + + + + + MACROEXECNORMAL + + + 0 + + + Macro execution depends on user settings + + +
+
+ + + The examples below show a MsgBox with the names of all currently open documents. + + + Dim openDocs as Object, strDocs as String + Set openDocs = ui.Documents() + strDocs = openDocs(0) + For i = 1 to UBound(openDocs) + strDocs = strDocs & Chr(10) & openDocs(i) + Next i + MsgBox strDocs + + + + ui = CreateScriptService("UI") + bas = CreateScriptService("Basic") + openDocs = ui.Documents() + strDocs = "\n".join(openDocs) + bas.MsgBox(strDocs) + + + + + List of Methods in the UI Service + + + + Activate
+ CreateBaseDocument
+ CreateDocument (*)
+ GetDocument
+ Maximize +
+ + Minimize
+ OpenBaseDocument
+ OpenDocument (*)
+ Resize

+
+ + RunCommand
+ SetStatusBar (*)
+ ShowProgressBar
+ WindowExists

+
+
+
+Note, as an exception, that the methods marked (*) are not applicable to Base documents. + +
+ Activate -------------------------------------------------------------------------------------------------------------------------- + + UI service;Activate + +

Activate

+ Make the specified window active. The method returns True if the given window is found and can be activated. There is no change in the actual user interface if no window matches the selection. + + + svc.Activate(windowname: str): bool + + + windowname: see the definitions above. + + + + ui.Activate("C:\Documents\My file.odt") + + + + ui.Activate(r"C:\Documents\My file.odt") + +
+ +
+ CreateBaseDocument -------------------------------------------------------------------------------------------------------------------------- + + UI service;CreateBaseDocument + +

CreateBaseDocument

+ Creates and stores a new %PRODUCTNAME Base document embedding an empty database of the given type. The method returns a Document service instance. + + + svc.CreateBaseDocument(filename: str, embeddeddatabase: str = 'HSQLDB', registrationname: str = '', opt calcfilename: str): svc + + + filename : Identifies the file to create. It must follow the SF_FileSystem.FileNaming notation. If the file already exists, it is overwritten without warning + embeddeddatabase : Either "HSQLDB" (default), "FIREBIRD" or "CALC". + registrationname : The name used to store the new database in the databases register. When = "" (default), no registration takes place. If the name already exists it is overwritten without warning. + calcfilename : Only when embeddeddatabase = "CALC", calcfilename represents the file containing the tables as Calc sheets. The file must exist or an error is raised. + + + + Dim myBase As Object, myCalcBase As Object + Set myBase = ui.CreateBaseDocument("C:\Databases\MyBaseFile.odb", "FIREBIRD") + Set myCalcBase = ui.CreateBaseDocument("C:\Databases\MyCalcBaseFile.odb", _ + "CALC", , "C:\Databases\MyCalcFile.ods") + + + + myBase = ui.CreateBaseDocument(r"C:\Databases\MyBaseFile.odb", "FIREBIRD") + myCalcBase = ui.CreateBaseDocument(r"C:\Databases\MyCalcBaseFile.odb", \ + "CALC", calcfilename = r"C:\Databases\MyCalcFile.ods") + +
+ +
+ CreateDocument -------------------------------------------------------------------------------------------------------------------------- + + UI service;CreateDocument + +

CreateDocument (*)

+ Create a new %PRODUCTNAME document of a given type or based on a given template. The method returns a document object. + + + svc.CreateDocument(documenttype: str = '', templatefile: str = '', hidden: bool = False): svc + + + documenttype : "Calc", "Writer", etc. If absent, the templatefile argument must be present. + templatefile : The full FileName of the template to build the new document on. If the file does not exist, the argument is ignored. The FileSystem service provides the TemplatesFolder and UserTemplatesFolder properties to help to build the argument. + hidden: if True, open the new document in the background (default = False). To use with caution: activation or closure afterwards can only happen programmatically. + + In both examples below, the first call to CreateDocument method creates a blank Calc document, whereas the second creates a document from a template file. + + + Dim myDoc1 As Object, myDoc2 As Object, FSO As Object + Set myDoc1 = ui.CreateDocument("Calc") + Set FSO = CreateScriptService("FileSystem") + Set myDoc2 = ui.CreateDocument(, FSO.BuildPath(FSO.TemplatesFolder, "personal/CV.ott")) + + + + myDoc1 = ui.CreateDocument("Calc") + fs = CreateScriptService("FileSystem") + myDoc2 = ui.CreateDocument(templatefile = fs.BuildPath(fs.TemplatesFolder, "personal/CV.ott")) + +
+ +
+ GetDocument -------------------------------------------------------------------------------------------------------------------------- + + UI service;GetDocument + +

GetDocument

+ Returns an open document object referring to either the active window, a given window or the active document. + + svc.GetDocument(windowname: str = ''): svc + svc.GetDocument(windowname: uno): svc + + windowname: See the definitions above. If this argument is absent, the active window is used. UNO objects of types com.sun.star.lang.XComponent or com.sun.star.comp.dba.ODatabaseDocument are also accepted. Thus passing ThisComponent or ThisDatabaseDocument as argument creates a new SFDocuments.Document, Base or Calc service. + + + + + Dim myDoc As Object + Set myDoc = ui.GetDocument("C:\Documents\My file.odt") + Set myBase = ui.GetDocument(ThisDatabaseDocument) + + + + from scriptforge import CreateScriptService + bas = CreateScriptService("Basic") + myDoc = ui.GetDocument(r"C:\Documents\My file.odt") + myDoc = ui.GetDocument(bas.ThisComponent) + + To access the name of the currently active window, refer to the ActiveWindow property. +
+ +
+ Maximize -------------------------------------------------------------------------------------------------------------------------- + + UI service;Maximize + +

Maximize

+ Maximizes the active window or the given window. + + + svc.Maximize(windowname: str) + + + windowname: see the definitions above. If this argument is absent, the active window is maximized. + + + + ui.Maximize("Untitled 1") + + + + ui.Maximize("Untitled 1") + +
+ +
+ Minimize -------------------------------------------------------------------------------------------------------------------------- + + UI service;Minimize + +

Minimize

+ Minimizes the active window or the given window. + + + svc.Minimize(windowname: str) + + + windowname: see the definitions above. If this argument is absent, the active window is minimized. + + + + ui.Minimize() + + + + ui.Minimize() + +
+ +
+ OpenBaseDocument -------------------------------------------------------------------------------------------------------------------------- + + UI service;OpenBaseDocument + +

OpenBaseDocument

+ Open an existing %PRODUCTNAME Base document. The method returns a document object. + + + svc.OpenBaseDocument(filename: str = '', registrationname: str = '', macroexecution: int = 0): svc + + + filename: Identifies the file to open. It must follow the SF_FileSystem.FileNaming notation. + registrationname: The name to use to find the database in the databases register. It is ignored if FileName <> "". + macroexecution: 0 = behaviour is defined by the user configuration, 1 = macros are not executable, 2 = macros are executable. + + + + Dim myBase As Object + Set myBase = ui.OpenBaseDocument("C:\Documents\myDB.odb", MacroExecution := ui.MACROEXECALWAYS) + + + + ui.OpenBaseDocument(r"C:\Documents\myDB.odb", macroexecution = ui.MACROEXECALWAYS) + + To improve code readability you can use predefined constants for the macroexecution argument, as in the examples above. +
+ +
+ OpenDocument -------------------------------------------------------------------------------------------------------------------------- + + UI service;OpenDocument + +

OpenDocument (*)

+ Opens an existing %PRODUCTNAME document with the given options. Returns a document object or one of its subclasses. The method returns Nothing (in Basic) / None (in Python) if the opening failed, even when the failure is caused by a user decision. + + + svc.Opendocument(filename: str, password: str = '', readonly: bool = False, hidden: bool = False, macroexecution: int = 0, filtername: str = '', filteroptions: str = ''): svc + + + filename: Identifies the file to open. It must follow the FileNaming notation of the FileSystem service. + password: To use when the document is protected. If wrong or absent while the document is protected, the user will be prompted to enter a password. + readonly: Default = False. + hidden: if True, open the new document in the background (default = False). To use with caution: activation or closure afterwards can only happen programmatically. + macroexecution: 0 = behaviour is defined by the user configuration, 1 = macros are not executable, 2 = macros are executable. + filtername: The name of a filter that should be used for loading the document. If present, the filter must exist. + filteroptions: An optional string of options associated with the filter. + + + + Dim myDoc As Object, FSO As Object + Set myDoc = ui.OpenDocument("C:\Documents\myFile.odt", ReadOnly := True) + + + + ui.OpenDocument(r"C:\Documents\myFile.odt", readonly = True) + +
+ +
+ Resize -------------------------------------------------------------------------------------------------------------------------- + + UI service;Resize + +

Resize

+ Resizes and/or moves the active window. Absent and negative arguments are ignored. If the window is minimized or maximized, calling Resize without arguments restores it. + + + svc.Resize(left: int = -1, top: int = -1, width: int = -1, height: int = -1) + + + left, top: Distances of the top-left corner from top and left edges of the screen, in pixels. + width, height: New dimensions of the window, in pixels. + + In the following examples, the width and height of the window are changed while top and left are left unchanged. + + + ui.Resize(, ,500, 500) + + + + ui.Resize(width = 500, height = 500) + + To resize a window that is not active, first activate it using the Activate method. +
+ +
+ RunCommand --------------------------------------------------------------------------------------------- + + UI service;RunCommand + +

RunCommand

+ Runs a UNO command on the current window. A few typical commands are: Save, SaveAs, ExportToPDF, Undo, Copy, Paste, etc. + Commands can be run with or without arguments. Arguments are not validated before running the command. If the command or its arguments are invalid, then nothing will happen. + For a complete list of UNO commands that can be run in %PRODUCTNAME, refer to the Wiki page Development/DispatchCommands. + + + svc.RunCommand(command: str, [args: any]) + + + command: Case-sensitive string containing the UNO command name. The inclusion of the prefix ".uno:" in the command is optional. The command itself is not checked for correctness. If nothing happens after the command call, then the command is probably wrong. + args: For each argument to be passed to the command, specify a pair containing the argument name and value. + + + The following example runs the .uno:About command in the current window. + + Set ui = CreateScriptService("UI") + ui.RunCommand("About") + + Below is an example that runs the UNO command .uno:BasicIDEAppear and passes the arguments required to open the Basic IDE at a specific line of a module. + + ' Arguments passed to the command: + ' Document = "LibreOffice Macros & Dialogs" + ' LibName = "ScriptForge" + ' Name = "SF_Session" + ' Line = 600 + ui.RunCommand(".uno:BasicIDEAppear", "Document", "LibreOffice Macros & Dialogs", _ + "LibName", "ScriptForge", "Name", "SF_Session", "Line", 600) + + Note that calling the command BasicIDEAppear without arguments will simply open the Basic IDE. + + + ui = CreateScriptService("UI") + ui.RunCommand("About") + + + ui.RunCommand(".uno:BasicIDEAppear", "Document", "LibreOffice Macros & Dialogs", \ + "LibName", "ScriptForge", "Name", "SF_Session", "Line", 600) + + In Python it is also possible to call RunCommand using keyword arguments: + + ui.RunCommand(".uno:BasicIDEAppear", Document = "LibreOffice Macros & Dialogs", \ + LibName = "ScriptForge", Name = "SF_Session", Line = 600) + + Each %PRODUCTNAME component has its own set of commands available. One easy way to learn commands is going to Tools - Customize - Keyboard. When you position your mouse over a function in the Function list, a tooltip will appear with the corresponding UNO command. +
+ +
+ SetStatusbar -------------------------------------------------------------------------------------------------------------------------- + + UI service;SetStatusbar + +

SetStatusbar (*)

+ Display a text and a progressbar in the status bar of the active window. Any subsequent calls in the same macro run refer to the same status bar of the same window, even if the window is not visible anymore. A call without arguments resets the status bar to its normal state. + + + svc.SetStatusbar(text: str = '', percentage: int = -1) + + + text: An optional text to be displayed in front of the progress bar. + percentage: an optional degree of progress between 0 and 100. + + + + Dim i As Integer + For i = 0 To 100 + ui.SetStatusbar("Progress ...", i) + Wait 50 + Next i + ' Resets the statusbar + ui.SetStatusbar + + + + from time import sleep + for i in range(101): + ui.SetStatusbar("Test:", i) + sleep(0.05) + ui.SetStatusbar() + +
+ +
+ ShowProgressBar -------------------------------------------------------------------------------------------------------------------------- + + UI service;ShowProgressBar + +

ShowProgressBar

+ Displays a non-modal dialog box. Specify its title, an explicatory text and a percentage of progress to be represented on a progressbar. The dialog will remain visible until a call to the method without arguments or until the user manually closes the dialog. + + + svc.ShowProgressBar(title: str = '', text: str = '', percentage: str = -1) + + + title : The title appearing on top of the dialog box. Default = "ScriptForge". + text: An optional text to be displayed above the progress bar. + percentage: an optional degree of progress between 0 and 100. + + + + Dim i As Integer + For i = 0 To 100 + ui.ShowProgressBar("Window Title", "Progress ..." & i & "/100", i) + Wait 50 + Next i + ' Closes the Progress Bar window + ui.ShowProgressBar + + + + from time import sleep + for i in range(101): + ui.ShowProgressBar("Window Title", "Progress ... " + str(i) + "/100", i) + sleep(0.05) + # Closes the Progress Bar window + ui.ShowProgressBar() + +
+ +
+ WindowExists -------------------------------------------------------------------------------------------------------------------------- + + UI service;WindowExists + +

WindowExists

+ Returns True if the given window could be identified. + + + svc.WindowExists(windowname: str): bool + + + windowname: see the definitions above. + + + + If ui.WindowExists("C:\Document\My file.odt") Then + ' ... + + + + if ui.WindowExists(r"C:\Document\My file.odt"): + # ... + +
+ +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_unittest.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_unittest.xhp new file mode 100644 index 000000000..80ce5c834 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_unittest.xhp @@ -0,0 +1,818 @@ + + + + + + SFUnitTests.UnitTest service + /text/sbasic/shared/03/sf_unittest.xhp + + + +
+ + UnitTest service + +
+
+

SFUnitTests.UnitTest service

+ The UnitTest service provides a framework for automating unit tests using the Basic language, including the ability to: + + + Aggregate test cases into test suites and unit tests. + + + Share setup and shutdown code among test cases. + + + Report test results using the Console. + + +
+ Both the unit tests and the code to be tested must be written in Basic. The code being tested may call functions written in other languages. + The UnitTest service is not available for Python scripts. + +

Definitions

+

Test Case

+ A test case is the individual unit of testing. It checks for a specific response to a particular set of inputs. + In the UnitTest service, a test case is represented by a single Basic Sub whose name starts with a common prefix (the default is "Test_"). + The test case fails if one of the AssertX methods returns False. +

Test Suite

+ A test suite is a collection of test cases that should be executed together. + All test cases of a test suite are stored in a single Basic module. + A test suite may implement the SetUp and TearDown methods to prepare for test cases in its module. +

Unit Test

+ A full unit test consists of a set of test suites in the same Basic library. + +

Service invocation

+ Before using the UnitTest service the ScriptForge library needs to be loaded or imported: + +

Simple mode

+ Invoke the service in simple mode to call AssertX functions without having to build the full hierarchy of test suites and test cases. + In simple mode, the service is invoked inside the test case, as shown in the example below: + + Sub SimpleTest + On Local Error GoTo CatchError + Dim myTest As Variant + myTest = CreateScriptService("UnitTest") + ' A few dummy tests + myTest.AssertEqual(1 + 1, 2) + myTest.AssertEqual(1 - 1, 0) + MsgBox("All tests passed") + Exit Sub + CatchError: + myTest.ReportError("A test failed") + End Sub + + In this example, if any of the AssertEqual calls fail, the interpreter will go to the CatchError label and report the error by calling the ReportError method. +

Full mode

+ When invoked in full mode, the service creation is external to the test code and all tests are organized into test cases and test suites inside a single library. + The following example creates a UnitTest instance whose tests are located inside the current document (ThisComponent) in the "Tests" library. + + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + Dim myUnitTest As Variant + myUnitTest = CreateScriptService("UnitTest", ThisComponent, "Tests") + +

A minimalist example in full mode

+ Consider that a ODS file has a module named "MathUtils" in its "Standard" library with the following code: + + ' Code in module Standard.MathUtils + Function Sum(a, b) As Double + Sum = a + b + End Function + + Function Multiply(a, b) As Double + Multiply = a * b + End Function + + To create a full test suite, consider that a new library named "Tests" is created in the file with a single module "AllTests" containing the code below: + + ' Code in module Tests.AllTests + Sub Main() + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + Dim test As Variant + test = CreateScriptService("UnitTest", ThisComponent, "Tests") + test.RunTest("AllTests") + test.Dispose() + End Sub + + Sub Setup(test) + ' Preparation code ran prior to the first test case + Dim exc As Variant + exc = CreateScriptService("Exception") + exc.Console(Modal := False) + End Sub + + Sub TearDown(test) + ' Optional cleanup code called after the last test case + End Sub + + Sub Test_Sum(test) + On Local Error GoTo CatchError + test.AssertEqual(Sum(1, 1), 2, "Sum two positive integers") + test.AssertEqual(Sum(-10, 20), 10, "Sum of negative and positive integers") + test.AssertEqual(Sum(1.5, 1), 2.5, "Sum of float and integer values") + Exit Sub + CatchError: + test.ReportError("Sum method is broken") + End Sub + + Sub Test_Multiply(test) + On Local Error GoTo CatchError + test.AssertEqual(Multiply(2, 2), 4, "Multiply two positive integers") + test.AssertEqual(Multiply(-4, 2), -8, "Multiply negative and positive integers") + test.AssertEqual(Multiply(1.5, 3), 4.5, "Multiply of float and integer values") + Exit Sub + CatchError: + test.ReportError("Multiply method is broken") + End Sub + + The test suite above consists of two test cases Test_Sum and Test_Multiply. To run all tests simply run the Main method from the "AllTests" module. + The Console from the Exception service is used as the default output to print test results. After running the example above, the following output will be displayed in the console: + + ' RUNTEST ENTER testsuite='Tests.AllTests', pattern='Test_*' + ' SETUP Tests.AllTests.Setup() ENTER + ' SETUP Tests.AllTests.Setup() EXIT + ' TESTCASE Tests.AllTests.Test_Multiply() ENTER + ' TESTCASE Tests.AllTests.Test_Multiply() EXIT (0,017 sec) + ' TESTCASE Tests.AllTests.Test_Sum() ENTER + ' TESTCASE Tests.AllTests.Test_Sum() EXIT (0,016 sec) + ' TEARDOWN Tests.AllTests.TearDown() ENTER + ' TEARDOWN Tests.AllTests.TearDown() EXIT + ' RUNTEST EXIT testsuite='Tests.AllTests' (0,223 sec) + + If any of the AssertEqual methods fails during these tests, an error message is added to the console. + + + Region service;LongMessage + Region service;ReturnCode + Region service;Verbose + Region service;WhenAssertionFails + + +

Properties

+ + + + Name + + + Readonly + + + Type + + + Description + + + + + LongMessage + + + No + + + Boolean + + + When set to True (default) the console shows the standard message appended to the message provided by the tester. When False, only the message defined by the tester is used. + + + + + ReturnCode + + + Yes + + + Integer + + + Value returned by RunTest after the unit test is finished. Next is a list of possible values: + 0 - Test finished without errors or test not started
+ 1 - An assertion within a test case returned False
+ 2 - A SkipTest was issued by the Setup method or by one of the test cases.
+ 3 - Abnormal end of test
+
+
+ + + Verbose + + + No + + + Boolean + + + When set to True, all assertions are reported in the console (failing or not). When False (default), only failing assertions are reported. + + + + + WhenAssertionFails + + + No + + + Integer + + + Defines what is done when an assertion fails. Next is a list of possible values: + 0 - Ignore the failure and continue running the test
+ 1 - The TearDown method in the module is executed in the current test suite and the next suite is started (default in full mode).
+ 2 - Stop immediately (default in simple mode)
+
+
+
+ + + + List of Methods in the UnitTest Service + + + + + AssertAlmostEqual
+ AssertEqual
+ AssertFalse
+ AssertGreater
+ AssertGreaterEqual
+ AssertIn
+ AssertIsInstance
+ AssertIsNothing
+ AssertLike
+
+
+ + + AssertNotRegex
+ AssertIsNull
+ AssertLess
+ AssertLessEqual
+ AssertNotAlmostEqual
+ AssertNotEqual
+ AssertNotIn
+ AssertNotInstance
+ AssertNotLike
+
+
+ + + AssertNotNothing
+ AssertNotNull
+ AssertRegex
+ AssertTrue
+ Fail
+ Log
+ ReportError
+ RunTest
+ SkipTest
+
+
+
+
+ +

Arguments of the AssertX methods

+ All assertions test one or two expressions, referred in the remainder of this help page as A and B. They are always the first one or two arguments in the AssertX method. + All AssertX methods accept a message argument specifying a custom message to be reported in the console regarding the assertion. By default an empty string is used. This argument is always in the last position of the assertion. + Some AssertX methods also accept additional arguments, as described by their syntaxes below. + +
+ AssertAlmostEqual -------------------------------------------------------------------------------------- + + UnitTest service;AssertAlmostEqual + +

AssertAlmostEqual

+ Returns True when A and B are numerical values and are considered to be close to each other, given a relative tolerance. + + + svc.AssertAlmostEqual(a: any, b: any, tolerance: double = 1E-09, message: str = ""): bool + + This assertion returns True if the two conditions below are met: + + + A and B can be converted to the Double type. + + + The absolute difference between A and B divided by the largest absolute value of A or B is lower than the value specified in tolerance. + + +
+ +
+ AssertEqual -------------------------------------------------------------------------------------------- + + UnitTest service;AssertEqual + +

AssertEqual

+ Returns True when A and B are considered to be equal. + + + svc.AssertEqual(a: any, b: any, message: str = ""): bool + + When A and B are scalars, True is returned if: + + + Both expressions have the same VarType or are both numeric. + + + Booleans and numeric values are compared with the = operator. + + + Strings are compared with the builtin StrComp function. The comparison is case-sensitive. + + + Dates and times are compared up to the second. + + + Null, Empty and Nothing are not equal, but AssertEqual(Nothing, Nothing) returns True. + + + UNO objects are compared with the builtin EqualUnoObjects method. + + + Note that Basic objects are never equal. + + + When A and B are arrays, True is returned if: + + + Both arrays have the same number of dimensions (up to 2 dimensions) and their lower and upper bounds are identical for all dimensions. + + + All items in both arrays are equal, one by one. + + + Two empty arrays are considered to be equal. + + +
+ +
+ AssertFalse -------------------------------------------------------------------------------------------- + + UnitTest service;AssertFalse + +

AssertFalse

+ Returns True when the type of A is Boolean and its value is False. + + + svc.AssertFalse(a: any, message: str = ""): bool + +
+ +
+ AssertGreater ------------------------------------------------------------------------------------------ + + UnitTest service;AssertGreater + +

AssertGreater

+ Returns True when A is greater than B. + + + svc.AssertGreater(a: any, b: any, message: str = ""): bool + + The comparison between A and B assumes the following: + + + Eligible data types are String, Date or numeric. + + + Both expressions must have the same VarType or both must be numeric. + + + String comparisons are case-sensitive. + + +
+ +
+ AssertGreaterEqual ------------------------------------------------------------------------------------- + + UnitTest service;AssertGreaterEqual + +

AssertGreaterEqual

+ Returns True when A is greater than or equal to B. + + + svc.AssertGreaterEqual(a: any, b: any, message: str = ""): bool + + The comparison between A and B assumes the following: + + + Eligible data types are String, Date or numeric. + + + Both expressions must have the same VarType or both must be numeric. + + + String comparisons are case-sensitive. + + +
+ +
+ AssertIn ----------------------------------------------------------------------------------------------- + + UnitTest service;AssertIn + +

AssertIn

+ Returns True when A is found in B. + + + svc.AssertIn(a: any, b: any, message: str = ""): bool + + This assertion assumes the following: + + + Expression B may be a 1D array, a ScriptForge Dictionary object or a string. + + + When expression B is a 1D array, expression A may be a date or a numeric value. + + + When expression B is a ScriptForge Dictionary object, then string A is searched for among the keys in B. + + + String comparisons are case-sensitive. + + +
+ +
+ AssertIsInstance --------------------------------------------------------------------------------------- + + UnitTest service;AssertIsInstance + +

AssertIsInstance

+ Returns True when A is an instance of a specified object type, specified as a string containing the type name. + + + svc.AssertIsInstance(a: any, objecttype: str, message: str = ""): bool + + Expression A may be one of the following: + + + A ScriptForge object. In this case, the objecttype argument is a string such as "DICTIONARY", "calc", "Dialog", etc. + + + A UNO object. In this case, the objecttype argument must be a string identical to the value returned by the SF_Session.UnoObjectType() method. + + + An Array. In this case, the objecttype argument is expected to be "array". + + + Any other variable (neither an Object nor an Array). In this case, objecttype is a string matching the value returned by the builtin TypeName function. + + +
+ +
+ AssertIsNothing ---------------------------------------------------------------------------------------- + + UnitTest service;AssertIsNothing + +

AssertIsNothing

+ Returns True when A is an object that has the Nothing value. + + + svc.AssertIsNothing(a: any, message: str = ""): bool + +
+ +
+ AssertIsNull ------------------------------------------------------------------------------------------- + + UnitTest service;AssertIsNull + +

AssertIsNull

+ Returns True when A has the Null value. + + + svc.AssertIsNull(a: any, message: str = ""): bool + +
+ +
+ AssertLess --------------------------------------------------------------------------------------------- + + UnitTest service;AssertLess + +

AssertLess

+ Returns True when A is less than B. + + + svc.AssertLess(a: any, b: any, message: str = ""): bool + + The comparison between A and B assumes the following: + + + Eligible data types are String, Date or numeric. + + + Both expressions must have the same VarType or both must be numeric. + + + String comparisons are case-sensitive. + + +
+ +
+ AssertLessEqual ---------------------------------------------------------------------------------------- + + UnitTest service;AssertLessEqual + +

AssertLessEqual

+ Returns True when A is less than or equal to B. + + + svc.AssertLessEqual(a: any, b: any, message: str = ""): bool + + The comparison between A and B assumes the following: + + + Eligible data types are String, Date or numeric. + + + Both expressions must have the same VarType or both must be numeric. + + + String comparisons are case-sensitive. + + +
+ +
+ AssertLike --------------------------------------------------------------------------------------------- + + UnitTest service;AssertLike + +

AssertLike

+ Returns True if string A matches a given pattern containing wildcards. + + + svc.AssertLike(a: any, pattern: str = "", message: str = ""): bool + + The following wildcards are accepted: + + + ? - Represents any single character. + + + * - Represents zero, one, or multiple characters. + + +
+ +
+ AssertNotAlmostEqual ----------------------------------------------------------------------------------- + + UnitTest service;AssertNotAlmostEqual + +

AssertNotAlmostEqual

+ Returns True when A and B are numerical values and are not considered to be close to each other, given a relative tolerance. + + + svc.AssertNotAlmostEqual(a: any, b: any, tolerance: double = 1E-09, message: str = ""): bool + + This assertion returns True if the two conditions below are met: + + + A and B can be converted to the Double type. + + + The absolute difference between A and B divided by the largest absolute value of A or B is greater than the value specified in tolerance. + + +
+ +
+ AssertNotEqual ----------------------------------------------------------------------------------------- + + UnitTest service;AssertNotEqual + +

AssertNotEqual

+ Returns True when A and B are not considered to be equal. + + + svc.AssertNotEqual(a: any, b: any, message: str = ""): bool + + This method works both for scalars and arrays. Read the instructions in AssertEqual for more information on what equality means in this assertion. +
+ +
+ AssertNotIn -------------------------------------------------------------------------------------------- + + UnitTest service;AssertNotIn + +

AssertNotIn

+ Returns True when A (a string) is not found in B. + + + svc.AssertNotIn(a: any, b: any, message: str = ""): bool + + Read the instructions in AssertIn for more information on the assumptions of this method. +
+ +
+ AssertNotInstance -------------------------------------------------------------------------------------- + + UnitTest service;AssertNotInstance + +

AssertNotInstance

+ Returns True when A is not an instance of a specified object type. + + + svc.AssertNotInstance(a: any, objecttype: str, message: str = ""): bool + + Read the instructions in AssertIsInstance for more information on the assumptions of this method. +
+ +
+ AssertNotLike ------------------------------------------------------------------------------------------ + + UnitTest service;AssertNotLike + +

AssertNotLike

+ Returns True if string A does not match a given pattern containing wildcards. + + + svc.AssertNotLike(a: any, pattern: str = "", message: str = ""): bool + + Read the instructions in AssertLike for more information on the assumptions of this method. +
+ +
+ AssertNotNothing --------------------------------------------------------------------------------------- + + UnitTest service;AssertNotNothing + +

AssertNotNothing

+ Returns True except when A is an object that has the Nothing value. + + + svc.AssertNotNothing(a: any, message: str = ""): bool + +
+ +
+ AssertNotNull ------------------------------------------------------------------------------------------ + + UnitTest service;AssertNotNull + +

AssertNotNull

+ Returns True except when A has the Null value. + + + svc.AssertNotNull(a: any, message: str = ""): bool + +
+ +
+ AssertNotRegex ----------------------------------------------------------------------------------------- + + UnitTest service;AssertNotRegex + +

AssertNotRegex

+ Returns True when A is not a string or does not match the given regular expression. + + + svc.AssertNotRegex(a: any, regex: str = "", message: str = ""): bool + + The comparison is case-sensitive. +
+ +
+ AssertRegex -------------------------------------------------------------------------------------------- + + UnitTest service;AssertRegex + +

AssertRegex

+ Returns True when string A matches the given regular expression. + + + svc.AssertRegex(a: any, regex: str = "", message: str = ""): bool + + The comparison is case-sensitive. +
+ +
+ AssertTrue --------------------------------------------------------------------------------------------- + + UnitTest service;AssertTrue + +

AssertTrue

+ Returns True when expression A is a Boolean and its value is True. + + + svc.AssertTrue(a: any, message: str = ""): bool + +
+ +
+ Fail --------------------------------------------------------------------------------------------------- + + UnitTest service;Fail + +

Fail

+ Forces a test case to fail. + + + svc.Fail(message: str = "") + + A message can be provided to be reported in the console. +
+ +
+ Log ---------------------------------------------------------------------------------------------------- + + UnitTest service;Log + +

Log

+ Writes the specified message in the console. + + + svc.Log(message: str = "") + + A message can be provided to be reported in the console. +
+ +
+ ReportError -------------------------------------------------------------------------------------------- + + UnitTest service;ReportError + +

ReportError

+ Displays a message box with a message and the current property values of the Exception service. + This method is commonly used in the exception handling section of the Sub containing the test case, which is reached when an assertion fails or when the Fail method is called. + + + svc.ReportError(message: str = "") + + Depending on the value of the property WhenAssertionFails, the test execution may continue or be interrupted. + When writing test cases it is recommended to include a call to the ReportError method in the exception handling section of the Sub. + If the property LongMessage is equal to True, the specified message is followed by the standard error message description. Otherwise only the message is displayed. +
+ +
+ RunTest ------------------------------------------------------------------------------------------------ + + UnitTest service;RunTest + +

RunTest

+ Executes the complete test suite implemented in the specified module. Each test case is run independently from each other. + Running a test suite consists of: + + + Executing the optional Setup method present in the module. + + + Executing once each test case, in no specific order. + + + Executing the optional TearDown method present in the module. + + + + + svc.RunTest(testsuite: str, testcasepattern: str = "", message: str = ""): int + + The argument testcasepattern specifies a pattern composed of "?" and "*" wildcards to select which test cases will be run. The comparison is not case-sensitive. + If a message is provided, it is written to the console when the test starts. +
+ +
+ SkipTest ----------------------------------------------------------------------------------------------- + + UnitTest service;SkipTest + +

SkipTest

+ Interrupts the running test suite without calling the TearDown method. + Skipping a test is usually meaningful during the Setup method when not all conditions to run the test are met. + It is up to the Setup method to exit the Sub shortly after the SkipTest call. + If SkipTest is called from within a test case, the execution of the test suite is interrupted and the remaining test cases are not run. Keep in mind that the order in which test cases are run is arbitrary within a test suite. + + + svc.SkipTest(message: str = "") + + If a message is provided, it is written to the console. +
+ +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_writer.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_writer.xhp new file mode 100644 index 000000000..d4ea1bdfc --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03/sf_writer.xhp @@ -0,0 +1,189 @@ + + + + + + + SFDocuments.Writer service + /text/sbasic/shared/03/sf_writer.xhp + + + + +
+ + Writer service + +
+ +
+

SFDocuments.Writer service

+ The SFDocuments shared library provides a number of methods and properties to facilitate the management and handling of %PRODUCTNAME documents. + Some methods are generic for all types of documents and are inherited from the SF_Document module, whereas other methods that are specific for Writer documents are defined in the SF_Writer module. + To be done: list with the main features of the Writer service. +
+ +

Service invocation

+ Before using the Writer service the ScriptForge library needs to be loaded or imported: + + + The Writer service is closely related to the UI service of the ScriptForge library. Below are a few examples of how the Writer service can be invoked. + + The code snippet below creates a Writer service instance that corresponds to the currently active Writer document. + + Dim oDoc As Object + Set oDoc = CreateScriptService("SFDocuments.Writer", "Untitled 1") ' Default = ActiveWindow + + Another way to create an instance of the Writer service is using the UI service. In the following example, a new Writer document is created and oDoc is a Writer service instance: + + Dim ui As Object, oDoc As Object + Set ui = CreateScriptService("UI") + Set oDoc = ui.CreateDocument("Writer") + + Or using the OpenDocument method from the UI service: + + Set oDoc = ui.OpenDocument("C:\Me\MyFile.odt") + + It is also possible to instantiate the Writer service using the CreateScriptService method: + + Dim oDoc As Object + Set oDoc = CreateScriptService("SFDocuments.Writer", "MyFile.odt") + + In the example above, "MyFile.odt" is the name of an open document window. If this argument is not provided, the active window is considered. + It is recommended to free resources after use: + + Set oDoc = oDoc.Dispose() + + However, if the document was closed using the CloseDocument method, it becomes unnecessary to free resources using the command described above. + + + myDoc = CreateScriptService("Writer") ' Default = ActiveWindow + + + ui = CreateScriptService("UI") + myDoc = ui.CreateDocument("Writer") + + + myDoc = ui.OpenDocument(r"C:\Documents\MyFile.odt") + + + myDoc = CreateScriptService("SFDocuments.Writer", "MyFile.odt") + myDoc.Dispose() + + The use of the prefix "SFDocuments." while calling the service is optional. + +

Definitions

+ TBD + +

Properties

+ +

Methods

+ + + List of Methods in the Writer Service + + + + + Forms
+
+
+ + + PrintOut
+
+
+ + +
+
+
+
+
+ +
+ Forms --------------------------------------------------------------------- + + Document service;Forms + +

Forms

+ Depending on the parameters provided this method will return: + + + A zero-based Array (or a tuple in Python) with the names of all the forms contained in the document (if the form argument is absent) + + + A SFDocuments.Form service instance representing the form specified as argument. + + + This method is applicable only for Writer documents. Calc and Base documents have their own Forms method in the Calc and Base services, respectively. + + + svc.Forms(): str[0..*] + + + svc.Forms(form: str = ''): svc + + + svc.Forms(form: int): svc + + + form: The name or index corresponding to a form stored in the document. If this argument is absent, the method will return a list with the names of all forms available in the document. + + In the following examples, the first line gets the names of all forms in the document and the second line retrieves the Form object of the form named "Form_A". + + + Set FormNames = oDoc.Forms() + Set FormA = oDoc.Forms("Form_A") + + + + form_names = doc.Forms() + form_A = doc.Forms("Form_A") + +
+ +
+ PrintOut -------------------------------------------------------------------------------------------------------------------------- + + Writer service;PrintOut + +

PrintOut

+ Send the contents of the document to the printer. The printer may be previously defined by default, by the user or by the SetPrinter method of the Document service. Returns True when successful. + + + svc.PrintOut(opt pages: str = "", opt copies: num = 1, opt printbackground: bool = True, opt printblankpages: bool = False, opt printevenpages: bool = True, opt printoddpages: bool = True, opt printimages: bool = True): bool + + + pages: The pages to print as a string, like in the user interface. Example: "1-4;10;15-18". Default = all pages + copies: The number of copies, default is 1. + printbackground: Prints the background image when True (default). + printblankpages: When False (default), omits empty pages. + printevenpages: Prints even pages when True (default). + printoddpages: Print odd pages when True (default). + printimages: Print graphic objects when True (default). + + + + oDoc.PrintOut("1-4;10;15-18", Copies := 2, PrintImages := False) + + + + doc.PrintOut(printblankpages = True, copies = 3) + +
+ + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03000000.xhp b/helpcontent2/source/text/sbasic/shared/03000000.xhp new file mode 100644 index 000000000..b9f2c0ad2 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03000000.xhp @@ -0,0 +1,50 @@ + + + + + + + Run-Time Functions + /text/sbasic/shared/03000000.xhp + + + + + + +
+ +

Run-Time Functions

+This section describes the Runtime Functions of %PRODUCTNAME Basic. +
+ + + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010000.xhp b/helpcontent2/source/text/sbasic/shared/03010000.xhp new file mode 100644 index 000000000..f885f1846 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010000.xhp @@ -0,0 +1,41 @@ + + + + + + + + +Screen I/O Functions +/text/sbasic/shared/03010000.xhp + + +Sun Microsystems, Inc. + + + +
+

Screen I/O Functions

+ This section describes the Runtime Functions used to call dialogs for the input and output of user entries. +
+ + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010100.xhp b/helpcontent2/source/text/sbasic/shared/03010100.xhp new file mode 100644 index 000000000..42f45eb1d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010100.xhp @@ -0,0 +1,43 @@ + + + + + + + + +Display Functions +/text/sbasic/shared/03010100.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Display Functions + This section describes Runtime functions used to output information to the screen display. +
+ + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010101.xhp b/helpcontent2/source/text/sbasic/shared/03010101.xhp new file mode 100644 index 000000000..9eed147d5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010101.xhp @@ -0,0 +1,227 @@ + + + + + + + MsgBox Statement + /text/sbasic/shared/03010101.xhp + + + + +
+ + MsgBox statement + + +

MsgBox Statement

+Displays a dialog box containing a message. +
+ + + + MsgBox prompt As String [,buttons = MB_OK [,title As String]] + response = MsgBox( prompt As String [,buttons = MB_OK [,title As String]]) + + +
+ +
+ prompt: String expression displayed as a message in the dialog box. Line breaks can be inserted with Chr$(13). + title: String expression displayed in the title bar of the dialog. If omitted, the title bar displays the name of the respective application. + buttons: Any integer expression that specifies the dialog type, as well as the number and type of buttons to display, and the icon type. buttons represents a combination of bit patterns, that is, a combination of elements can be defined by adding their respective values: +
+ +
+ + + + Named constant + + + Integer value + + + Definition + + + + + MB_OK + + + 0 + + + Display OK button only. + + + + + MB_OKCANCEL + + + 1 + + + Display OK and Cancel buttons. + + + + + MB_ABORTRETRYIGNORE + + + 2 + + + Display Abort, Retry, and Ignore buttons. + + + + + MB_YESNOCANCEL + + + 3 + + + Display Yes, No, and Cancel buttons. + + + + + MB_YESNO + + + 4 + + + Display Yes and No buttons. + + + + + MB_RETRYCANCEL + + + 5 + + + Display Retry and Cancel buttons. + + + + + MB_ICONSTOP + + + 16 + + + Add the Stop icon to the dialog. + + + + + MB_ICONQUESTION + + + 32 + + + Add the Question icon to the dialog. + + + + + MB_ICONEXCLAMATION + + + 48 + + + Add the Exclamation Point icon to the dialog. + + + + + MB_ICONINFORMATION + + + 64 + + + Add the Information icon to the dialog. + + + + + + + + 128 + + + First button in the dialog as default button. + + + + + MB_DEFBUTTON2 + + + 256 + + + Second button in the dialog as default button. + + + + + MB_DEFBUTTON3 + + + 512 + + + Third button in the dialog as default button. + + +
+
+
+ + + + + + +Sub ExampleMsgBox + Const sText1 = "An unexpected error occurred." + Const sText2 = "The program execution will continue, however." + Const sText3 = "Error" + MsgBox(sText1 + Chr(13) + sText2,16,sText3) + MsgBox(sText1 + Chr(13) + sText2, MB_ICONSTOP, sText3) +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010102.xhp b/helpcontent2/source/text/sbasic/shared/03010102.xhp new file mode 100644 index 000000000..3317c1192 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010102.xhp @@ -0,0 +1,156 @@ + + + + + + + MsgBox Function + /text/sbasic/shared/03010102.xhp + + + + + + +
+ + MsgBox function + + + +

MsgBox Function

+Displays a dialog box containing a message and returns a value. +
+ + + +MsgBox (Prompt As String [,Buttons = MB_OK [,Title As String]]) As Integer + + + + + +Integer + + + + Named constant + + + Integer value + + + Definition + + + + + IDOK + + + 1 + + + OK + + + + + IDCANCEL + + + 2 + + + Cancel + + + + + IDABORT + + + 3 + + + Abort + + + + + IDRETRY + + + 4 + + + Retry + + + + + IDIGNORE + + + 5 + + + Ignore + + + + + IDYES + + + 6 + + + Yes + + + + + IDNO + + + 7 + + + No + + +
+ + + + +Example: + +Sub ExampleMsgBox +Dim sVar As Integer + sVar = MsgBox("Las Vegas") + sVar = MsgBox("Las Vegas",1) + sVar = MsgBox( "Las Vegas",256 + 16 + 2,"Dialog title") + sVar = MsgBox("Las Vegas", MB_DEFBUTTON2 + MB_ICONSTOP + MB_ABORTRETRYIGNORE, "Dialog title") +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010103.xhp b/helpcontent2/source/text/sbasic/shared/03010103.xhp new file mode 100644 index 000000000..c60a4925f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010103.xhp @@ -0,0 +1,97 @@ + + + + + + + Print# Statement + /text/sbasic/shared/03010103.xhp + + + + + +
+ + Print statement + Print statement; Tab function + Print statement; Spc function + Spc function; in Print statement + Tab function; in Print statement + + +

Print# Statement

+Outputs the specified strings or numeric expressions to the screen or to a sequential file. +
+ +Use Put# statement to write data to a binary or a random file. Use Write# statement to write data to a sequential text file with delimiting characters. + + +Print syntax + +Print [#filenum,] expression1[{;|,} [Spc(number As Integer);] [Tab(pos As Integer);] [expression2[...]] + + + + filenum: Any numeric expression that contains the file number that was set by the Open statement for the respective file.see i61758 + expression: Any numeric or string expression to be printed. Multiple expressions can be separated by a semicolon. If separated by a comma, the expressions are indented to the next tab stop. The tab stops cannot be adjusted. + number: Number of spaces to be inserted by the Spc function. + pos: Spaces are inserted until the specified position. +If a semicolon or comma appears after the last expression to be printed, $[officename] Basic stores the text in an internal buffer and continues program execution without printing. When another Print statement without a semicolon or comma at the end is encountered, all text to be printed is printed at once. +Positive numeric expressions are printed with a leading space. Negative expressions are printed with a leading minus sign. If a certain range is exceeded for floating-point values, the respective numeric expression is printed in exponential notation. +If the expression to be printed exceeds a certain length, the display will automatically wrap to the next line. +You can insert the Tab function, enclosed by semicolons, between arguments to indent the output to a specific position, or you can use the Spc function to insert a specified number of spaces. + + + + + +Sub ExamplePrint + Print "ABC" + Print "ABC","123" + i = FreeFile() + Open "C:\Users\ThisUser\Temp.txt" For Output As i + Print #i, "ABC" + Close #i +End Sub + + + + +Sub ExamplePrint + Print "ABC" + Print "ABC","123" + i = FreeFile() + Open "~/temp.txt" For Output As i + Print #i, "ABC" + Close #i +End Sub + + + + +
+ + + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010200.xhp b/helpcontent2/source/text/sbasic/shared/03010200.xhp new file mode 100644 index 000000000..73ea6aca3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010200.xhp @@ -0,0 +1,41 @@ + + + + + + + + +Functions for Screen Input +/text/sbasic/shared/03010200.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Functions for Screen Input + This section describes Runtime functions used to control screen input. +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010201.xhp b/helpcontent2/source/text/sbasic/shared/03010201.xhp new file mode 100644 index 000000000..598129fc4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010201.xhp @@ -0,0 +1,69 @@ + + + + + + + InputBox Function + /text/sbasic/shared/03010201.xhp + + + + + + +
+ + InputBox function + + +

InputBox Function

+Displays a prompt in a dialog at which the user can input text. The input is assigned to a variable. +
+The InputBox statement is a convenient method of entering text through a dialog. Confirm the input by clicking OK or pressing Return. The input is returned as the function return value. If you close the dialog with Cancel, InputBox returns a zero-length string (""). + + + +InputBox (Prompt As String[, Title As String[, Default As String[, xpostwips As Integer, ypostwips As Integer]]]) As String + + + +
+ prompt: String expression displayed as the message in the dialog box. + title: String expression displayed in the title bar of the dialog box. + default: String expression displayed in the text box as default if no other input is given. + xpostwips: Integer expression that specifies the horizontal position of the dialog. The position is an absolute coordinate and does not refer to the window of %PRODUCTNAME. + ypostwips: Integer expression that specifies the vertical position of the dialog. The position is an absolute coordinate and does not refer to the window of %PRODUCTNAME. +If xpostwips and ypostwips are omitted, the dialog is centered on the screen. The position is specified in twips. +
+ + +String + + + +Sub ExampleInputBox +Dim sText As String + sText = InputBox ("Please enter a phrase:","Dear User") + MsgBox ( sText , 64, "Confirmation of phrase") +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03010300.xhp b/helpcontent2/source/text/sbasic/shared/03010300.xhp new file mode 100644 index 000000000..ee93251cd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010300.xhp @@ -0,0 +1,43 @@ + + + + + +Color Functions +/text/sbasic/shared/03010300.xhp + + +Sun Microsystems, Inc. + + + + + +
+

Color Functions

+ This section describes Runtime functions used to define colors. +
+ + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010301.xhp b/helpcontent2/source/text/sbasic/shared/03010301.xhp new file mode 100644 index 000000000..c7a824885 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010301.xhp @@ -0,0 +1,69 @@ + + + + + + + Blue Function + /text/sbasic/shared/03010301.xhp + + + + + +
+ + Blue function + + +

Blue Function

+Returns the blue component of the specified composite color code. +
+ + + +Blue (Color As Long) + + + +Integer + + + Color value: Long integer expression that specifies any composite color code for which to return the blue component. +Under VBA compatibility mode (Option VBASupport 1), the function Blue() is incompatible with VBA colors, when color from previous call to function RGB [VBA] is passed. + + + + + + + + +Sub ExampleColor +Dim lVar As Long + lVar = rgb(128,0,200) + MsgBox "The color " & lVar & " consists of:" & Chr(13) &_ + "red= " & Red(lVar) & Chr(13)&_ + "green= " & Green(lVar) & Chr(13)&_ + "blue= " & Blue(lVar) & Chr(13) , 64,"colors" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010302.xhp b/helpcontent2/source/text/sbasic/shared/03010302.xhp new file mode 100644 index 000000000..752ffc517 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010302.xhp @@ -0,0 +1,68 @@ + + + + + + + Green Function + /text/sbasic/shared/03010302.xhp + + + + + + +
+ + Green function + + + +

Green Function

+Returns the Green component of the given composite color code. +
+ + + +Green (Color As Long) + + + +Integer + + + Color: Long integer expression that specifies a composite color code for which to return the Green component. + + + + + + +Sub ExampleColor +Dim lVar As Long + lVar = rgb(128,0,200) + MsgBox "The color " & lVar & " contains the components:" & Chr(13) &_ + "red = " & red(lVar) & Chr(13)&_ + "green = " & green(lVar) & Chr(13)&_ + "blue = " & blue(lVar) & Chr(13) , 64,"colors" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010303.xhp b/helpcontent2/source/text/sbasic/shared/03010303.xhp new file mode 100644 index 000000000..361a1e747 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010303.xhp @@ -0,0 +1,72 @@ + + + + + + + Red Function + /text/sbasic/shared/03010303.xhp + + + + + +
+ + Red function + + + +

Red Function

+Returns the Red component of the specified composite color code. +
+ + + +Red (ColorNumber As Long) + + + +Integer + + + ColorNumber: Long integer expression that specifies any composite color code for which to return the Red component. +Under VBA compatibility mode (Option VBASupport 1), the function Red() is incompatible with VBA colors, when color from previous call to function RGB [VBA] is passed. + + + + +
+ The color picker dialog details the red, green and blue components of a composite color code, as well as its hexadecimal expression. Changing the color of text and selecting Custom color displays the color picker dialog. +
+ + + +Sub ExampleColor +Dim lVar As Long + lVar = rgb(128,0,200) + MsgBox "The color " & lVar & " consists of:" & Chr(13) &_ + "red= " & red(lVar) & Chr(13)&_ + "green= " & green(lVar) & Chr(13)&_ + "blue= " & blue(lVar) & Chr(13) , 64,"colors" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010304.xhp b/helpcontent2/source/text/sbasic/shared/03010304.xhp new file mode 100644 index 000000000..78ad9233d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010304.xhp @@ -0,0 +1,80 @@ + + + + + + + QBColor Function + /text/sbasic/shared/03010304.xhp + + + + + +
+ + QBColor function + + +

QBColor Function

+Returns the RGB color code of the color passed as a color value through an older MS-DOS based programming system. +
+ + +QBColor (ColorNumber As Integer) + + +Long + + + ColorNumber: Any integer expression that specifies the color value of the color passed from an older MS-DOS based programming system. + ColorNumber can be assigned the following values: +0 : Black +1 : Blue +2 : Green +3 : Cyan +4 : Red +5 : Magenta +6 : Yellow +7 : White +8 : Gray +9 : Light Blue +10 : Light Green +11 : Light Cyan +12 : Light Red +13 : Light Magenta +14 : Light Yellow +15 : Bright White +This function is used only to convert from older MS-DOS based BASIC applications that use the above color codes. The function returns a long integer value indicating the color to be used in the $[officename] IDE. + + + + + +Sub ExampleQBColor +Dim iColor As Integer +Dim sText As String + iColor = 7 + sText = "RGB= " & Red(QBColor( iColor) ) & ":" & Blue(QBColor( iColor) ) & ":" & Green(QBColor( iColor) ) + MsgBox stext,0,"Color " & iColor +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010305.xhp b/helpcontent2/source/text/sbasic/shared/03010305.xhp new file mode 100644 index 000000000..6978f49a7 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010305.xhp @@ -0,0 +1,81 @@ + + + + + + + RGB Function + /text/sbasic/shared/03010305.xhp + + + + +
+ + RGB function + + +

RGB Function

+ Returns a Long integer color value consisting of red, green, and blue components. +
+ + + +RGB (Red, Green, Blue) + + + +Long + + +
+
+ red: Any integer expression that represents the red component (0-255) of the composite color. + green: Any integer expression that represents the green component (0-255) of the composite color. + blue: Any integer expression that represents the blue component (0-255) of the composite color. +
+The resulting Long value is calculated with the following formula:
+Result = red×65536 + green×256 + blue. +
+Under VBA compatibility mode (Option VBASupport 1), the Long value is calculated as +
+Result = red + green×256 + blue×65536
+See RGB Function [VBA] +
+ +The color picker dialog helps computing red, green and blue components of a composite color. Changing the color of text and selecting Custom color displays the color picker dialog. +
+ + + + + + +Sub ExampleColor +Dim lVar As Long + lVar = rgb(128,0,200) + MsgBox "The color " & lVar & " consists of:" & Chr(13) &_ + "red= " & red(lVar) & Chr(13)&_ + "green= " & green(lVar) & Chr(13)&_ + "blue= " & blue(lVar) & Chr(13) , 64,"colors" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03010306.xhp b/helpcontent2/source/text/sbasic/shared/03010306.xhp new file mode 100644 index 000000000..9dacef585 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03010306.xhp @@ -0,0 +1,68 @@ + + + + + + + RGB Function [VBA] + /text/sbasic/shared/03010306.xhp + + + + + +
+ + RGB function [VBA] + + +

RGB Function [VBA]

+Returns a Long integer color value consisting of red, green, and blue components, according to VBA color formula. +
+ + + +RGB (Red, Green, Blue) + + + +Long + + + +Because of the VBA compatibility mode (Option VBASupport 1), the Long value is calculated as
+Result = red + green×256 + blue×65536. +
+ + + + + + +Option VBASupport 1 +Sub ExampleRGBVBA +Dim lVar As Long + lVar = rgb(128,0,200) + Print lVar; ' returns 13107328 +End Sub + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020000.xhp b/helpcontent2/source/text/sbasic/shared/03020000.xhp new file mode 100644 index 000000000..e036d774f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020000.xhp @@ -0,0 +1,47 @@ + + + + + + + + + File I/O Functions + /text/sbasic/shared/03020000.xhp + + + Sun Microsystems, Inc. + + + +
+ File I/O Functions + Use File I/O functions to create and manage user-defined (data) files. +
+You can use these functions to support the creation of "relative" files, so that you can save and reload certain records by specifying their record number. File I/O functions can also help you manage your files by providing you with information such as file size, current path settings, or the creation date of a file or a directory. + + + + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03020100.xhp b/helpcontent2/source/text/sbasic/shared/03020100.xhp new file mode 100644 index 000000000..762a63e80 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020100.xhp @@ -0,0 +1,41 @@ + + + + + + + + +Opening and Closing Files +/text/sbasic/shared/03020100.xhp + + +Sun Microsystems, Inc. + + + +
+Opening and Closing Files +
+ + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020101.xhp b/helpcontent2/source/text/sbasic/shared/03020101.xhp new file mode 100644 index 000000000..78cb1907f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020101.xhp @@ -0,0 +1,60 @@ + + + + + + + Close Statement + /text/sbasic/shared/03020101.xhp + + + + + + +
+ + Close statement + + + +

Close Statement

+Closes a specified file that was opened with the Open statement. +
+ + + + Close Statement diagram + + +Close [[#]fileNum [, [#]fileNum2 [,...]]] + + + + fileNum: Any integer expression that specifies the number of the data channel that was opened with the Open statement. + + + + +
+ + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020102.xhp b/helpcontent2/source/text/sbasic/shared/03020102.xhp new file mode 100644 index 000000000..d906b6319 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020102.xhp @@ -0,0 +1,64 @@ + + + + + + + FreeFile Function + /text/sbasic/shared/03020102.xhp + + + + + + +
+ + FreeFile function + + + +FreeFile Function +Returns the next available file number for opening a file. Use this function to open a file using a file number that is not already in use by a currently open file. +
+ + + +FreeFile + + + +Integer + + +This function can only be used immediately in front of an Open statement. FreeFile returns the next available file number, but does not reserve it. + + + + + + + +
+ + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020103.xhp b/helpcontent2/source/text/sbasic/shared/03020103.xhp new file mode 100644 index 000000000..ddf55d217 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020103.xhp @@ -0,0 +1,128 @@ + + + + + + + Open Statement + /text/sbasic/shared/03020103.xhp + + + + + + +
+ + Open statement + + +

Open Statement

+Opens a data channel. +
+ + + + Open Statement diagram + + + access fragment diagram + + + locking fragment diagram + + +Open pathname For mode [Access io] [locking] As [#]filenum [Len=recLen] + + + + pathname: Path and name of the file to open. If you try to read a file that does not exist (Access = Read), an error message appears. If you try to write to a file that does not exist (Access = Write), a new file is created. + mode: Keyword that specifies the file mode. Valid values: Append (append to sequential file), Binary (data can be accessed by bytes using Get and Put), Input (opens data channel for reading), Output (opens data channel for writing), and Random (edits relative files). + io: Keyword that defines the access type. Valid values: Read (read-only), Write (write-only), Read Write (both). + locking: Keyword that defines the security status of a file after opening. Valid values: Shared (file may be opened by other applications), Lock Read (file is protected against reading), Lock Write (file is protected against writing), Lock Read Write (denies file access). + filenum: Any integer expression from 0 to 511 to indicate the number of a free data channel. You can then pass commands through the data channel to access the file. The file number must be determined by the FreeFile function immediately before the Open statement. + recLen: For Random access files, set the length of the records.#61736 +You can only modify the contents of a file that was opened with the Open statement. If you try to open a file that is already open, an error message appears. + + +
+ + + + Sub ExampleWorkWithAFile + Dim iNumber As Integer + Dim sLine As String + Dim aFile As String + Dim sMsg As String + aFile = "C:\Users\ThisUser\data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber + Print #iNumber, "This is a line of text" + Print #iNumber, "This is another line of text" + Close #iNumber + iNumber = Freefile + Open aFile For Input As iNumber + While Not eof(iNumber) + Line Input #iNumber, sLine + If sLine <>"" Then + sMsg = sMsg & sLine & chr(13) + End If + Wend + Close #iNumber + MsgBox sMsg + End Sub + + + + + Sub ExampleWorkWithAFile + Dim iNumber As Integer + Dim sLine As String + Dim aFile As String + Dim sMsg As String + aFile = "~/data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber + Print #iNumber, "This is a line of text" + Print #iNumber, "This is another line of text" + Close #iNumber + iNumber = Freefile + Open aFile For Input As iNumber + While Not eof(iNumber) + Line Input #iNumber, sLine + If sLine <>"" Then + sMsg = sMsg & sLine & chr(13) + End If + Wend + Close #iNumber + MsgBox sMsg + End Sub + + + +
+If the Open statement tries to open a file to which the current user does not have read/write permissions, an I/O error will be raised. +
+ + + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020104.xhp b/helpcontent2/source/text/sbasic/shared/03020104.xhp new file mode 100644 index 000000000..9d09da144 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020104.xhp @@ -0,0 +1,81 @@ + + + + + + + Reset Statement + /text/sbasic/shared/03020104.xhp + + + + + +
+ + Reset statement + + +

Reset Statement

+Closes all open files and writes the contents of all file buffers to the harddisk. +
+ + + + Reset Statement diagram + + +Reset + + + + +Sub ExampleReset +On Error GoTo ErrorHandler + Dim iNumber As Integer + Dim iCount As Integer + Dim sLine As String + Dim aFile As String + aFile = "C:\Users\ThisUser\data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber + Print #iNumber, "This is a new line of text" + Close #iNumber + iNumber = Freefile + Open aFile For Input As iNumber + For iCount = 1 To 5 + Line Input #iNumber, sLine + If sLine <>"" Then + Rem + End If + Next iCount + Close #iNumber + Exit Sub +ErrorHandler: + Reset + MsgBox "All files will be closed", 0, "Error" +End Sub + + +
+ + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020200.xhp b/helpcontent2/source/text/sbasic/shared/03020200.xhp new file mode 100644 index 000000000..2ae72fee0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020200.xhp @@ -0,0 +1,46 @@ + + + + + + + + +File Input/Output Functions +/text/sbasic/shared/03020200.xhp + + +Sun Microsystems, Inc. + + + +
+File Input/Output Functions +
+ + + + + + + + +see i61245 + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020201.xhp b/helpcontent2/source/text/sbasic/shared/03020201.xhp new file mode 100644 index 000000000..300451363 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020201.xhp @@ -0,0 +1,125 @@ + + + + + + + Get Statement + /text/sbasic/shared/03020201.xhp + + + + + +
+ + Get statement + + +

Get Statement

+Reads a record from a relative file, or a sequence of bytes from a binary file, into a variable. +
+See also: PUT Statement + + + + Get Statement diagram + + +Get [#]fileNum, [recordNum|filePos], variable + + + + fileNum: Any integer expression that determines the file number. + recordNum: For files opened in Random mode, recordNum is the number of the record that you want to read. +For files opened in Binary mode, filePos is the byte position in the file where the reading starts. +If recordNum and filePos are omitted, the current position or the current data record of the file is used. +variable: Name of the variable to be read. With the exception of object variables, you can use any variable type. + + +
+ + + + Sub ExampleRandomAccess + Dim iNumber As Integer + Dim sText As Variant ' Must be a variant + Dim aFile As String + aFile = "C:\Users\ThisUser\data.txt" + iNumber = Freefile + Open aFile For Random As #iNumber Len=32 + Seek #iNumber,1 ' Position at beginning + Put #iNumber, , "This is the first line of text" ' Fill line with text + Put #iNumber, , "This is the second line of text" + Put #iNumber, , "This is the third line of text" + Seek #iNumber,2 + Get #iNumber, , sText + Print sText + Close #iNumber + iNumber = Freefile + Open aFile For Random As #iNumber Len=32 + Get #iNumber, 2, sText + Put #iNumber, , "This is a new text" + Get #iNumber, 1, sText + Get #iNumber, 2, sText + Put #iNumber, 20, "This is the text in record 20" + Print Lof(#iNumber) + Close #iNumber + End Sub + + + + + Sub ExampleRandomAccess + Dim iNumber As Integer + Dim sText As Variant ' Must be a variant + Dim aFile As String + aFile = "~/data.txt" + iNumber = Freefile + Open aFile For Random As #iNumber Len=32 + Seek #iNumber,1 ' Position at beginning + Put #iNumber, , "This is the first line of text" ' Fill line with text + Put #iNumber, , "This is the second line of text" + Put #iNumber, , "This is the third line of text" + Seek #iNumber,2 + Get #iNumber, , sText + Print sText + Close #iNumber + iNumber = Freefile + Open aFile For Random As #iNumber Len=32 + Get #iNumber, 2, sText + Put #iNumber, , "This is a new text" + Get #iNumber, 1, sText + Get #iNumber, 2, sText + Put #iNumber, 20, "This is the text in record 20" + Print Lof(#iNumber) + Close #iNumber + End Sub + + + +
+ +
+ + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020202.xhp b/helpcontent2/source/text/sbasic/shared/03020202.xhp new file mode 100644 index 000000000..63adaa36d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020202.xhp @@ -0,0 +1,90 @@ + + + + + + + Input# Statement + /text/sbasic/shared/03020202.xhp + + + + + +
+ + Input statement + + +Input# Statement +Reads data from an open sequential file. +
+ + + + Input Statement diagram + + +Input #fileNum {,|;} var1 [, var2 [, ...]] + + + + fileNum: Number of the file that contains the data that you want to read. The file must be opened with the Open statement using the key word INPUT. + var: A numeric or string variable that you assign the values read from the opened file to. +The Input# statement reads numeric values or strings from an open file and assigns the data to one or more variables. A numeric variable is read up to the first carriage return (Asc=13), line feed (Asc=10), space, or comma. String variables are read to up to the first carriage return (Asc=13), line feed (Asc=10), or comma. +Data and data types in the opened file must appear in the same order as the variables that are passed in the "var" parameter. If you assign non-numeric values to a numeric variable, "var" is assigned a value of "0". +Records that are separated by commas cannot be assigned to a string variable. Quotation marks (") in the file are disregarded as well. If you want to read these characters from the file, use the Line Input# statement to read pure text files (files containing only printable characters) line by line. +If the end of the file is reached while reading a data element, an error occurs and the process is aborted. + + + +Sub ExampleWorkWithAFile + Dim iCount As Integer, sFileName As String + Dim sName As String, sValue As Integer + sFileName = "C:\Users\ThisUser\data.txt" + iCount = Freefile + ' Write data ( which we will read later with Input ) to file + Open sFileName For Output As iCount + sName = "Hamburg" : sValue = 200 + Write #iCount, sName, sValue + sName = "New York" : sValue = 300 + Write #iCount; sName, sValue + sName = "Miami" : sValue = 459 + Write #iCount, sName, sValue + Close #iCount + ' Read data file using Input + iCount = Freefile + Open sFileName For Input As iCount + Input #iCount, sName, sValue + MsgBox sName & " " & sValue + Input #iCount; sName, sValue + MsgBox sName & " " & sValue + Input #iCount, sName, sValue + MsgBox sName & " " & sValue + Close #iCount +End Sub + +
+ + + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020203.xhp b/helpcontent2/source/text/sbasic/shared/03020203.xhp new file mode 100644 index 000000000..117186268 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020203.xhp @@ -0,0 +1,61 @@ + + + + + + + Line Input# Statement + /text/sbasic/shared/03020203.xhp + + + + + +
+ + Line Input statement + + +

Line Input# Statement

+Reads a line from a sequential file into a variable. +
+ + + + Line Input Statement diagram + + +Line Input #fileNum, variable + + + + fileNum: Number of the file that contains the data that you want to read. The file must have been opened in advance with the Open statement using the key word INPUT. + variable: The name of the variable that stores the result. +With the Line Input# statement, you can read strings from an open file into a variable. String variables are read line-by-line up to the first carriage return (Asc=13) or linefeed (Asc=10). Line end marks are not included in the resulting string. + + + + +
+ + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020204.xhp b/helpcontent2/source/text/sbasic/shared/03020204.xhp new file mode 100644 index 000000000..c8b6bd14f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020204.xhp @@ -0,0 +1,66 @@ + + + + + + + Put# Statement + /text/sbasic/shared/03020204.xhp + + + + +
+ + Put statement + + +

Put# Statement

+Writes a record to a relative file or a sequence of bytes to a binary file. +
+ +Use Print# statement to print data to a sequential text file. Use Write# statement to write data to a sequential text file with delimiting characters. + + + + Put Statement diagram + + +Put [#]fileNum, [recordNum|filePos], variable + + + + fileNum: Any integer expression that defines the file that you want to write to. + recordNum, filePos: For relative files (random access files), the number of the record that you want to write. +For binary files (binary access), the position of the byte in the file where you want to start writing. + variable: Name of the variable that you want to write to the file. +Note for relative files: If the contents of this variable does not match the length of the record that is specified in the Len clause of the Open statement, the space between the end of the newly written record and the next record is padded with existing data from the file that you are writing to. +Note for binary files: The contents of the variables are written to the specified position, and the file pointer is inserted directly after the last byte. No space is left between the records. + + + + +
+ + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020205.xhp b/helpcontent2/source/text/sbasic/shared/03020205.xhp new file mode 100644 index 000000000..f97195397 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020205.xhp @@ -0,0 +1,103 @@ + + + + + + + Write Statement + /text/sbasic/shared/03020205.xhp + + + + + +
+ + Write statement + + +

Write# Statement

+Writes data to a sequential text file with delimiting characters. +
+ +Use Print# statement to print data to a sequential text file. Use Put# statement to write data to a binary or a random file. + + + + Write Statement diagram + + +Write [#fileNum] {,|;} expression [, …] + + + + fileNum: Any numeric expression that contains the file number that was set by the Open statement for the respective file. + expression list: Variables or expressions that you want to enter in a file, separated by commas. +If the expression list is omitted, the Write statement appends an empty line to the file. +To add an expression list to a new or an existing file, the file must be opened in the Output or Append mode. +Strings that you write are enclosed by quotation marks and separated by commas. You do not need to enter these delimiters in the expression list. +Each Write statement outputs a line end symbol as last entry. +Numbers with decimal delimiters are converted according to the locale settings. + + + + + + Sub ExampleWrite + Dim iCount As Integer + Dim sValue As String + iCount = Freefile + Open "C:\Users\ThisUser\data.txt" For Output As iCount + sValue = "Hamburg" + Write #iCount,sValue,200 + sValue = "New York" + Write #iCount,sValue,300 + sValue = "Miami" + Write #iCount,sValue,450 + Close #iCount + End Sub + + + + + Sub ExampleWrite + Dim iCount As Integer + Dim sValue As String + iCount = Freefile + Open "~/data.txt" For Output As iCount + sValue = "Hamburg" + Write #iCount,sValue,200 + sValue = "New York" + Write #iCount,sValue,300 + sValue = "Miami" + Write #iCount,sValue,450 + Close #iCount + End Sub + + + + +
+ + + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020301.xhp b/helpcontent2/source/text/sbasic/shared/03020301.xhp new file mode 100644 index 000000000..2c681a0aa --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020301.xhp @@ -0,0 +1,66 @@ + + + + + + + Eof Function + /text/sbasic/shared/03020301.xhp + + + + + + +
+ + Eof function + + + +Eof Function +Determines if the file pointer has reached the end of a file. +
+ + + +Eof (intexpression As Integer) + + + +Bool + + + Intexpression: Any integer expression that evaluates to the number of an open file. +Use EOF to avoid errors when you attempt to get input past the end of a file. When you use the Input or Get statement to read from a file, the file pointer is advanced by the number of bytes read. When the end of a file is reached, EOF returns the value "True" (-1). + + + + + + + +
+ + + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020302.xhp b/helpcontent2/source/text/sbasic/shared/03020302.xhp new file mode 100644 index 000000000..cba83b1a6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020302.xhp @@ -0,0 +1,54 @@ + + + + + + + + +Loc Function +/text/sbasic/shared/03020302.xhp + + +Sun Microsystems, Inc. + + + +
+Loc function + +Loc Function +Returns the current position in an open file. +
+Syntax: + +Loc(FileNumber) + +Return value: +Long +Parameters: + +FileNumber: Any numeric expression that contains the file number that is set by the Open statement for the respective file. +If the Loc function is used for an open random access file, it returns the number of the last record that was last read or written. +For a sequential file, the Loc function returns the position in a file divided by 128. For binary files, the position of the last read or written byte is returned. + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020303.xhp b/helpcontent2/source/text/sbasic/shared/03020303.xhp new file mode 100644 index 000000000..3741e50cf --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020303.xhp @@ -0,0 +1,63 @@ + + + + + + + + +Lof Function +/text/sbasic/shared/03020303.xhp + + +Sun Microsystems, Inc. + + + +
+Lof function + +Lof Function +Returns the size of an open file in bytes. +
+ + +Lof (FileNumber) As Long + + +Long + + +FileNumber: Any numeric expression that contains the file number that is specified in the Open statement. +To obtain the length of a file that is not open, use the FileLen function. + + + + + + + +
+ + + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03020304.xhp b/helpcontent2/source/text/sbasic/shared/03020304.xhp new file mode 100644 index 000000000..464b09feb --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020304.xhp @@ -0,0 +1,52 @@ + + + + + + + + +Seek Function +/text/sbasic/shared/03020304.xhp + + +Sun Microsystems, Inc. + + + +
+Seek function + +Seek Function +Returns the position for the next writing or reading in a file that was opened with the open statement. +
+For random access files, the Seek function returns the number of the next record to be read. +For all other files, the function returns the byte position at which the next operation is to occur. +See also: Open, Seek. +Syntax: + +Seek (FileNumber) + +Return value: +Long +Parameters: + +FileNumber: The data channel number used in the Open statement. + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020305.xhp b/helpcontent2/source/text/sbasic/shared/03020305.xhp new file mode 100644 index 000000000..9ff8727fd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020305.xhp @@ -0,0 +1,61 @@ + + + + + + +Seek# Statement +/text/sbasic/shared/03020305.xhp + + +Sun Microsystems, Inc. + + + +Seek statement + +

Seek Statement

+Sets the position for the next writing or reading in a file that was opened with the Open statement.see #61751 +For random access files, the Seek statement sets the number of the next record to be accessed. +For all other files, the Seek statement sets the byte position at which the next operation is to occur. + + + + Seek Statement diagram + + +Seek [#]filePos, {filePos|recordNum} + + +Parameters: + +fileNum: The data channel number used in the Open statement. + +filePos, recordNum: Position for the next writing or reading. Position can be a number between 1 and 2,147,483,647. According to the file type, the position indicates the number of the record (files in the Random mode) or the byte position (files in the Binary, Output, Append or Input mode). The first byte in a file is position 1, the second byte is position 2, and so on. + + + + +
+ + Seek function +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020400.xhp b/helpcontent2/source/text/sbasic/shared/03020400.xhp new file mode 100644 index 000000000..27592c63a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020400.xhp @@ -0,0 +1,56 @@ + + + + + + + + +Managing Files +/text/sbasic/shared/03020400.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Managing Files + The functions and statements for managing files are described here. +
+ + + + + + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020401.xhp b/helpcontent2/source/text/sbasic/shared/03020401.xhp new file mode 100644 index 000000000..42f721d4d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020401.xhp @@ -0,0 +1,77 @@ + + + + + + + ChDir Statement + /text/sbasic/shared/03020401.xhp + + + + + +
+ + ChDir statement + + +

ChDir Statement

+Changes the current directory or drive. +
+ +
+ Some DOS-specific file and directory functions are no longer provided in %PRODUCTNAME, or their function is only limited. For example, support for the ChDir, ChDrive and CurDir functions is not provided. Some DOS-specific properties are no longer used in functions that expect file properties as parameters (for example, to differentiate from concealed files and system files). This ensures the greatest possible level of platform independence for %PRODUCTNAME. Therefore this feature is subject to removal in a future release. +
+ +
+ The ScriptForge library in %PRODUCTNAME 7.1 introduces the FileSystem service with methods to handle files and folders in user scripts. +
+ + + +ChDir Text As String + + + + Text: Any string expression that specifies the directory path or drive. +If you only want to change the current drive, enter the drive letter followed by a colon. + + + + + + + Sub ExampleChDir + Dim sDir1 As String, sDir2 As String + sDir1 = "C:\Test" + sDir2 = "D:\Private" + ChDir( sDir1 ) + MsgBox CurDir + ChDir( sDir2 ) + MsgBox CurDir + End Sub + + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03020402.xhp b/helpcontent2/source/text/sbasic/shared/03020402.xhp new file mode 100644 index 000000000..780f9e204 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020402.xhp @@ -0,0 +1,66 @@ + + + + + + + ChDrive Statement + /text/sbasic/shared/03020402.xhp + + + + + +
+ + ChDrive statement + + +

ChDrive Statement

+Changes the current drive. +
+ + + + + + ChDrive Text As String + + + + Text: Any string expression that contains the drive letter of the new drive. If you want, you can use URL notation. +The drive must be assigned a capital letter. Under Windows, the letter that you assign the drive is restricted by the settings in LASTDRV. If the drive argument is a multiple-character string, only the first letter is relevant. If you attempt to access a non-existent drive, an error occurs that you can respond to with the OnError statement. + + + + + + + + Sub ExampleChDrive + ChDrive "D" ' Only possible if a drive 'D' exists. + End Sub + + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03020403.xhp b/helpcontent2/source/text/sbasic/shared/03020403.xhp new file mode 100644 index 000000000..0929218d7 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020403.xhp @@ -0,0 +1,78 @@ + + + + + + + CurDir Function + /text/sbasic/shared/03020403.xhp + + + + + +
+ + CurDir function + + +

CurDir Function

+Returns a variant string that represents the current path or that of the specified Windows drive. +
+ + + + + +CurDir [(Text As String)] + + +Return value: +String + + + Text: Any string expression that specifies an existing drive, for example "C" for the first partition of the first hard drive. This parameter is used solely under Windows. +If no drive is specified or if the drive is a zero-length string (""), CurDir returns the path for the current drive. %PRODUCTNAME Basic reports an error if the syntax of the drive description is incorrect or if the drive does not exist. + +This function is not case-sensitive. + + + + + + + + + Sub ExampleCurDir + Dim sDir1 As String, sDir2 As String + sDir1 = "C:\Test" + sDir2 = "D:\Private" + ChDir( sDir1 ) + MsgBox CurDir + ChDir( sDir2 ) + MsgBox CurDir + End Sub + + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03020404.xhp b/helpcontent2/source/text/sbasic/shared/03020404.xhp new file mode 100644 index 000000000..5416578ca --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020404.xhp @@ -0,0 +1,85 @@ + + + + + + + Dir Function + /text/sbasic/shared/03020404.xhp + + + + + +
+ + Dir function + + +

Dir Function

+Returns the name of a file, a directory, or all of the files and the directories on a drive or in a directory that match the specified search path. +
+ + + +Dir [(Text As String [, Attrib As Integer])] + + +

Return value:

+String + + + Text: Any string expression that specifies the search path, directory or file. This argument can only be specified the first time that you call the Dir function. If you want, you can enter the path in URL notation. + Attrib: Any integer expression that specifies bitwise file attributes. The Dir function only returns files or directories that match the specified attributes. You can combine several attributes by adding the attribute values: +0 : Normal files. +16 : Returns the name of the directory only. +Use this attribute to check if a file or directory exists, or to determine all files and folders in a specific directory. +To check if a file exists, enter the complete path and name of the file. If the file or directory name does not exist, the Dir function returns a zero-length string (""). +To generate a list of all existing files in a specific directory, proceed as follows: The first time you call the Dir function, specify the complete search path for the files, for example, "D:\Files\*.ods". If the path is correct and the search finds at least one file, the Dir function returns the name of the first file that matches the search path. To return additional file names that match the path, call Dir again, but with no arguments. +To return directories only, use the attribute parameter. The same applies if you want to determine the name of a volume (for example, a hard drive partition). + + + + + + +Sub ExampleDir +' Displays all files and directories +Dim sPath As String +Dim sDir As String, sValue As String + sDir="Directories:" + sPath = CurDir + sValue = Dir$(sPath + getPathSeparator + "*",16) + Do + If sValue <> "." And sValue <> ".." Then + If (GetAttr( sPath + getPathSeparator + sValue) And 16) >0 Then + ' Get the directories + sDir = sDir & chr(13) & sValue + End If + End If + sValue = Dir$ + Loop Until sValue = "" + MsgBox sDir,0,sPath +End Sub + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03020405.xhp b/helpcontent2/source/text/sbasic/shared/03020405.xhp new file mode 100644 index 000000000..d19d30546 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020405.xhp @@ -0,0 +1,89 @@ + + + + + + + FileAttr Function + /text/sbasic/shared/03020405.xhp + + + + + + +
+ + FileAttr function + + + +FileAttr Function +Returns the access mode or the file access number of a file that was opened with the Open statement. The file access number is dependent on the operating system (OSH = Operating System Handle). +
+If you use a 32-Bit operating system, you cannot use the FileAttr-Function to determine the file access number. +See also: Open + + + +FileAttr (FileNumber As Integer, Attribute As Integer) + + + +Integer + + + FileNumber: The number of the file that was opened with the Open statement. + Attribute: Integer expression that indicates the type of file information that you want to return. The following values are possible: +1: The FileAttr-Function indicates the access mode of the file. +2: The FileAttr-Function returns the file access number of the operating system. +If you specify a parameter attribute with a value of 1, the following return values apply: +1 - INPUT (file open for input) +2 - OUTPUT (file open for output) +4 - RANDOM (file open for random access) +8 - APPEND (file open for appending) +32 - BINARY (file open in binary mode). + + + + + + +Sub ExampleFileAttr + Dim iNumber As Integer + Dim sLine As String + Dim aFile As String + aFile = "C:\Users\ThisUser\data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber + Print #iNumber, "This is a line of text" + MsgBox FileAttr(#iNumber, 1), 0, "Access mode" + MsgBox FileAttr(#iNumber, 2), 0, "File attribute" + Close #iNumber +End Sub + + +
+ + + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020406.xhp b/helpcontent2/source/text/sbasic/shared/03020406.xhp new file mode 100644 index 000000000..3fb2923e8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020406.xhp @@ -0,0 +1,62 @@ + + + + + + + FileCopy Statement + /text/sbasic/shared/03020406.xhp + + + + + + +
+ + FileCopy statement + + + +FileCopy Statement +Copies a file. +
+ +Syntax: + +FileCopy TextFrom As String, TextTo As String + + +Parameters: + TextFrom: Any string expression that specifies the name of the file that you want to copy. The expression can contain optional path and drive information. If you want, you can enter a path in URL notation. + TextTo: Any string expression that specifies where you want to copy the source file to. The expression can contain the destination drive, the path, and file name, or the path in URL notation. +You can only use the FileCopy statement to copy files that are not opened. + + + + +Example: + +Sub ExampleFileCopy + FileCopy "c:\autoexec.bat", "c:\Temp\Autoexec.sav" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020407.xhp b/helpcontent2/source/text/sbasic/shared/03020407.xhp new file mode 100644 index 000000000..d198d3407 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020407.xhp @@ -0,0 +1,61 @@ + + + + + + + FileDateTime Function + /text/sbasic/shared/03020407.xhp + + + + + + +
+ + FileDateTime function + + + +FileDateTime Function +Returns a string that contains the date and the time that a file was created or last modified. +
+ +Syntax: + +FileDateTime (Text As String) + + +Parameters: + Text: Any string expression that contains an unambiguous (no wildcards) file specification. You can also use URL notation. +This function determines the exact time of creation or last modification of a file, returned in the format "MM.DD.YYYY HH.MM.SS". + + + + +Example: + +Sub ExampleFileDateTime + MsgBox FileDateTime("C:\autoexec.bat") +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020408.xhp b/helpcontent2/source/text/sbasic/shared/03020408.xhp new file mode 100644 index 000000000..bb3a030f2 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020408.xhp @@ -0,0 +1,64 @@ + + + + + + + FileLen Function + /text/sbasic/shared/03020408.xhp + + + + + + +
+ + FileLen function + + + +FileLen Function +Returns the length of a file in bytes. +
+ + + +FileLen (Text As String) As Long + + + +Long +Use ScriptForge.FileSystem service GetFileLen() method when size is expected to be over 2 gigabytes. + + + Text: Any string expression that contains an unambiguous file specification. You can also use URL notation. +This function determines the length of a file. If the FileLen function is called for an open file, it returns the file length before it was opened. To determine the current file length of an open file, use the Lof function. + + + + + +Sub ExampleFileLen + MsgBox FileLen("C:\autoexec.bat") +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020409.xhp b/helpcontent2/source/text/sbasic/shared/03020409.xhp new file mode 100644 index 000000000..0eaf7067b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020409.xhp @@ -0,0 +1,171 @@ + + + + + + + GetAttr Function + /text/sbasic/shared/03020409.xhp + + + + + + +
+ + GetAttr function + + + +GetAttr Function +Returns a bit pattern that identifies the file type or the name of a volume or a directory. +
+ +Syntax: + +GetAttr (Text As String) + + +Return value: +Integer + +Parameters: + Text: Any string expression that contains an unambiguous file specification. You can also use URL notation. +This function determines the attributes for a specified file and returns the bit pattern that can help you to identify the following file attributes: + + + + +Value + +
+ + + + Named constant + + + Value + + + Definition + + + + + ATTR_NORMAL + + + 0 + + + Normal files. + + + + + ATTR_READONLY + + + 1 + + + Read-only files. + + + + + ATTR_HIDDEN + + + 2 + + + Hidden file + + + + + ATTR_SYSTEM + + + 4 + + + System file + + + + + ATTR_VOLUME + + + 8 + + + Returns the name of the volume + + + + + ATTR_DIRECTORY + + + 16 + + + Returns the name of the directory only. + + + + + ATTR_ARCHIVE + + + 32 + + + File was changed since last backup (Archive bit). + + +
+
+ +If you want to know if a bit of the attribute byte is set, use the following query method: + +Example: + +Sub ExampleSetGetAttr +On Error GoTo ErrorHandler ' Define target for error handler + If Dir("C:\test",16)="" Then MkDir "C:\test" + If Dir("C:\test\autoexec.sav")="" Then FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav" + SetAttr "c:\test\autoexec.sav" ,0 + FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav" + SetAttr "c:\test\autoexec.sav" ,1 + Print GetAttr( "c:\test\autoexec.sav" ) + End +ErrorHandler: + Print Error + End +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020410.xhp b/helpcontent2/source/text/sbasic/shared/03020410.xhp new file mode 100644 index 000000000..0c2214b17 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020410.xhp @@ -0,0 +1,63 @@ + + + + + + + Kill Statement + /text/sbasic/shared/03020410.xhp + + + + + + +
+ + Kill statement + + + +Kill Statement +Deletes a file from a disk. +
+ + + +Kill File As String + + + + File: Any string expression that contains an unambiguous file specification. You can also use URL notation. + + + + + + +Sub ExampleKill + Kill "C:\Users\ThisUser\datafile.dat" ' File must be created in advance +End Sub + + +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020411.xhp b/helpcontent2/source/text/sbasic/shared/03020411.xhp new file mode 100644 index 000000000..2051628f2 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020411.xhp @@ -0,0 +1,104 @@ + + + + + + + MkDir Statement + /text/sbasic/shared/03020411.xhp + + + + + + +
+ + MkDir statement + + + +

MkDir Statement

+ + MkDir Statement diagram + +Creates a new directory on a data medium. +
+ + + +MkDir path + + + + path: Any string expression that specifies the name and path of the directory to be created. You can also use URL notation. +If the path is not determined, the directory is created in the current directory. + + + + + + +Sub ExampleFileIO +' Example for functions of the file organization +Const sFile1 As String = "file://c|/autoexec.bat" +Const sDir1 As String = "file://c|/Temp" +Const sSubDir1 As String ="Test" +Const sFile2 As String = "Copied.tmp" +Const sFile3 As String = "Renamed.tmp" +Dim sFile As String + sFile = sDir1 + "/" + sSubDir1 + ChDir( sDir1 ) + If Dir(sSubDir1,16)="" Then ' Does the directory exist? + MkDir sSubDir1 + MsgBox sFile,0,"Create directory" + End If + sFile = sFile + "/" + sFile2 + FileCopy sFile1 , sFile + MsgBox fSysURL(CurDir()),0,"Current directory" + MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Creation time" + MsgBox sFile & Chr(13)& FileLen( sFile ),0,"File length" + MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"File attributes" + Name sFile As sDir1 + "/" + sSubDir1 + "/" + sFile3 + ' Rename in the same directory + sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3 + SetAttr( sFile, 0 ) 'Delete all attributes + MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"New file attributes" + Kill sFile + RmDir sDir1 + "/" + sSubDir1 +End Sub + +' Converts a system path in URL +Function fSysURL( fSysFp As String ) As String +Dim iPos As String + iPos = 1 + iPos = Instr(iPos,fSysFp, getPathSeparator()) + Do While iPos > 0 + Mid( fSysFp, iPos , 1,"/") + iPos = Instr(iPos+1,fSysFp, getPathSeparator()) + Loop + ' the colon with DOS + iPos = Instr(1,fSysFp,":") + If iPos > 0 Then Mid( fSysFp, iPos , 1,"|") + fSysURL = "file://" & fSysFp +End Function + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03020412.xhp b/helpcontent2/source/text/sbasic/shared/03020412.xhp new file mode 100644 index 000000000..a754376d6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020412.xhp @@ -0,0 +1,65 @@ + + + + + + + Name Statement + /text/sbasic/shared/03020412.xhp + + + + + + +
+ + Name statement + + + +Name Statement +Renames an existing file or directory. +
+ +Syntax: + +Name OldName As String As NewName As String + + +Parameters: + OldName, NewName: Any string expression that specifies the file name, including the path. You can also use URL notation.see #i61074 + +Example: + +Sub ExampleReName +On Error GoTo Error +FileCopy "c:\autoexec.bat", "c:\temp\autoexec.sav" +Name "c:\temp\autoexec.sav" As "c:\temp\autoexec.bat" +End +Error: +If err = 58 Then + MsgBox "File already exists" +End If +End +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020413.xhp b/helpcontent2/source/text/sbasic/shared/03020413.xhp new file mode 100644 index 000000000..7d38f2cc3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020413.xhp @@ -0,0 +1,71 @@ + + + + + + + RmDir Statement + /text/sbasic/shared/03020413.xhp + + + + + +
+ + RmDir statement + + +

RmDir Statement

+Deletes an existing directory from a data medium. +
+ + + + RmDir Statement diagram + + +RmDir Text As String + + + + Text: Any string expression that specifies the name and path of the directory that you want to delete. You can also use URL notation. +If the path is not determined, the RmDir Statement searches for the directory that you want to delete in the current path. If it is not found there, an error message appears. + + + + + + +Sub ExampleRmDir + MkDir "C:\Test2" + ChDir "C:\test2" + MsgBox Curdir + ChDir "\" + RmDir "C:\test2" +End Sub + + +
+ + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020414.xhp b/helpcontent2/source/text/sbasic/shared/03020414.xhp new file mode 100644 index 000000000..e4cd4814d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020414.xhp @@ -0,0 +1,122 @@ + + + + + + + SetAttr Statement + /text/sbasic/shared/03020414.xhp + + + + + + +
+ + SetAttr statement + + + +SetAttr Statement +Sets the attribute information for a specified file. +
+ +Syntax: + +SetAttr FileName As String, Attribute As Integer + + +Parameters: +FileName: Name of the file, including the path, that you want to test attributes of. If you do not enter a path, SetAttr searches for the file in the current directory. You can also use URL notation. + Attribute: Bit pattern defining the attributes that you want to set or to clear: + Value + + + + + Named constant + + + Value + + + Definition + + + + + ATTR_NORMAL + + + 0 + + + Normal files. + + + + + ATTR_READONLY + + + 1 + + + Read-only files. + + + + + ATTR_HIDDEN + + + 2 + + + Hidden file + + +
+ +You can set multiple attributes by combining the respective values with a logic OR statement. + + + + + +Example: + +Sub ExampleSetGetAttr + On Error GoTo ErrorHandler ' Define target for error handler + If Dir("C:\test",16)="" Then MkDir "C:\test" + If Dir("C:\test\autoexec.sav")="" Then FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav" + SetAttr "c:\test\autoexec.sav" ,0 + FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav" + SetAttr "c:\test\autoexec.sav" , ATTR_READONLY + Print GetAttr( "c:\test\autoexec.sav" ) + End +ErrorHandler: + Print Error + End +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03020415.xhp b/helpcontent2/source/text/sbasic/shared/03020415.xhp new file mode 100644 index 000000000..162e1bf9b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020415.xhp @@ -0,0 +1,64 @@ + + + + + + + FileExists Function + /text/sbasic/shared/03020415.xhp + + + + + + +
+ + FileExists function + + + +FileExists Function +Determines if a file or a directory is available on the data medium. +
+ +Syntax: + +FileExists(FileName As String | DirectoryName As String) + + +Return value: +Bool + +Parameters: +FileName | DirectoryName: Any string expression that contains an unambiguous file specification. You can also use URL notation. + + + +Example: + +Sub ExampleFileExists + MsgBox FileExists("C:\autoexec.bat") + MsgBox FileExists("file:///d|/bookmark.htm") + MsgBox FileExists("file:///d|/Private") +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030000.xhp b/helpcontent2/source/text/sbasic/shared/03030000.xhp new file mode 100644 index 000000000..c9c3d5505 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030000.xhp @@ -0,0 +1,44 @@ + + + + + + + +Date and Time Functions +/text/sbasic/shared/03030000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Date and Time Functions + Use the statements and functions described here to perform date and time calculations. +
+ %PRODUCTNAME Basic lets you calculate time or date differences by converting the time and date values to continuous numeric values. After the difference is calculated, special functions are used to reconvert the values to the standard time or date formats. + You can combine date and time values into a single floating-decimal number. Dates are converted to integers, and times to decimal values. %PRODUCTNAME Basic also supports the variable type Date, which can contain a time specification consisting of both a date and time. + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030100.xhp b/helpcontent2/source/text/sbasic/shared/03030100.xhp new file mode 100644 index 000000000..bbc69eac4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030100.xhp @@ -0,0 +1,53 @@ + + + + + + + + +Converting Date Values +/text/sbasic/shared/03030100.xhp + + +Sun Microsystems, Inc. + + + +
+Converting Date Values +The following functions convert date values to calculable numbers and back. +
+ + + + + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030101.xhp b/helpcontent2/source/text/sbasic/shared/03030101.xhp new file mode 100644 index 000000000..2ee2203c3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030101.xhp @@ -0,0 +1,69 @@ + + + + + + + +DateSerial Function +/text/sbasic/shared/03030101.xhp + + +Sun Microsystems, Inc. + + + +
+DateSerial function + +

DateSerial Function

+Returns a Date value for a specified year, month, or day. +
+ + +DateSerial (year, month, day) + + +Date + + +Year: Integer expression that indicates a year. All values between 0 and 99 are interpreted as the years 1900-1999. For years that fall outside this range, you must enter all four digits. + +Month: Integer expression that indicates the month of the specified year. The accepted range is from 1-12. + +Day: Integer expression that indicates the day of the specified month. The accepted range is from 1-31. No error is returned when you enter a non-existing day for a month shorter than 31 days.see i69463 +The DateSerial function returns the number of days between December 30,1899 and the given date. You can use this function to calculate the difference between two dates. +The DateSerial function returns the data type Variant with VarType 7 (Date). Internally, this value is stored as a Double value, so that when the given date is 1.1.1900, the returned value is 2. Negative values correspond to dates before December 30, 1899 (not inclusive). +If a date is defined that lies outside of the accepted range, $[officename] Basic returns an error message. +Whereas you define the DateValue function as a string that contains the date, the DateSerial function evaluates each of the parameters (year, month, day) as separate numeric expressions. + + + + + Sub ExampleDateSerial + Dim lDate As Long + Dim sDate As String + lDate = DateSerial(1964, 4, 9) + sDate = DateSerial(1964, 4, 9) + MsgBox lDate ' returns 23476 + MsgBox sDate ' returns 04/09/1964 + End Sub + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030102.xhp b/helpcontent2/source/text/sbasic/shared/03030102.xhp new file mode 100644 index 000000000..aea6339a0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030102.xhp @@ -0,0 +1,73 @@ + + + + + + + DateValue Function + /text/sbasic/shared/03030102.xhp + + +Sun Microsystems, Inc. + + + + +
+ DateValue function + +

DateValue Function

+ Returns a Date object from a string representing a date. + The returned object is represented internally as a single numeric value corresponding to the specified date. This value can be used to calculate the number of days between two dates. +
+ + + + DateValue(date As String) + + +
+ date: A string that contains the date that will be converted to a Date object. + The string passed to DateValue must be expressed in one of the date formats defined by your locale setting (see %PRODUCTNAME - PreferencesTools - Options - Language Settings - Languages) or using the ISO date format "yyyy-mm-dd" (year, month and day separated by hyphens). +
+ +Date. + + + + + Sub ExampleDateValue + Dim aDate As Date + aDate = DateValue("2021-12-20") + ' Prints the localized date + MsgBox aDate + ' Extracts the year, month and day from the date object + MsgBox Year(aDate) + MsgBox Month(aDate) + MsgBox Day(aDate) + ' Prints the numeric value corresponding to the date (as Long type) + MsgBox CLng(aDate) + End Sub + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03030103.xhp b/helpcontent2/source/text/sbasic/shared/03030103.xhp new file mode 100644 index 000000000..b39292b03 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030103.xhp @@ -0,0 +1,62 @@ + + + + + + + +Day Function +/text/sbasic/shared/03030103.xhp + + +Sun Microsystems, Inc. + + + +
+Day function + +Day Function +Returns a value that represents the day of the month based on a serial date number generated by DateSerial or DateValue. +
+Syntax: + +Day (Number) + +Return value: +Integer +Parameters: + +Number: A numeric expression that contains a serial date number from which you can determine the day of the month. +This function is basically the opposite of the DateSerial function, returning the day of the month from a serial date number generated by the DateSerial or the DateValue function. For example, the expression + +Print Day (DateSerial(1994, 12, 20)) + +returns the value 20. + + +Example: + +Sub ExampleDay + Print "Day " & Day(DateSerial(1994, 12, 20)) & " of the month" +End Sub + + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03030104.xhp b/helpcontent2/source/text/sbasic/shared/03030104.xhp new file mode 100644 index 000000000..90e7d4754 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030104.xhp @@ -0,0 +1,62 @@ + + + + + + + +Month Function +/text/sbasic/shared/03030104.xhp + + +Sun Microsystems, Inc. + + + +
+Month function + +Month Function +Returns the month of a year from a serial date that is generated by the DateSerial or the DateValue function. +
+Syntax: + +Month (Number) + +Return value: +Integer +Parameters: + +Number: Numeric expression that contains the serial date number that is used to determine the month of the year. +This function is the opposite of the DateSerial function. It returns the month in the year that corresponds to the serial date that is generated by DateSerial or DateValue. For example, the expression + +Print Month(DateSerial(1994, 12, 20)) + +returns the value 12. + + +Example: + +Sub ExampleMonth + MsgBox "" & Month(Now) ,64,"The current month" +End Sub + + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03030105.xhp b/helpcontent2/source/text/sbasic/shared/03030105.xhp new file mode 100644 index 000000000..f2bd1dad4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030105.xhp @@ -0,0 +1,194 @@ + + + + + + WeekDay Function + /text/sbasic/shared/03030105.xhp + + + Sun Microsystems, Inc. + + + +
+ + WeekDay function + + +

WeekDay Function

+This function returns the number corresponding to the weekday represented by a serial date number that is generated by the DateSerial or the DateValue functions. +
+This help page describes the WeekDay function used in Basic scripts. If you are interested in the WeekDay function used in %PRODUCTNAME Calc, refer to this help page. + + + WeekDay (SerialDate, [FirstDayOfWeek]) + + + +SerialDate: Integer expression that contains the serial date number that is used to calculate the day of the week. + +FirstDayOfWeek: Integer value indicating which weekday should be considered as the first day of the week. The default value is 0, meaning that the system locale settings are used to determine the first day of the week. +The parameter FirstDayOfWeek accepts values ranging from 0 to 7. The table below describes the meaning of each possible value: +
+ + + + Value + + + VBA Constant + + + Description + + + + + 0 + + + vbUseSystemDayOfWeek + + + Use system locale settings + + + + + 1 + + + vbSunday + + + Sunday (default) + + + + + 2 + + + vbMonday + + + Monday + + + + + 3 + + + vbTuesday + + + Tuesday + + + + + 4 + + + vbWednesday + + + Wednesday + + + + + 5 + + + vbThursday + + + Thursday + + + + + 6 + + + vbFriday + + + Friday + + + + + 7 + + + vbSaturday + + + Saturday + + +
+
+The VBA constants listed above are only available if VBA support has been enabled. For more information, read the VBASupport Statement help page. + + +Integer + + + +The following example uses the function Now() to determine the current weekday. + +Sub ExampleWeekDay + Dim sDay As String + ' Return And display the day of the week + Select Case WeekDay( Now ) + Case 1: sDay="Sunday" + Case 2: sDay="Monday" + Case 3: sDay="Tuesday" + Case 4: sDay="Wednesday" + Case 5: sDay="Thursday" + Case 6: sDay="Friday" + Case 7: sDay="Saturday" + End Select + MsgBox "" + sDay,64,"Today Is" +End Sub + +The following example illustrates the use FirstDayOfWeek parameter, assuming that Tuesday is the first day of the week. + + Dim someDay As Long + ' The date January 1st 2021 was a Friday + someDay = DateSerial(2021, 01, 01) + ' Prints "6" assuming Sunday is the first day of the week + MsgBox WeekDay(someDay) + ' Prints "4" assuming Tuesday is the first day of the week + MsgBox WeekDay(someDay, 3) + + +
+ + + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03030106.xhp b/helpcontent2/source/text/sbasic/shared/03030106.xhp new file mode 100644 index 000000000..6d99a611a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030106.xhp @@ -0,0 +1,62 @@ + + + + + + + +Year Function +/text/sbasic/shared/03030106.xhp + + +Sun Microsystems, Inc. + + + +
+Year function + +Year Function +Returns the year from a serial date number that is generated by the DateSerial or the DateValue function. +
+Syntax: + +Year (Number) + +Return value: +Integer +Parameters: + +Number: Integer expression that contains the serial date number that is used to calculate the year. +This function is the opposite of the DateSerial function, and returns the year of a serial date. For example, the expression: + +Print Year(DateSerial(1994, 12, 20)) + +returns the value 1994. + + +Example: + +Sub ExampleYear + MsgBox "" & Year(Now) ,64,"Current year" +End Sub + + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03030107.xhp b/helpcontent2/source/text/sbasic/shared/03030107.xhp new file mode 100644 index 000000000..947b738f9 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030107.xhp @@ -0,0 +1,62 @@ + + + + + + + CDateToIso Function + /text/sbasic/shared/03030107.xhp + + + + + +
+ + CdateToIso function + + +CDateToIso Function +Returns the date in ISO format without separators (YYYYMMDD) from a serial date number that is generated by the DateSerial or the DateValue or the CDateFromIso function. +The year part consists of at least four digits, with leading zeros if the absolute value is less than 1000, it can be negative with a leading minus sign if the date passed denotes a year before the common era (BCE) and it can have more than four digits if the absolute value is greater than 9999. The formatted string returned can be in the range "-327680101" to "327671231". +Years less than 100 and greater than 9999 are supported since %PRODUCTNAME 5.4. +
+ +Syntax: + +CDateToIso(Number) + + +Return value: +String + +Parameters: + Number: Integer that contains the serial date number. + + + +Example: + +Sub ExampleCDateToIso + MsgBox "" & CDateToIso(Now) ,64,"ISO Date" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030108.xhp b/helpcontent2/source/text/sbasic/shared/03030108.xhp new file mode 100644 index 000000000..1662472af --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030108.xhp @@ -0,0 +1,60 @@ + + + + + + + +CDateFromIso Function +/text/sbasic/shared/03030108.xhp + + +Sun Microsystems, Inc. + + + +
+CdateFromIso function + +CDateFromIso Function +Returns the internal date number from a string that contains a date in ISO format (YYYYMMDD or YYYY-MM-DD). +The year part must consist of either two (supported only in YYMMDD format without separators for compatibility) or at least four digits. With four digits leading zeros must be given if the absolute value is less than 1000, it can be negative with a leading minus sign if the date passed denotes a year before the common era (BCE) and it can have more than four digits if the absolute value is greater than 9999. The formatted string can be in the range "-327680101" to "327671231", or "-32768-01-01" to "32767-12-31". +An invalid date results in an error. Year 0 is not accepted, the last day BCE is -0001-12-31 and the next day CE is 0001-01-01. Dates before 1582-10-15 are in the proleptic Gregorian calendar. +When converting a date serial number to a printable string, for example for the Print or MsgBox command, the locale's default calendar is used and at that 1582-10-15 cutover date may switch to the Julian calendar, which can result in a different date being displayed than expected. Use the CDateToIso Function to convert such date number to a string representation in the proleptic Gregorian calendar. +The YYYY-MM-DD format with separators is supported since %PRODUCTNAME 5.3.4. Years less than 100 or greater than 9999 are accepted since %PRODUCTNAME 5.4 if not in VBA compatibility mode. +
+Syntax: + +CDateFromIso(String) + +Return value: +Internal date number +Parameters: + +String: A string that contains a date in ISO format. + + +Example: + + dateval = CDateFromIso("20021231") + dateval = CDateFromIso("2002-12-31") + +return both 12/31/2002 in the date format of your system + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030110.xhp b/helpcontent2/source/text/sbasic/shared/03030110.xhp new file mode 100644 index 000000000..f8768bd70 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030110.xhp @@ -0,0 +1,157 @@ + + + + + + + DateAdd Function + /text/sbasic/shared/03030110.xhp + + + + + + +
+ + DateAdd function + + + +

DateAdd Function

+Adds a date or time interval to a given date a number of times and returns the resulting date. +
+ + + +DateAdd (interval As String, number As Long, date As Date) As Date + + +Return value: +A Variant containing a date. + + + interval - A string expression from the following table, specifying the date or time interval. + +
+ + + + + interval (string value) + + + Explanation + + + + + yyyy + + + Year + + + + + q + + + Quarter + + + + + m + + + Month + + + + + y + + + Day of year + + + + + w + + + Weekday + + + + + ww + + + Week of year + + + + + d + + + Day + + + + + h + + + Hour + + + + + n + + + Minute + + + + + s + + + Second + + +
+ +
+number - A numerical expression specifying how many times the interval value will be added when positive or subtracted when negative. +date - A given date or the name of a Variant variable containing a date. The interval value will be added number times to this date. + + + +Sub example_dateadd + MsgBox DateAdd("m", 1, #1/31/2004#) &" - "& DateAdd(date:=#2005-01-31#, interval:="m", number:=1) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030111.xhp b/helpcontent2/source/text/sbasic/shared/03030111.xhp new file mode 100644 index 000000000..748dfe0ed --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030111.xhp @@ -0,0 +1,63 @@ + + + + + + + CDateToUnoDate Function + /text/sbasic/shared/03030111.xhp + + + + + + +
+ + CDateToUnoDate function + + + +CDateToUnoDate Function +Returns the date as a UNO com.sun.star.util.Date struct. +
+ +Syntax: + +CDateToUnoDate(aDate) + + +Return value: +com.sun.star.util.Date + +Parameters: + aDate: Date to convert + + + +Example: + +Sub ExampleCDateToUnoDate + aDatabaseRow.updateDate(3, CDateToUnoDate(Now)) + aDateControl.Date = CDateToUnoDate(Now) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030112.xhp b/helpcontent2/source/text/sbasic/shared/03030112.xhp new file mode 100644 index 000000000..4bc61338a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030112.xhp @@ -0,0 +1,63 @@ + + + + + + + CDateFromUnoDate Function + /text/sbasic/shared/03030112.xhp + + + + + + +
+ + CDateFromUnoDate function + + + +CDateFromUnoDate Function +Converts a UNO com.sun.star.util.Date struct to a Date value. +
+ +Syntax: + +CDateFromUnoDate(aDate) + + +Return value: +Date + +Parameters: + aDate: Date to convert + + + +Example: + +Sub ExampleCDateFromUnoDate + MsgBox(CDateFromUnoDate(aDatabaseRow.getDate(3))) + MsgBox(CDateFromUnoDate(aDateControl.Date)) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030113.xhp b/helpcontent2/source/text/sbasic/shared/03030113.xhp new file mode 100644 index 000000000..1a19ab689 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030113.xhp @@ -0,0 +1,63 @@ + + + + + + + CDateToUnoTime Function + /text/sbasic/shared/03030113.xhp + + + + + + +
+ + CDateToUnoTime function + + + +CDateToUnoTime Function +Returns the time part of the date as a UNO com.sun.star.util.Time struct. +
+ +Syntax: + +CDateToUnoTime(aDate) + + +Return value: +com.sun.star.util.Time + +Parameters: + aDate: Date value to convert + + + +Example: + +Sub ExampleCDateToUnoTime + aDatabaseRow.updateTime(3, CDateToUnoTime(Now)) + aTimeControl.Time = CDateToUnoTime(Now) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030114.xhp b/helpcontent2/source/text/sbasic/shared/03030114.xhp new file mode 100644 index 000000000..2c37d6778 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030114.xhp @@ -0,0 +1,63 @@ + + + + + + + CDateFromUnoTime Function + /text/sbasic/shared/03030114.xhp + + + + + + +
+ + CDateFromUnoTime function + + + +CDateFromUnoTime Function +Converts a UNO com.sun.star.util.Time struct to a Date value. +
+ +Syntax: + +CDateFromUnoTime(aTime) + + +Return value: +Date + +Parameters: + aTime: Time to convert + + + +Example: + +Sub ExampleCDateFromUnoTime + MsgBox(CDateFromUnoTime(aDatabaseRow.getTime(3))) + MsgBox(CDateFromUnoTime(aTimeControl.Time)) +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030115.xhp b/helpcontent2/source/text/sbasic/shared/03030115.xhp new file mode 100644 index 000000000..7523d3264 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030115.xhp @@ -0,0 +1,62 @@ + + + + + + + CDateToUnoDateTime Function + /text/sbasic/shared/03030115.xhp + + + + + + +
+ + CDateToUnoDateTime function + + + +CDateToUnoDateTime Function +Returns the time part of the date as a UNO com.sun.star.util.DateTime struct. +
+ +Syntax: + +CDateToUnoDateTime(aDate) + + +Return value: +com.sun.star.util.DateTime + +Parameters: + aDate: Date value to convert + + + +Example: + +Sub ExampleCDateToUnoDateTime + aDatabaseRow.updateTimestamp(3, CDateToUnoDateTime(Now)) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030116.xhp b/helpcontent2/source/text/sbasic/shared/03030116.xhp new file mode 100644 index 000000000..f46887f53 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030116.xhp @@ -0,0 +1,62 @@ + + + + + + + CDateFromUnoDateTime Function + /text/sbasic/shared/03030116.xhp + + + + + + +
+ + CDateFromUnoDateTime function + + + +CDateFromUnoDateTime Function +Converts a UNO com.sun.star.util.DateTime struct to a Date value. +
+ +Syntax: + +CDateFromUnoDateTime(aDateTime) + + +Return value: +Date + +Parameters: + aDateTime: DateTime to convert + + + +Example: + +Sub ExampleCDateFromUnoDateTime + MsgBox(CDateFromUnoDateTime(aDatabaseRow.getTimestamp(3))) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030120.xhp b/helpcontent2/source/text/sbasic/shared/03030120.xhp new file mode 100644 index 000000000..04f6fd4de --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030120.xhp @@ -0,0 +1,186 @@ + + + + + + + DateDiff Function + /text/sbasic/shared/03030120.xhp + + + + + +
+ + DateDiff function + + +

DateDiff Function

+Returns the number of date or time intervals between two given date values. +
+ + + +DateDiff (interval As String, date1 As Date, date2 As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Double + + +Return value: +A number. + + + interval - A string expression from the following table, specifying the date or time interval. + + date1, date2 - The two date values to be compared. + + +
+ firstdayofweek: An optional parameter that specifies the starting day of a week. + + + + + firstdayofweek value + + + Explanation + + + + + 0 + + + Use system default value + + + + + 1 + + + Sunday (default) + + + + + 2 + + + Monday + + + + + 3 + + + Tuesday + + + + + 4 + + + Wednesday + + + + + 5 + + + Thursday + + + + + 6 + + + Friday + + + + + 7 + + + Saturday + + +
+ + firstweekofyear: An optional parameter that specifies the starting week of a year. + + + + + firstweekofyear value + + + Explanation + + + + + 0 + + + Use system default value + + + + + 1 + + + Week 1 is the week with January, 1st (default) + + + + + 2 + + + Week 1 is the first week containing four or more days of that year + + + + + 3 + + + Week 1 is the first week containing only days of the new year + + +
+ +
+ + + +Sub example_datediff + MsgBox DateDiff("d", #1/1/2005#, #2005-12-31#) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030130.xhp b/helpcontent2/source/text/sbasic/shared/03030130.xhp new file mode 100644 index 000000000..5934bb13b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030130.xhp @@ -0,0 +1,63 @@ + + + + + + + DatePart Function + /text/sbasic/shared/03030130.xhp + + + + + + +
+ + DatePart function + + +

DatePart Function

+The DatePart function returns a specified part of a date. +
+ + + +DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long + + +Return value: +The extracted part for the given date. + + + interval - A string expression from the following table, specifying the date interval. + + date - The date from which the result is calculated. + + + + +Sub example_datepart + MsgBox DatePart("ww", #12/31/2005#) + MsgBox DatePart(date:=#1999-12-30#, interval:="q") +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030200.xhp b/helpcontent2/source/text/sbasic/shared/03030200.xhp new file mode 100644 index 000000000..e12f26802 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030200.xhp @@ -0,0 +1,49 @@ + + + + + + + + +Converting Time Values +/text/sbasic/shared/03030200.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Converting Time Values + The following functions convert time values to calculable numbers. +
+ + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030201.xhp b/helpcontent2/source/text/sbasic/shared/03030201.xhp new file mode 100644 index 000000000..6d246b8e6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030201.xhp @@ -0,0 +1,56 @@ + + + + + + + + Hour Function + /text/sbasic/shared/03030201.xhp + + + +
+Hour function + +Hour Function + Returns the hour from a time value that is generated by the TimeSerial or the TimeValue function. +
+ Syntax: + +Hour (Number) + + Return value: + Integer + Parameters: + + Number: Numeric expression that contains the serial time value that is used to return the hour value. + This function is the opposite of the TimeSerial function. It returns an integer value that represents the hour from a time value that is generated by the TimeSerial or the TimeValue function. For example, the expression + Print Hour(TimeSerial(12,30,41)) + returns the value 12. + + + Example: + + Sub ExampleHour + Print "The current hour is " & Hour( Now ) + End Sub + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030202.xhp b/helpcontent2/source/text/sbasic/shared/03030202.xhp new file mode 100644 index 000000000..979e62808 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030202.xhp @@ -0,0 +1,58 @@ + + + + + + + + Minute Function + /text/sbasic/shared/03030202.xhp + + + +
+ Minute function + +

Minute Function (BASIC)

+ Returns the minute of the hour that corresponds to the serial time value that is generated by the TimeSerial or the TimeValue function. +
+ + + Minute (Number) + + + Integer + + + Number: Numeric expression that contains the serial time value that is used to return the minute value. + This function is the opposite of the TimeSerial function. It returns the minute of the serial time value that is generated by the TimeSerial or the TimeValue function. For example, the expression: + + Print Minute(TimeSerial(12,30,41)) + + returns the value 30. + + + + + Sub ExampleMinute + MsgBox "The current minute is "& Minute(Now)& "." + End Sub + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030203.xhp b/helpcontent2/source/text/sbasic/shared/03030203.xhp new file mode 100644 index 000000000..4a9d7c632 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030203.xhp @@ -0,0 +1,62 @@ + + + + + + + Now Function + /text/sbasic/shared/03030203.xhp + + + + + +
+ + Now function + + +

Now Function

+Returns the current system date and time as a Date value. +
+ + + +Now + + + +Date + + + + Sub ExampleNow + MsgBox "It is now " & Now + End Sub + + +The Now function measures time in seconds. To measure time in milliseconds use the Timer service. + +
+ +
+ + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03030204.xhp b/helpcontent2/source/text/sbasic/shared/03030204.xhp new file mode 100644 index 000000000..cf11c82da --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030204.xhp @@ -0,0 +1,65 @@ + + + + + + + Second Function + /text/sbasic/shared/03030204.xhp + + + + + + +
+ + Second function + + + +Second Function +Returns an integer that represents the seconds of the serial time number that is generated by the TimeSerial or the TimeValue function. +
+ +Syntax: + +Second (Number) + + +Return value: +Integer + +Parameters: + Number: Numeric expression that contains the serial time number that is used to calculate the number of seconds. +This function is the opposite of the TimeSerial function. It returns the seconds of a serial time value that is generated by the TimeSerial or TimeValue functions. For example, the expression: +Print Second(TimeSerial(12,30,41)) +returns the value 41. + + + +Example: + +Sub ExampleSecond + MsgBox "The exact second of the current time is "& Second( Now ) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030205.xhp b/helpcontent2/source/text/sbasic/shared/03030205.xhp new file mode 100644 index 000000000..c351bf9fd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030205.xhp @@ -0,0 +1,76 @@ + + + + + + + TimeSerial Function + /text/sbasic/shared/03030205.xhp + + + + + + +
+ + TimeSerial function + + + +TimeSerial Function +Calculates a serial time value for the specified hour, minute, and second parameters that are passed as numeric value. You can then use this value to calculate the difference between times. +
+ +Syntax: + +TimeSerial (hour, minute, second) + + +Return value: +Date + +Parameters: + hour: Any integer expression that indicates the hour of the time that is used to determine the serial time value. Valid values: 0-23. + minute: Any integer expression that indicates the minute of the time that is used to determine the serial time value. In general, use values between 0 and 59. However, you can also use values that lie outside of this range, where the number of minutes influence the hour value. + second: Any integer expression that indicates the second of the time that is used to determine the serial time value. In general, you can use values between 0 and 59. However, you can also use values that lie outside of this range, where the number seconds influences the minute value. + Examples: +12, -5, 45 corresponds to 11, 55, 45 +12, 61, 45 corresponds to 13, 2, 45 +12, 20, -2 corresponds to 12, 19, 58 +12, 20, 63 corresponds to 12, 21, 4 +You can use the TimeSerial function to convert any time into a single value that you can use to calculate time differences. +The TimeSerial function returns the type Variant with VarType 7 (Date). This value is stored internally as a double-precision number between 0 and 0.9999999999. As opposed to the DateSerial or DateValue function, where the serial date values are calculated as days relative to a fixed date, you can calculate with values returned by the TimeSerial function, but you cannot evaluate them. +In the TimeValue function, you can pass a string as a parameter containing the time. For the TimeSerial function, however, you can pass the individual parameters (hour, minute, second) as separate numeric expressions. + + + +Example: + +Sub ExampleTimeSerial +Dim dDate As Double, sDate As String + dDate = TimeSerial(8,30,15) + sDate = TimeSerial(8,30,15) + MsgBox dDate,64,"Time as a number" + MsgBox sDate,64,"Formatted time" +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030206.xhp b/helpcontent2/source/text/sbasic/shared/03030206.xhp new file mode 100644 index 000000000..baf4ee9ea --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030206.xhp @@ -0,0 +1,78 @@ + + + + + + + TimeValue Function + /text/sbasic/shared/03030206.xhp + + + + + + +
+ + TimeValue function + + + +TimeValue Function +Calculates a serial time value from the specified hour, minute, and second - parameters passed as strings - that represents the time in a single numeric value. This value can be used to calculate the difference between times. +
+ +Syntax: + +TimeValue (Text As String) + + +Return value: +Date + +Parameters: + Text: Any string expression that contains the time that you want to calculate in the format "HH:MM:SS". +Use the TimeValue function to convert any time into a single value, so that you can calculate time differences. +This TimeValue function returns the type Variant with VarType 7 (Date), and stores this value internally as a double-precision number between 0 and 0.9999999999. +As opposed to the DateSerial or the DateValue function, where serial date values result in days relative to a fixed date, you can calculate with the values that are returned by the TimeValue function, but you cannot evaluate them. +In the TimeSerial function, you can pass individual parameters (hour, minute, second) as separate numeric expressions. For the TimeValue function, however, you can pass a string as a parameter containing the time. + + + + +Example: + +Sub ExampleTimerValue +Dim daDT As Date +Dim a1, b1, c1, a2, b2, c2 As String + a1 = "start time" + b1 = "end time" + c1 = "total time" + a2 = "8:34" + b2 = "18:12" + daDT = TimeValue(b2) - TimeValue(a2) + c2 = a1 & ": " & a2 & chr(13) + c2 = c2 & b1 & ": " & b2 & chr(13) + c2 = c2 & c1 & ": " & trim(Str(Hour(daDT))) & ":" & trim(Str(Minute(daDT))) & ":" & trim(Str(Second(daDT))) + MsgBox c2 +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030300.xhp b/helpcontent2/source/text/sbasic/shared/03030300.xhp new file mode 100644 index 000000000..4f64396e1 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030300.xhp @@ -0,0 +1,44 @@ + + + + + + + + +System Date and Time +/text/sbasic/shared/03030300.xhp + + +Sun Microsystems, Inc. + + + + + +
+ System Date and Time + The following functions and statements set or return the system date and time. +
+ + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03030301.xhp b/helpcontent2/source/text/sbasic/shared/03030301.xhp new file mode 100644 index 000000000..e561ac7d0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030301.xhp @@ -0,0 +1,54 @@ + + + + + + + Date Function + /text/sbasic/shared/03030301.xhp + + + + + + +
+ + Date function + + + +

Date Function

+Returns the current system date as a string, or date variant. +
+ + + +Date[$][()] + + + + +Sub ExampleDate + MsgBox "The date is " & Date +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03030302.xhp b/helpcontent2/source/text/sbasic/shared/03030302.xhp new file mode 100644 index 000000000..3d93aa166 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030302.xhp @@ -0,0 +1,53 @@ + + + + + + + Time Function + /text/sbasic/shared/03030302.xhp + + + + + +
+ + Time function + + +

Time Function

+This function returns the current system time as a string in the format "HH:MM:SS". +
+ + + +Time[$][()] + + + + +Sub ExampleTime + MsgBox Time,0,"The time is" +End Sub + + + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03030303.xhp b/helpcontent2/source/text/sbasic/shared/03030303.xhp new file mode 100644 index 000000000..d82375bc0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03030303.xhp @@ -0,0 +1,69 @@ + + + + + + + Timer Function + /text/sbasic/shared/03030303.xhp + + + + + +
+ + Timer function + + +

Timer Function

+Returns a value that specifies the number of seconds that have elapsed since midnight. +
+You must first declare a variable to call the Timer function and assign it the "Long " data type, otherwise a Date value is returned. + + + + Timer + + + +Date + + + + Sub ExampleTimer + Dim lSec As Long,lMin As Long,lHour As Long + lSec = Timer + MsgBox lSec, 0, "Seconds since midnight" + lMin = lSec / 60 + lSec = lSec Mod 60 + lHour = lMin / 60 + lMin = lMin Mod 60 + MsgBox Right("00" & lHour , 2) & ":"& Right("00" & lMin , 2) & ":" & Right("00" & lSec , 2), 0, "The time is" +End Sub + + +The Timer function measures time in seconds. To measure time in milliseconds use the Timer service available in the ScriptForge library. + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03040000.xhp b/helpcontent2/source/text/sbasic/shared/03040000.xhp new file mode 100644 index 000000000..33dbd5af5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03040000.xhp @@ -0,0 +1,618 @@ + + + + + + + Basic Constants + /text/sbasic/shared/03040000.xhp + + + + +
+ +Basic constants + +

Basic Constants

+ Constants used in Basic programs +
+ +
+ +Boolean Basic constants +Basic constant;False +Basic constant;True + +

Boolean constants

+ + + + + Name + + + Type + + + Value + + + + + True + + + Boolean + + + 1 + + + + + False + + + Boolean + + + 0 + + +
+ + + + Dim bPositive as Boolean + bPositive = True + +
+ +
+ +Basic Mathematical constants +Pi;Basic constant +Basic constant;Pi + + +

Mathematical constant

+ + + + + Name + + + Type + + + Value + + + + + Pi + + + Double + + + 3.14159265358979 + + +
+ + + + Function Rad2Deg( aRad as Double) As Double + Rad2Deg = aRad * 180.00 / Pi + End Function + +
+ +
+ +Basic Object constants +Empty;Basic constant +Null;Basic constant +Nothing;Basic constant +Basic constant;Nothing +Basic constant;Null +Basic constant;Empty + + +

Object Constants

+ + + + + Name + + + Type + + + Usage + + + + + Empty + + + Variant + + + The Empty value indicates that the variable is not initialized. + + + + + Null + + + null + + + Indicates that the variable does not contain data. + + + + + Nothing + + + Object + + + Assign the Nothing object to a variable to remove a previous assignment. + + +
+ + + + SubExampleEmpty + Dim sVar As Variant + sVar = Empty + Print IsEmpty(sVar) ' Returns True + End Sub + Sub ExampleNull + Dim vVar As Variant + MsgBox IsNull(vVar) + End Sub + Sub ExampleNothing + Dim oDoc As Object + Set oDoc = ThisComponent + Print oDoc.Title + oDoc = Nothing + Print oDoc ' Error + End Sub + +
+ +

MsgBox Named Constants

+ + +

GetAttr Named Constants

+ + +

VarType Named Constants

+ + +
+ +Visual Basic constants +VBA Exclusive constants + +

Additional VBA constants

+ The following constants are available when VBA compatibility mode is enabled + + +
+ +VBA Variable Type Named Constants + + + +
+ +

VBA Color Named Constants

+ + + + + Named constant + + + Red, Green, Blue
composition
+
+
+ + + vbBlack + + + RGB(0, 0, 0) + + + + + vbBlue + + + RGB(0, 0, 255) + + + + + vbCyan + + + RGB(0, 255, 255) + + + + + vbGreen + + + RGB(0, 255, 0) + + + + + vbMagenta + + + RGB(255, 0, 255) + + + + + vbRed + + + RGB(255, 0, 0) + + + + + vbYellow + + + RGB(255, 255, 0) + + + + + vbWhite + + + RGB(255, 255, 255) + + +
+ +

Variable Type Named Constants

+ + + + Named constant + + + Decimal value + + + + + vbArray + + + 8192 + + + + + vbBoolean + + + 11 + + + + + vbByte + + + 17 + + + + + vbCurrency + + + 6 + + + + + vbDataObject + + + 13 + + + + + vbDate + + + 7 + + + + + vbDecimal + + + 14 + + + + + vbDouble + + + 5 + + + + + vbEmpty + + + 0 + + + + + vbError + + + 10 + + + + + vbInteger + + + 2 + + + + + vbLong + + + 3 + + + + + vbNull + + + 1 + + + + + vbObject + + + 9 + + + + + vbSingle + + + 4 + + + + + vbString + + + 8 + + + + + vbUserDefinedType + + + 36 + + + + + vbVariant + + + 12 + + +
+ +

FormatDateTime VBA Named Constants

+ + +

StrConv VBA Named Constants

+ + +

WeekDayName VBA Named Constants

+ + +

Miscellaneous VBA Named Constants

+ + + + Named constant + + + Hexadecimal (decimal) value + + + Description + + + + + vbTrue + + + -1 + + + Part of vbTriState enumeration. + + + + + vbFalse + + + 0 + + + Part of vbTriState enumeration. + + + + + vbUseDefault + + + -2 + + + Part of vbTriState enumeration. + + + + + vbCr + + + \x0D (13) + + + CR - Carriage return + + + + + vbCrLf + + + \x0D\x0A (13 10) + + + CRLF - Carriage return and line feed + + + + + vbFormFeed + + + \x0c (12) + + + FF - Form feed + + + + + vbLf + + + \x0A (10) + + + LF - Line feed + + + + + vbNewLine + + + \x0D\x0A (13 10) for Windows + \x0A (10) for other systems + + + LF or CRLF + + + + + vbNullString + + + "" + + + Null string + + + + + vbTab + + + \x09 (9) + + + HT - Horizontal tab + + + + + vbVerticalTab + + + \x0B (11) + + + VT - Vertical tab + + +
+
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03050000.xhp b/helpcontent2/source/text/sbasic/shared/03050000.xhp new file mode 100644 index 000000000..28820eec3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03050000.xhp @@ -0,0 +1,45 @@ + + + + + + Error-Handling Functions + /text/sbasic/shared/03050000.xhp + + + Sun Microsystems, Inc. + + + +
+

Error-Handling Functions

+ Use the following statements and functions to define the way %PRODUCTNAME Basic reacts to run-time errors. +
+ %PRODUCTNAME Basic offers several methods to prevent the termination of a program when a run-time error occurs. + + + + + + + + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03050100.xhp b/helpcontent2/source/text/sbasic/shared/03050100.xhp new file mode 100644 index 000000000..e10ff2d81 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03050100.xhp @@ -0,0 +1,70 @@ + + + + + + + Erl Function + /text/sbasic/shared/03050100.xhp + + + + + +
+ + Erl function + + +Erl Function +Returns the line number where an error occurred during program execution. +
+ +Syntax: + +Erl + + +Return value: +Integer + +Parameters: +The Erl function only returns a line number, and not a line label. + +Example: + +Sub ExampleError +On Error GoTo ErrorHandler ' Set up error handler +Dim iVar As Integer +Dim sVar As String +' Error caused by non-existent file + iVar = Freefile + Open "\file9879.txt" For Input As #iVar + Line Input #iVar, sVar + Close #iVar + Exit Sub +ErrorHandler: + MsgBox "Error " & err & ": " & Error$ + chr(13) + "In Line : " + Erl + chr(13) + Now , 16 ,"An error occurred" +End Sub + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03050200.xhp b/helpcontent2/source/text/sbasic/shared/03050200.xhp new file mode 100644 index 000000000..a6ee49f82 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03050200.xhp @@ -0,0 +1,66 @@ + + + + + + + +Err Function +/text/sbasic/shared/03050200.xhp + + +Sun Microsystems, Inc. + + + +
+Err function + +Err Function +Returns an error code that identifies the error that occurred during program execution. +
+Syntax: + +Err + +Return value: +Integer +Parameters: +The Err function is used in error-handling routines to determine the error and the corrective action. +Example: + +Sub ExampleError +On Error Goto ErrorHandler REM Set up error handler +Dim iVar as Integer +Dim sVar As String +REM Error occurs due to non-existent file + iVar = Freefile + Open "\file9879.txt" for Input as #iVar + Line Input #iVar, sVar + Close #iVar +Exit Sub +ErrorHandler: + MsgBox "Error " & Err & ": " & Error$ + chr(13) + "At line : " + Erl + chr(13) + Now , 16 ,"an error occurred" +End Sub + +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03050300.xhp b/helpcontent2/source/text/sbasic/shared/03050300.xhp new file mode 100644 index 000000000..f3964172a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03050300.xhp @@ -0,0 +1,55 @@ + + + + + +Error Function +/text/sbasic/shared/03050300.xhp + + +Sun Microsystems, Inc. + + + +
+Error function + +Error Function +Returns the error message that corresponds to a value or raises a given error context. +
+Syntax: + +Error +Error(expression) +Error err_code + +Return value: +String or raised error context +Parameters: +If no argument is provided, the Error function returns the error message of the most recent error that occurred during program execution. + +expression: Any numeric expression whose error code can be mapped to an existing error message. An empty string is returned if the error code does not exist. +err_code: Any value that corresponds to an existing error code. + +fixed i60953 +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03050500.xhp b/helpcontent2/source/text/sbasic/shared/03050500.xhp new file mode 100644 index 000000000..3d1e71c39 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03050500.xhp @@ -0,0 +1,86 @@ + + + + + + + On Error GoTo ... Resume Statement + /text/sbasic/shared/03050500.xhp + + + + +
+ + Resume Next parameter + On Error GoTo ... Resume statement + +On Error GoTo ... Resume Statement +Enables an error-handling routine after an error occurs, or resumes program execution. +
+ + + + On Error Statement diagram + + +On [Local] Error {GoTo Labelname | GoTo 0 | Resume Next} + + + +GoTo Labelname: If an error occurs, enables the error-handling routine that starts at the line "Labelname". +Resume Next: If an error occurs, program execution continues with the statement that follows the statement in which the error occurred. +GoTo 0: Disables the error handler in the current procedure. +Local: "On error" is global in scope, and remains active until canceled by another "On error" statement. "On Local error" is local to the routine which invokes it. Local error handling overrides any previous global setting. When the invoking routine exits, the local error handling is canceled automatically, and any previous global setting is restored. +The On Error GoTo statement is used to react to errors that occur in a macro.see i112231: The statement must be inserted at the start of a procedure (in a local error-handling routine) or at the start of a module. + + + +Sub ExampleReset +On Error GoTo ErrorHandler + Dim iNumber As Integer + Dim iCount As Integer + Dim sLine As String + Dim aFile As String + aFile = "C:\Users\ThisUser\data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber + Print #iNumber, "This is a line of text" + Close #iNumber + iNumber = Freefile + Open aFile For Input As iNumber + For iCount = 1 To 5 + Line Input #iNumber, sLine + If sLine <>"" Then + Rem + End If + Next iCount + Close #iNumber + Exit Sub +ErrorHandler: + Reset + MsgBox "All files will be closed", 0, "Error" +End Sub + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03060000.xhp b/helpcontent2/source/text/sbasic/shared/03060000.xhp new file mode 100644 index 000000000..2f67ded5d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03060000.xhp @@ -0,0 +1,53 @@ + + + + + + + + +Logical Operators +/text/sbasic/shared/03060000.xhp + + +Sun Microsystems, Inc. + + + + +
+

Logical Operators

+ The following logical operators are supported by $[officename] Basic. +
+ + Logical operators combine (bitwise) the contents of two expressions or variables, for example, to test if specific bits are set or not. + + + + + + + +
+ + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03060100.xhp b/helpcontent2/source/text/sbasic/shared/03060100.xhp new file mode 100644 index 000000000..1c4bf0bc3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03060100.xhp @@ -0,0 +1,68 @@ + + + + + + + AND Operator + /text/sbasic/shared/03060100.xhp + + + + + + +
+ + AND operator (logical) + + + +AND Operator +Logically combines two expressions. +
+ +Syntax: + +Result = Expression1 And Expression2 + + +Parameters: + Result: Any numeric variable that records the result of the combination. + Expression1, Expression2: Any expressions that you want to combine. +Boolean expressions combined with AND only return the value True if both expressions evaluate to True: + True AND True returns True; for all other combinations the result is False. +The AND operator also performs a bitwise comparison of identically positioned bits in two numeric expressions. + +Example: + +Sub ExampleAnd +Dim A As Variant, B As Variant, C As Variant, D As Variant +Dim vVarOut As Variant + A = 10: B = 8: C = 6: D = Null + vVarOut = A > B And B > C ' returns -1 + vVarOut = B > A And B > C ' returns 0 + vVarOut = A > B And B > D ' returns 0 + vVarOut = (B > D And B > A) ' returns 0 + vVarOut = B And A ' returns 8 due to the bitwise And combination of both arguments +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03060200.xhp b/helpcontent2/source/text/sbasic/shared/03060200.xhp new file mode 100644 index 000000000..4ba146ac9 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03060200.xhp @@ -0,0 +1,67 @@ + + + + + + + Eqv Operator + /text/sbasic/shared/03060200.xhp + + + + + + +
+ + Eqv operator (logical) + + + +Eqv Operator +Calculates the logical equivalence of two expressions. +
+ +Syntax: + +Result = Expression1 Eqv Expression2 + + +Parameters: + Result: Any numeric variable that contains the result of the comparison. + Expression1, Expression2: Any expressions that you want to compare. +When testing for equivalence between Boolean expressions, the result is True if both expressions are either True or False. +In a bit-wise comparison, the Eqv operator only sets the corresponding bit in the result if a bit is set in both expressions, or in neither expression. + +Example: + +Sub ExampleEqv +Dim A As Variant, B As Variant, C As Variant, D As Variantsee #i38265 +Dim vOut As Variant + A = 10: B = 8: C = 6: D = Null + vOut = A > B Eqv B > C ' returns -1 + vOut = B > A Eqv B > C ' returns 0 + vOut = A > B Eqv B > D ' returns 0 + vOut = (B > D Eqv B > A) ' returns -1 + vOut = B Eqv A ' returns -3 +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03060300.xhp b/helpcontent2/source/text/sbasic/shared/03060300.xhp new file mode 100644 index 000000000..041eb2736 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03060300.xhp @@ -0,0 +1,67 @@ + + + + + + + Imp Operator + /text/sbasic/shared/03060300.xhp + + + + + + +
+ + Imp operator (logical) + + + +Imp Operator +Performs a logical implication on two expressions. +
+ +Syntax: + +Result = Expression1 Imp Expression2 + + +Parameters: + Result: Any numeric variable that contains the result of the implication. + Expression1, Expression2: Any expressions that you want to evaluate with the Imp operator. +If you use the Imp operator in Boolean expressions, False is only returned if the first expression evaluates to True and the second expression to False. +If you use the Imp operator in bit expressions, a bit is deleted from the result if the corresponding bit is set in the first expression and the corresponding bit is deleted in the second expression. + +Example: + +Sub ExampleImp +Dim A As Variant, B As Variant, C As Variant, D As Variant +Dim vOut As Variant + A = 10: B = 8: C = 6: D = Null + vOut = A > B Imp B > C ' returns -1 + vOut = B > A Imp B > C ' returns -1 + vOut = A > B Imp B > D ' returns 0 + vOut = (B > D Imp B > A) ' returns -1 + vOut = B Imp A ' returns -1 +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03060400.xhp b/helpcontent2/source/text/sbasic/shared/03060400.xhp new file mode 100644 index 000000000..38bcd0123 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03060400.xhp @@ -0,0 +1,66 @@ + + + + + + + Not Operator + /text/sbasic/shared/03060400.xhp + + + + + + +
+ + Not operator (logical) + + + +Not Operator +Negates an expression by inverting the bit values. +
+ +Syntax: + +Result = Not Expression + + +Parameters: + Result: Any numeric variable that contains the result of the negation. + Expression: Any expression that you want to negate. +When a Boolean expression is negated, the value True changes to False, and the value False changes to True. +In a bitwise negation each individual bit is inverted. + +Example: + +Sub ExampleNot +Dim vA As Variant, vB As Variant, vC As Variant, vD As Variant +Dim vOut As Variant + vA = 10: vB = 8: vC = 6: vD = Null + vOut = Not vA ' Returns -11 + vOut = Not(vC > vD) ' Returns -1 + vOut = Not(vB > vA) ' Returns -1 + vOut = Not(vA > vB) ' Returns 0 +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03060500.xhp b/helpcontent2/source/text/sbasic/shared/03060500.xhp new file mode 100644 index 000000000..d4652e7a5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03060500.xhp @@ -0,0 +1,67 @@ + + + + + + + Or Operator + /text/sbasic/shared/03060500.xhp + + + + + + +
+ + Or operator (logical) + + + +Or Operator +Performs a logical OR disjunction on two expressions. +
+ +Syntax: + +Result = Expression1 Or Expression2 + + +Parameters: + Result: Any numeric variable that contains the result of the disjunction. + Expression1, Expression2: Any numeric expressions that you want to compare. +A logical OR disjunction of two Boolean expressions returns the value True if at least one comparison expression is True. +A bit-wise comparison sets a bit in the result if the corresponding bit is set in at least one of the two expressions. + +Example: + +Sub ExampleOr +Dim vA As Variant, vB As Variant, vC As Variant, vD As Variant +Dim vOut As Variant + vA = 10: vB = 8: vC = 6: vD = Null + vOut = vA > vB Or vB > vC ' -1 + vOut = vB > vA Or vB > vC ' -1 + vOut = vA > vB Or vB > vD ' -1 + vOut = (vB > vD Or vB > vA) ' 0 + vOut = vB Or vA ' 10 +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03060600.xhp b/helpcontent2/source/text/sbasic/shared/03060600.xhp new file mode 100644 index 000000000..e2fa594dd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03060600.xhp @@ -0,0 +1,67 @@ + + + + + + + XOR Operator + /text/sbasic/shared/03060600.xhp + + + + + + +
+ + XOR operator (logical) + + + +XOR Operator +Performs a logical Exclusive-Or combination of two expressions. +
+ +Syntax: + +Result = Expression1 XOR Expression2 + + +Parameters: + Result: Any numeric variable that contains the result of the combination. + Expression1, Expression2: Any numeric expressions that you want to combine. +A logical Exclusive-Or conjunction of two Boolean expressions returns the value True only if both expressions are different from each other. +A bitwise Exclusive-Or conjunction returns a bit if the corresponding bit is set in only one of the two expressions. + +Example: + +Sub ExampleXOR +Dim vA As Variant, vB As Variant, vC As Variant, vD As Variant +Dim vOut As Variant + vA = 10: vB = 8: vC = 6: vD = Null + vOut = vA > vB XOR vB > vC ' returns 0 + vOut = vB > vA XOR vB > vC ' returns -1 + vOut = vA > vB XOR vB > vD ' returns -1 + vOut = (vB > vD XOR vB > vA) ' returns 0 + vOut = vB XOR vA ' returns 2 +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03070000.xhp b/helpcontent2/source/text/sbasic/shared/03070000.xhp new file mode 100644 index 000000000..5b9919cb4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03070000.xhp @@ -0,0 +1,53 @@ + + + + + + + + +Mathematical Operators +/text/sbasic/shared/03070000.xhp + + +Sun Microsystems, Inc. + + + + +
+

Mathematical Operators

+ The following mathematical operators are supported in $[officename] Basic. +
+ This chapter provides a short overview of all of the arithmetical operators that you may need for calculations within a program. + + + + + + + + +
+ + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03070100.xhp b/helpcontent2/source/text/sbasic/shared/03070100.xhp new file mode 100644 index 000000000..f54561edb --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03070100.xhp @@ -0,0 +1,66 @@ + + + + + + + "-" Operator + /text/sbasic/shared/03070100.xhp + + + + + + +
+ + "-" operator (mathematical) + + + +"-" Operator +Subtracts two values. +
+ +Syntax: + +Result = Expression1 - Expression2 + + +Parameters: + Result: Any numerical expression that contains the result of the subtraction. + Expression1, Expression2: Any numerical expressions that you want to subtract. + +Example: + +Sub ExampleSubtraction1 + Print 5 - 5 +End Sub + +Sub ExampleSubtraction2 +Dim iValue1 As Integer +Dim iValue2 As Integer + iValue1 = 5 + iValue2 = 10 + Print iValue1 - iValue2 +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03070200.xhp b/helpcontent2/source/text/sbasic/shared/03070200.xhp new file mode 100644 index 000000000..2f45997b5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03070200.xhp @@ -0,0 +1,66 @@ + + + + + + + "*" Operator + /text/sbasic/shared/03070200.xhp + + + + + + +
+ + "*" operator (mathematical) + + + +"*" Operator +Multiplies two values. +
+ +Syntax: + +Result = Expression1 * Expression2 + + +Parameters: + Result: Any numeric expression that records the result of a multiplication. + Expression1, Expression2: Any numeric expressions that you want to multiply. + +Example: + +Sub ExampleMultiplication1 + Print 5 * 5 +End Sub + +Sub ExampleMultiplication2 +Dim iValue1 As Integer +Dim iValue2 As Integer + iValue1 = 5 + iValue2 = 10 + Print iValue1 * iValue2 +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03070300.xhp b/helpcontent2/source/text/sbasic/shared/03070300.xhp new file mode 100644 index 000000000..ecfaa55d5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03070300.xhp @@ -0,0 +1,66 @@ + + + + + + + "+" Operator + /text/sbasic/shared/03070300.xhp + + + + + + +
+ + "+" operator (mathematical) + + + +"+" Operator +Adds or combines two expressions. +
+ +Syntax: + +Result = Expression1 + Expression2 + + +Parameters: + Result: Any numerical expression that contains the result of the addition. + Expression1, Expression2: Any numerical expressions that you want to combine or to add. + +Example: + +Sub ExampleAddition1 + Print 5 + 5 +End Sub + +Sub ExampleAddition2 +Dim iValue1 As Integer +Dim iValue2 As Integer + iValue1 = 5 + iValue2 = 10 + Print iValue1 + iValue2 +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03070400.xhp b/helpcontent2/source/text/sbasic/shared/03070400.xhp new file mode 100644 index 000000000..3e93644e4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03070400.xhp @@ -0,0 +1,66 @@ + + + + + + + "/" Operator + /text/sbasic/shared/03070400.xhp + + + + + + +
+ + "/" operator (mathematical) + + + +"/" Operator +Divides two values. +
+ +Syntax: + +Result = Expression1 / Expression2 + + +Parameters: + Result: Any numerical value that contains the result of the division. + Expression1, Expression2: Any numerical expressions that you want to divide. + +Example: + +Sub ExampleDivision1 + Print 5 / 5 +End Sub + +Sub ExampleDivision2 +Dim iValue1 As Integer +Dim iValue2 As Integer + iValue1 = 5 + iValue2 = 10 + Print iValue1 / iValue2 +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03070500.xhp b/helpcontent2/source/text/sbasic/shared/03070500.xhp new file mode 100644 index 000000000..e69cee190 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03070500.xhp @@ -0,0 +1,60 @@ + + + + + + + "^" Operator + /text/sbasic/shared/03070500.xhp + + + + + + +
+ + "^" operator (mathematical) + + + +"^" Operator +Raises a number to a power. +
+ +Syntax: + +Result = Expression ^ Exponent + + +Parameters: + Result: Any numerical expression that contains the result of the number raised to a power. + Expression: Numerical value that you want to raise to a power. + Exponent: The value of the power that you want to raise the expression to. + +Example: + +Sub Example + Print ( 12.345 ^ 23 ) + Print Exp ( 23 * Log( 12.345 ) ) ' Raises by forming a logarithm +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03070600.xhp b/helpcontent2/source/text/sbasic/shared/03070600.xhp new file mode 100644 index 000000000..ed510a94c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03070600.xhp @@ -0,0 +1,83 @@ + + + + + + + Mod Operator + /text/sbasic/shared/03070600.xhp + + + + + +
+ + MOD operator (mathematical) + + +

Mod Operator

+The MOD operator takes in two numeric expressions and returns the remainder of the division. +
+For example, the result of 21 MOD 6 is 3 because after dividing 21 by 6, the remainder of the division is 3. +If the MOD operation involves non-integer values, both operands are rounded to the nearest integer values. Hence, the value returned by a MOD operation will always be an integer number. +For example, the expression 16.4 MOD 5.9 is evaluated as follows: + + + The value 16.4 is rounded to 16. + + + The value 5.9 is rounded to 6. + + + The operation 16 MOD 6 returns 4, which is the remainder after dividing 16 by 6. + + +Beware that Basic's MOD operator and Calc's MOD Function behave differently. In Calc, both operands can be decimal values and they're not rounded before division, thus the resulting remainder may be a decimal value. + + + +Result = Expression1 MOD Expression2 + + + +Integer + + + Result: Any numeric variable that contains the result of the MOD operation. + Expression1, Expression2: Any numeric expressions for which you want to calculate the remainder after the division of Expression1 by Expression2. + + + +Sub ExampleMod + Dim a As Double, b as Double + a = 10 : b = 4 + Print a Mod b 'Returns 2 + a = 18 : b = 3.2 + Print a Mod b 'Returns 0 + a = 16.4 : b = 5.9 + Print a Mod b 'Returns 4 +End Sub + + +
+ MOD Function +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03070700.xhp b/helpcontent2/source/text/sbasic/shared/03070700.xhp new file mode 100644 index 000000000..69a83b03c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03070700.xhp @@ -0,0 +1,53 @@ + + + + + + + "\" Operator + /text/sbasic/shared/03070700.xhp + + + + + +
+

"\" Operator

+Performs the integer division on two numbers and returns the result. +
+ + Operators;Integer division (\\) + "\\" operator (mathematical) + + + + result = expression1 \ expression2 + + + + result: A numerical value that contains the result of the integer division. + expression1, expression2: Dividend and diviser operands of the integer division. +Before division both operands are rounded to whole numbers. The fractional part of the result is dropped. + + + +Sub IntegerDivision + Print 5 \ 4 , 5 / 4 ' 1 , 1.25 + Print 7 \ 4 , 7 / 4 ' 1 , 1.75 +End Sub + + +
+ + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03080000.xhp b/helpcontent2/source/text/sbasic/shared/03080000.xhp new file mode 100644 index 000000000..dcadb6f25 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080000.xhp @@ -0,0 +1,48 @@ + + + + + + + + +Numeric Functions +/text/sbasic/shared/03080000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Numeric Functions + The following numeric functions perform calculations. Mathematical and Boolean operators are described in a separate section. Functions differ from operators in that functions pass arguments and return a result, instead of operators that return a result by combining two numeric expressions. +
+ + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080100.xhp b/helpcontent2/source/text/sbasic/shared/03080100.xhp new file mode 100644 index 000000000..9e50eae34 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080100.xhp @@ -0,0 +1,44 @@ + + + + + + + + +Trigonometric Functions +/text/sbasic/shared/03080100.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Trigonometric Functions + The following are the trigonometric functions that are supported in $[officename] Basic. +
+ + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080101.xhp b/helpcontent2/source/text/sbasic/shared/03080101.xhp new file mode 100644 index 000000000..4188f8cca --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080101.xhp @@ -0,0 +1,76 @@ + + + + + + + Atn Function + /text/sbasic/shared/03080101.xhp + + + + +
+ +Atn function + +

Atn Function

+ Trigonometric function that returns the arctangent of a numeric expression. The return value is in the range -Pi/2 to +Pi/2. +
+ The arctangent is the inverse of the tangent function. The Atn Function returns the angle "Alpha", expressed in radians, using the tangent of this angle. The function can also return the angle "Alpha" by comparing the ratio of the length of the side that is opposite of the angle to the length of the side that is adjacent to the angle in a right-angled triangle. + Atn(side opposite the angle/side adjacent to angle)= Alpha + + + + Atn (Number As Double) As Double + + + Double + + + Number: Any numerical expression that represents the ratio of two sides of a right triangle. The Atn function returns the corresponding angle in radians (arctangent). + To convert radians to degrees, multiply radians by 180/pi. + degree=(radian*180)/pi + radian=(degree*pi)/180 + Pi is here the fixed circle constant with the rounded value 3.14159. Pi is a Basic mathematical constant. + + + + + + ' The following example calculates for a right-angled triangle + ' the angle Alpha from the tangent of the angle Alpha: + Sub ExampleAtn + ' rounded Pi = 3.14159 Is a predefined constant + Dim d1 As Double + Dim d2 As Double + d1 = InputBox("Enter the length of the side adjacent to the angle: ","Adjacent") + d2 = InputBox("Enter the length of the side opposite the angle: ","Opposite") + Print "The Alpha angle is"; (atn (d2/d1) * 180 / Pi); " degrees" + End Sub + + +
+ + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080102.xhp b/helpcontent2/source/text/sbasic/shared/03080102.xhp new file mode 100644 index 000000000..9f2e227ea --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080102.xhp @@ -0,0 +1,79 @@ + + + + + + + Cos Function + /text/sbasic/shared/03080102.xhp + + + + + + +
+ + Cos function + + + +

Cos Function

+Calculates the cosine of an angle. The angle is specified in radians. The result lies between -1 and 1. +
+Using the angle Alpha, the Cos function calculates the ratio of the length of the side that is adjacent to the angle, divided by the length of the hypotenuse in a right-angled triangle. +Cos(Alpha) = Adjacent/Hypotenuse + + +Cos (Number As Double) As Double + + + +Double + + + Number: Numeric expression that specifies an angle in radians that you want to calculate the cosine for. +To convert degrees to radians, multiply degrees by pi/180. To convert radians to degrees, multiply radians by 180/pi. +degree=(radian*180)/pi +radian=(degree*pi)/180 +Pi is here the fixed circle constant with the rounded value 3.14159... + + + + + +' The following example allows for a right-angled triangle the input of +' secant and angle (in degrees) and calculates the length of the hypotenuse: +Sub ExampleCosinus +' rounded Pi = 3.14159 +Dim d1 As Double, dAngle As Double + d1 = InputBox("Enter the length of the adjacent side: ","Adjacent") + dAngle = InputBox("Enter the angle Alpha (in degrees): ","Alpha") + Print "The length of the hypothenuse is"; (d1 / cos (dAngle * Pi / 180)) +End Sub + + +
+ + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03080103.xhp b/helpcontent2/source/text/sbasic/shared/03080103.xhp new file mode 100644 index 000000000..7f9f25a15 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080103.xhp @@ -0,0 +1,81 @@ + + + + + + + Sin Function + /text/sbasic/shared/03080103.xhp + + + + + + +
+ + Sin function + + + +

Sin Function

+Returns the sine of an angle. The angle is specified in radians. The result lies between -1 and 1. +
+Using the angle Alpha, the Sin function returns the ratio of the length of the opposite side of an angle to the length of the hypotenuse in a right-angled triangle. +Sin(Alpha) = side opposite the angle/hypotenuse + + + +Sin (Number As Double) As Double + + + +Double + + + Number: Numeric expression that defines the angle in radians that you want to calculate the sine for. +To convert degrees to radians, multiply degrees by Pi/180, and to convert radians to degrees, multiply radians by 180/Pi. +degrees=(radians*180)/Pi +radians=(degrees*Pi)/180 +Pi is approximately 3.141593. + + + + + +' In this example, the following entry is possible for a right-angled triangle: +' The side opposite the angle and the angle (in degrees) to calculate the length of the hypotenuse: +Sub ExampleSine +' Pi = 3.1415926 is a predefined variable +Dim d1 As Double +Dim dAlpha As Double + d1 = InputBox("Enter the length of the opposite side: ","Opposite Side") + dAlpha = InputBox("Enter the angle Alpha (in degrees): ","Alpha") + Print "The length of the hypotenuse is"; (d1 / sin (dAlpha * Pi / 180)) +End Sub + + +
+ + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03080104.xhp b/helpcontent2/source/text/sbasic/shared/03080104.xhp new file mode 100644 index 000000000..aa1978567 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080104.xhp @@ -0,0 +1,81 @@ + + + + + + + Tan Function + /text/sbasic/shared/03080104.xhp + + + + + + +
+ + Tan function + + + +

Tan Function

+Determines the tangent of an angle. The angle is specified in radians.i71396 +
+Using the angle Alpha, the Tan function calculates the ratio of the length of the side opposite the angle to the length of the side adjacent to the angle in a right-angled triangle. +Tan(Alpha) = side opposite the angle/side adjacent to angle + + + +Tan (Number As Double) As Double + + + +Double + + + Number: Any numeric expression that you want to calculate the tangent for (in radians). +To convert degrees to radians, multiply by Pi/180. To convert radians to degrees, multiply by 180/Pi. +degrees=(radians*180)/Pi +radians=(degrees*Pi)/180 +Pi is approximately 3.141593. + + + + + +' In this example, the following entry is possible for a right-angled triangle: +' The side opposite the angle and the angle (in degrees) to calculate the length of the side adjacent to the angle: +Sub ExampleTangens +' Pi = 3.1415926 is a pre-defined variable +Dim d1 As Double +Dim dAlpha As Double + d1 = InputBox("Enter the length of the side opposite the angle: ","opposite") + dAlpha = InputBox("Enter the Alpha angle (in degrees): ","Alpha") + Print "the length of the side adjacent the angle is"; (d1 / tan (dAlpha * Pi / 180)) +End Sub + + +
+ + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03080200.xhp b/helpcontent2/source/text/sbasic/shared/03080200.xhp new file mode 100644 index 000000000..66b019353 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080200.xhp @@ -0,0 +1,42 @@ + + + + + + + + +Exponential and Logarithmic Functions +/text/sbasic/shared/03080200.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Exponential and Logarithmic Functions + $[officename] Basic supports the following exponential and logarithmic functions. +
+ + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080201.xhp b/helpcontent2/source/text/sbasic/shared/03080201.xhp new file mode 100644 index 000000000..bf450847e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080201.xhp @@ -0,0 +1,64 @@ + + + + + + + Exp Function + /text/sbasic/shared/03080201.xhp + + + + + +
+ + Exp function + + +Exp Function +Returns the base of the natural logarithm (e = 2.718282) raised to a power. +
+ +Syntax: + +Exp (Number) + + +Return value: +Double + +Parameters: + Number: Any numeric expression that specifies the power that you want to raise "e" to (the base of natural logarithms). The power must be for both single-precision numbers less than or equal to 88.02969 and double-precision numbers less than or equal to 709.782712893, since $[officename] Basic returns an Overflow error for numbers exceeding these values. + + + +Example: + +Sub ExampleLogExp +Dim dValue As Double + Const b1=12.345e12 +Const b2=1.345e34 + dValue=Exp( Log(b1)+Log(b2) ) + MsgBox "" & dValue & chr(13) & (b1*b2) ,0,"Multiplication by logarithm" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080202.xhp b/helpcontent2/source/text/sbasic/shared/03080202.xhp new file mode 100644 index 000000000..b1a312563 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080202.xhp @@ -0,0 +1,66 @@ + + + + + + + Log Function + /text/sbasic/shared/03080202.xhp + + + + + +
+ + Log function + + +

Log Function (BASIC)

+Returns the natural logarithm of a number. +
+ + + +Log (Number) + + + +Double + + + Number: Any numeric expression that you want to calculate the natural logarithm for. +The natural logarithm is the logarithm to the base e. Base e is a constant with an approximate value of 2.718282... +You can calculate logarithms to any base (n) for any number (x) by dividing the natural logarithm of x by the natural logarithm of n, as follows: +Logn(x) = Log(x) / Log(n) + + + + + +Sub ExampleLogExp +Dim a As Double +Dim Const b1=12.345e12 +Dim Const b2=1.345e34 + a=Exp( Log(b1)+Log(b2) ) + MsgBox "" & a & chr(13) & (b1*b2) ,0,"Multiplication by logarithm function" +End Sub + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080300.xhp b/helpcontent2/source/text/sbasic/shared/03080300.xhp new file mode 100644 index 000000000..e0cad76a8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080300.xhp @@ -0,0 +1,42 @@ + + + + + + + + +Generating Random Numbers +/text/sbasic/shared/03080300.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Generating Random Numbers + The following statements and functions generate random numbers. +
+ + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080301.xhp b/helpcontent2/source/text/sbasic/shared/03080301.xhp new file mode 100644 index 000000000..c846b1501 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080301.xhp @@ -0,0 +1,74 @@ + + + + + + + Randomize Statement + /text/sbasic/shared/03080301.xhp + + + + + + +
+ + Randomize statement + + + +Randomize Statement +Initializes the random-number generator used by the Rnd function. +
+ +Syntax: + +Randomize [Number] + +Parameters: + Number: Any integer value. Used as seed to initialize the random-number generator. Equal seeds result in equal random-number sequences by the Rnd function. If the parameter is omitted, the Randomize statement will be ignored. +Unless a predictable sequence of numbers is desired, there is no need to use the Randomize statement, as the random-number generator will be initialized automatically at first use – it will be seeded using a system-provided random-number generator that produces uniformly-distributed, non-deterministic random numbers. If no such generator is available on the system, the system time will be used as seed. +The Randomize statement affects BASIC's Rnd function only. Other random-number generators (for example the Calc's RAND() function, etc.) are not affected by it. + + + +Example: + +Sub ExampleRandomize +Dim iCount As Integer, iVar As Integer, sText As String +Dim iSpectral(10) As Integer + Randomize 2^14-1 + For iCount = 1 To 1000 + iVar = Int(10 * Rnd) ' Range from 0 to 9 + iSpectral(iVar) = iSpectral(iVar) +1 + Next iCount + sText = " | " + For iCount = 0 To 9 + sText = sText & iSpectral(iCount) & " | " + Next iCount + MsgBox sText,0,"Spectral Distribution" +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080302.xhp b/helpcontent2/source/text/sbasic/shared/03080302.xhp new file mode 100644 index 000000000..109723caf --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080302.xhp @@ -0,0 +1,76 @@ + + + + + + + Rnd Function + /text/sbasic/shared/03080302.xhp + + + + + + +
+ + Rnd function + + + +Rnd Function +Returns a random number between 0 and 1. +
+ +Syntax: + +Rnd [(Expression)] + +Return value: +Double + +Parameters: + Expression: Has no effect, is ignored if provided. +The Rnd function returns decimal fractions ranging from 0 (included) to 1 (excluded) according to a uniform distribution. It uses the Mersenne Twister 19937 random-number generator. To generate random integers in a given range, use a formula like in the example below. A Randomize statement with a defined seed value can be used beforehand, if a predictable sequence of numbers is desired. + + + +Example: + +Sub ExampleRandomSelect +Dim iVar As Integer + iVar = Int((15 * Rnd) -2) + Select Case iVar + Case 1 To 5 + Print "Number from 1 to 5" + Case 6, 7, 8 + Print "Number from 6 to 8" + Case Is > 8 And iVar < 11 + Print "Greater than 8" + Case Else + Print "Outside range 1 to 10" + End Select +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080400.xhp b/helpcontent2/source/text/sbasic/shared/03080400.xhp new file mode 100644 index 000000000..b1c3eb18a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080400.xhp @@ -0,0 +1,41 @@ + + + + + + + + +Square Root Calculation +/text/sbasic/shared/03080400.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Square Root Calculation + Use this function to calculate square roots. +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080401.xhp b/helpcontent2/source/text/sbasic/shared/03080401.xhp new file mode 100644 index 000000000..35a3c55e4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080401.xhp @@ -0,0 +1,65 @@ + + + + + + + Sqr Function + /text/sbasic/shared/03080401.xhp + + + + + + +
+ + Sqr function + + + +Sqr Function +Calculates the square root of a numeric expression. +
+ +Syntax: + +Sqr (Number) + + +Return value: +Double + +Parameters: + Number: Any numeric expression that you want to calculate the square root for. +A square root is the number that you multiply by itself to produce another number, for example, the square root of 36 is 6. + + + +Example: + +Sub ExampleSqr +Dim iVar As Single + iVar = 36 + MsgBox Sqr(iVar) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03080500.xhp b/helpcontent2/source/text/sbasic/shared/03080500.xhp new file mode 100644 index 000000000..2a8754efa --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080500.xhp @@ -0,0 +1,43 @@ + + + + + + + + +Integers +/text/sbasic/shared/03080500.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Integers and Fractional + Functions to round values to integers, and to take the fractional part of a value. +
+ + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080501.xhp b/helpcontent2/source/text/sbasic/shared/03080501.xhp new file mode 100644 index 000000000..0cc5f18e0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080501.xhp @@ -0,0 +1,64 @@ + + + + + + + Fix Function + /text/sbasic/shared/03080501.xhp + + + + + + +
+ + Fix function + +Fix Function +Returns the integer value of a numeric expression by removing the fractional part of the number. +
+ + +Fix (Expression) + + +Double + + + Expression: Numeric expression that you want to return the integer value for. + + + + + +Sub ExampleFix + Print Fix(3.14159) ' returns 3. + Print Fix(0) ' returns 0. + Print Fix(-3.14159) ' returns -3. +End Sub + +
+ Int Function + Frac Function +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080502.xhp b/helpcontent2/source/text/sbasic/shared/03080502.xhp new file mode 100644 index 000000000..b695125ad --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080502.xhp @@ -0,0 +1,66 @@ + + + + + + + Int Function + /text/sbasic/shared/03080502.xhp + + + + + + +
+ + Int function + + + +Int Function +Returns the integer portion of a number. +
+ + +Int (Number) + + +Double + + + Number: Any valid numeric expression. + + + + + +Sub ExampleInt + Print Int(3.99) ' returns the value 3 + Print Int(0) ' returns the value 0 + Print Int(-3.14159) ' returns the value -4 +End Sub + +
+ Fix Function + Frac Function +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080503.xhp b/helpcontent2/source/text/sbasic/shared/03080503.xhp new file mode 100644 index 000000000..64e7fc9a0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080503.xhp @@ -0,0 +1,47 @@ + + + + + + + Frac Function + /text/sbasic/shared/03080503.xhp + + + +
+ + Frac function + +

Frac Function

+ Returns the fractional portion of a number. +
+ + Frac (Number) + + Double + + Number: Any valid numeric expression. + + + + + Sub ExampleFrac + Print Frac(3.99) ' returns the value 0.99 + Print Frac(0) ' returns the value 0 + Print Frac(-3.14159) ' returns the value -0.14159 + End Sub + +
+ Fix Function + Int Function +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03080600.xhp b/helpcontent2/source/text/sbasic/shared/03080600.xhp new file mode 100644 index 000000000..ec743146f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080600.xhp @@ -0,0 +1,41 @@ + + + + + + + + +Absolute Values +/text/sbasic/shared/03080600.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Absolute Values + This function returns absolute values. +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080601.xhp b/helpcontent2/source/text/sbasic/shared/03080601.xhp new file mode 100644 index 000000000..777db56b0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080601.xhp @@ -0,0 +1,67 @@ + + + + + + + Abs Function + /text/sbasic/shared/03080601.xhp + + + + + + +
+ + Abs function + + + +Abs Function +Returns the absolute value of a numeric expression. +
+ +Syntax: + +Abs (Number) + + +Return value: +Double + +Parameters: + Number: Any numeric expression that you want to return the absolute value for. Positive numbers, including 0, are returned unchanged, whereas negative numbers are converted to positive numbers. +The following example uses the Abs function to calculate the difference between two values. It does not matter which value you enter first. + + + +Example: + +Sub ExampleDifference +Dim siW1 As Single +Dim siW2 As Single + siW1 = Int(InputBox("Please enter the first amount","Value Input")) + siW2 = Int(InputBox("Please enter the second amount","Value Input")) + Print "The difference is "; Abs(siW1 - siW2) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03080700.xhp b/helpcontent2/source/text/sbasic/shared/03080700.xhp new file mode 100644 index 000000000..d578e1cdf --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080700.xhp @@ -0,0 +1,41 @@ + + + + + + + + +Expression Signs +/text/sbasic/shared/03080700.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Expression Signs + This function returns the algebraic sign of a numeric expression. +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080701.xhp b/helpcontent2/source/text/sbasic/shared/03080701.xhp new file mode 100644 index 000000000..e90641510 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080701.xhp @@ -0,0 +1,100 @@ + + + + + + + Sgn Function + /text/sbasic/shared/03080701.xhp + + + + + + +
+ + Sgn function + + + +Sgn Function +Returns an integer number between -1 and 1 that indicates if the number that is passed to the function is positive, negative, or zero. +
+ +Syntax: + +Sgn (Number) + + +Return value: +Integer + +Parameters: + Number: Numeric expression that determines the value that is returned by the function. + + + + + Number + + + Return value + + + + + negative + + + Sgn returns -1. + + + + + 0 + + + Sgn returns 0. + + + + + positive + + + Sgn returns 1. + + +
+ + + + +Example: + +Sub ExampleSgn + Print sgn(-10) ' returns -1 + Print sgn(0) ' returns 0 + Print sgn(10) ' returns 1 +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03080800.xhp b/helpcontent2/source/text/sbasic/shared/03080800.xhp new file mode 100644 index 000000000..f340a1310 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080800.xhp @@ -0,0 +1,42 @@ + + + + + + + + +Converting Numbers +/text/sbasic/shared/03080800.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Converting Numbers + The following functions convert numbers from one number format to another. +
+ + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03080801.xhp b/helpcontent2/source/text/sbasic/shared/03080801.xhp new file mode 100644 index 000000000..82d5bb968 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080801.xhp @@ -0,0 +1,78 @@ + + + + + + + Hex Function + /text/sbasic/shared/03080801.xhp + + + + + + +
+ + Hex function + + + +Hex Function +Returns a string that represents the hexadecimal value of a number. +
+ +Syntax: + +Hex (Number) + + +Return value: +String + +Parameters: + Number: Any numeric expression that you want to convert to a hexadecimal number. + + + +Example: + +Sub ExampleHex +' uses BasicFormulas in %PRODUCTNAME Calc +Dim a2, b2, c2 As String + a2 = "&H3E8" + b2 = Hex2Lng(a2) + MsgBox b2 + c2 = Lng2Hex(b2) + MsgBox c2 +End Sub + +Function Hex2Lng(sHex As String) As Long +' Returns a 32-bit signed integer number from an 8-digit hexadecimal value. + Hex2Lng = clng( sHex ) +End Function + +Function Lng2Hex(iLong As Long) As String +' Calculates the 8-digit hexadecimal value out of a 32-bit signed integer number. + Lng2Hex = "&H" & Hex( iLong ) +End Function + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03080802.xhp b/helpcontent2/source/text/sbasic/shared/03080802.xhp new file mode 100644 index 000000000..14910c900 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03080802.xhp @@ -0,0 +1,62 @@ + + + + + + + Oct Function + /text/sbasic/shared/03080802.xhp + + + + + + +
+ + Oct function + + + +Oct Function +Returns the octal value of a number. +
+ +Syntax: + +Oct (Number) + + +Return value: +String + +Parameters: + Number: Any numeric expression that you want to convert to an octal value. + + + +Example: + +Sub ExampleOct + MsgBox Oct(255) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090000.xhp b/helpcontent2/source/text/sbasic/shared/03090000.xhp new file mode 100644 index 000000000..d632a2a8e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090000.xhp @@ -0,0 +1,45 @@ + + + + + + + + +Controlling Program Execution +/text/sbasic/shared/03090000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Controlling Program Execution + The following statements control the execution of a program. +
+ A program generally executes from the first line of code to the last line of code. You can also execute certain procedures within the program according to specific conditions, or repeat a section of the program within a sub-procedure or function. You can use loops to repeat parts of a program as many times as necessary, or until a certain condition is met. These type of control statements are classified as Condition, Loop, or Jump statements. + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090100.xhp b/helpcontent2/source/text/sbasic/shared/03090100.xhp new file mode 100644 index 000000000..e34cf1f1f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090100.xhp @@ -0,0 +1,43 @@ + + + + + + + + +Condition Statements +/text/sbasic/shared/03090100.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Condition Statements + The following statements are based on conditions. +
+ + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090101.xhp b/helpcontent2/source/text/sbasic/shared/03090101.xhp new file mode 100644 index 000000000..bd9875630 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090101.xhp @@ -0,0 +1,98 @@ + + + + + + + If...Then...Else Statement + /text/sbasic/shared/03090101.xhp + + + + + +
+ + If statement + ElseIf; If statement + Else If;If statement + Else;If statement + Else;If statement + End If;If statement + EndIf;If statement + + +

If...Then...Else Statement

+Defines one or more statement blocks that you only want to execute if a given condition or expression is True. +
+ + +If...EndIf statement +ElseIf fragment +Else fragment + + + If condition Then + statements + [{ElseIf|Else If} expression Then + statements] + [Else + statements] + {EndIf|End If} + + Instead of Else If you can write ElseIf, instead of End If you can write EndIf. + If statements can be shortened to one line when using single statement blocks. + + If condition Then statement [Else statement] + + + + The If...Then statement executes program blocks depending on given conditions. When %PRODUCTNAME Basic encounters an If statement, the condition is tested. If the condition is True, all subsequent statements up to the next Else or ElseIf statement are executed. If the condition is False, and an ElseIf statement follows, %PRODUCTNAME Basic tests the next expression and executes the following statements if the condition is True. If False, the program continues either with the next ElseIf or Else statement. Statements following Else are executed only if none of the previously tested conditions were True. After all conditions are evaluated, and the corresponding statements executed, the program continues with the statement following EndIf. +You can nest multiple If...Then statements. + Else and ElseIf statements are optional. +You can use GoTo and GoSub to jump out of an If...Then block, but not to jump into an If...Then structure. + + +The following example enables you to enter the expiration date of a product, and determines if the expiration date has passed. + +Sub ExampleIfThenDate + Dim sDate As String + Dim sToday As String + sDate = InputBox("Enter the expiration date (MM.DD.YYYY)") + sDate = Right$(sDate, 4) + Mid$(sDate, 4, 2) + Left$(sDate, 2) + sToday = Date$ + sToday = Right$(sToday, 4)+ Mid$(sToday, 4, 2) + Left$(sToday, 2) + If sDate < sToday Then + MsgBox "The expiration date has passed" + ElseIf sDate > sToday Then + MsgBox "The expiration date has not yet passed" + Else + MsgBox "The expiration date is today" + End If +End Sub + + +
+ Select Case statement + Iif or Switch functions +
+ + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090102.xhp b/helpcontent2/source/text/sbasic/shared/03090102.xhp new file mode 100644 index 000000000..571abc33d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090102.xhp @@ -0,0 +1,85 @@ + + + + + + + Select...Case Statement + /text/sbasic/shared/03090102.xhp + + + + + + +
+ + Select Case statement + Case keyword; in Select Case statement + + + +

Select...Case Statement

+Defines one or more statement blocks depending on the value of an expression. +
+ + +Select Case syntax + + Select Case expression + Case values + Statement Block + [ Case values2 + Statement Block] + [ Case Else + Statement Block] + End Select + + + + expression: Any expression that controls if the statement block that follows the respective Case clause is executed. + values: Any value list that is compatible with the expression. The statement block that follows the Case clause is executed if expression matches values. + + + +Sub ExampleRandomSelect +Dim iVar As Integer + iVar = Int((15 * Rnd) -2) + Select Case iVar + Case 1 To 5 + Print "Number from 1 to 5" + Case 6, 7, 8 + Print "Number from 6 to 8" + Case 8 To 10 + Print "Greater than 8" + Case Else + Print "Out of range 1 to 10" + End Select +End Sub + + +
+ + + If statement + Iif or Switch functions +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090103.xhp b/helpcontent2/source/text/sbasic/shared/03090103.xhp new file mode 100644 index 000000000..07b6e453d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090103.xhp @@ -0,0 +1,67 @@ + + + + + +IIf Function +/text/sbasic/shared/03090103.xhp + + +Sun Microsystems, Inc. + + + +
+IIf function + +

IIf Function

+Returns one of two possible function results, depending on the logical value of the evaluated expression. +
+ + +IIf (Expression, ExpressionTrue, ExpressionFalse) + + + +Expression: Any expression that you want to evaluate. If the expression evaluates to True, the function returns the result of ExpressionTrue, otherwise it returns the result of ExpressionFalse. + +ExpressionTrue, ExpressionFalse: Any expression, one of which will be returned as the function result, depending on the logical evaluation. +IIf evaluates both ExpressionTrue and ExpressionFalse even if it returns only one of them. If one of the expressions results in error, the function returns the error. For example, do not use IIF to bypass a possible division by zero result. + + + + +REM Returns the maximum of 3 values +Function Max (A As Double, B As Double, C, As Double) As Double + Max = IIf( A >= B, A, B) + Max = IIf( C >= Max, C, Max) +End Function +REM Bad usage of function IIf +Function Inverse(A As Double) As Double + Inverse = IIf( A = 0, 0, 1/A ) +End Function + + +
+ If or Select Case statements + Switch function +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090200.xhp b/helpcontent2/source/text/sbasic/shared/03090200.xhp new file mode 100644 index 000000000..41c8aaedf --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090200.xhp @@ -0,0 +1,43 @@ + + + + + + + + +Loops +/text/sbasic/shared/03090200.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Loops + The following statements execute loops. +
+ + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090201.xhp b/helpcontent2/source/text/sbasic/shared/03090201.xhp new file mode 100644 index 000000000..696ffeecd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090201.xhp @@ -0,0 +1,102 @@ + + + + + + + Do...Loop Statement + /text/sbasic/shared/03090201.xhp + + + + + +
+ + Do...Loop statement + While; Do loop + Until + loops + + + +Do...Loop Statement + Repeats the statements between the Do and the Loop statement while the condition is True or until the condition becomes True. +
+ + +Do statement + + Do {While | Until} condition = True + ' Do While: The statement block is repeated as long as the condition is true + ' Do Until: The statement block is repeated as long as the condition is false + statements + [Exit Do] + statements + Loop + + +Do...Loop statement + + Do + statements + [Exit Do] + statements + ' Loop While: The statement block repeats as long as the condition is true + ' Loop Until: The statement block repeats until the condition is true + Loop {While | Until} condition = True + + + +The Do...Loop statement executes a loop as long as, or until, a certain condition is True. The condition for exiting the loop must be entered following either the Do or the Loop statement. The above examples are valid combinations. + condition: A comparison, numeric or Basic expression, that evaluates to either True or False. + statements: Statements that you want to repeat while or until a condition is True. + +Use the Exit Do statement to unconditionally end the loop. You can add this statement anywhere in a Do...Loop statement. You can also define an exit condition using the If...Then structure as follows: + + Do... + statements + If condition = True Then Exit Do + statements + Loop... + + + + +Sub ExampleDoLoop + Dim sFile As String + Dim sPath As String + sPath = "c:\" + sFile = Dir$( sPath ,22) + If sFile <> "" Then + Do + MsgBox sFile + sFile = Dir$ + Loop Until sFile = "" + End If +End Sub + + +
+ For, Select Case or While statements + Iif or Switch functions +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090202.xhp b/helpcontent2/source/text/sbasic/shared/03090202.xhp new file mode 100644 index 000000000..eee101283 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090202.xhp @@ -0,0 +1,123 @@ + + + + + + + For...Next Statement + /text/sbasic/shared/03090202.xhp + + + + + + +
+ +For statement +For Each statement +In keyword +Next keyword +Step keyword +To keyword + + + +

For...Next Statement

+ Repeats the statements between the For...Next block a specified number of times. +
+ +

Syntax:

+ + For Statement diagram + + +For counter=start To end [Step step] + statement-block + [Exit For] + statement-block +Next [counter] + + + For Each Statement diagram + + + For Each item In list + statement-block + [Exit For] + statement-block + Next [item] + + +

Variables:

+ counter: Loop counter initially assigned the value to the right of the equal sign (start). Only numeric variables are valid. The loop counter increases or decreases according to the variable step until end is passed. + start: Numeric variable that defines the initial value at the beginning of the loop. + end: Numeric variable that defines the final value at the end of the loop. + step: Sets the value by which to increase or decrease the loop counter. If step is not specified, the loop counter is incremented by 1. In this case, end must be greater than start. If you want to decrease counter, end must be less than start, and step must be assigned a negative value. +The For...Next loop repeats all of the statements in the loop for the number of times that is specified by the parameters. +As the counter variable is decreased, %PRODUCTNAME Basic checks if the end value has been reached. As soon as the counter passes the end value, the loop automatically terminates. +It is possible to nest For...Next statements. If you do not specify a variable following the Next statement, Next automatically refers to the most recent For statement. +If you specify an increment of 0, the statements between For and Next are repeated continuously. +When counting down the counter variable, %PRODUCTNAME Basic checks for overflow or underflow. The loop ends when counter exceeds end (positive Step value) or is less than end (negative Step value). +Use the Exit For statement to exit the loop unconditionally. This statement must be within a For...Next loop. Use the If...Then statement to test the exit condition as follows: + + For... + statement-block + If condition = True Then Exit For + statement-block + Next + + +In nested For...Next loops, if you exit a loop unconditionally with Exit For, only one loop is exited. + +

Examples

+The following example uses two nested loops to sort a string array with 10 elements ( sEntry() ), that is filled with various contents: + +Sub ExampleSort +Dim sEntry(9) As String +Dim iCount As Integer, iCount2 As Integer +Dim sTemp As String + sEntry = Array("Jerry","Patty","Kurt","Thomas","Michael",_ + "David","Cathy","Susie","Edward","Christine") + For iCount = 0 To 9 + For iCount2 = iCount + 1 To 9 + If sEntry(iCount) > sEntry(iCount2) Then + sTemp = sEntry(iCount) + sEntry(iCount) = sEntry(iCount2) + sEntry(iCount2) = sTemp + End If + Next iCount2 + Next iCount + For iCount = 0 To 9 + Print sEntry(iCount) + Next iCount +End Sub + +This explores the content of an array to display each item it contains. + + Sub list_iteration + cutlery = Array("fork", "knife", "spoon") + For Each item in cutlery + Print item + Next ' item + End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090203.xhp b/helpcontent2/source/text/sbasic/shared/03090203.xhp new file mode 100644 index 000000000..dad29dca3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090203.xhp @@ -0,0 +1,72 @@ + + + + + + + +While...Wend Statement +/text/sbasic/shared/03090203.xhp + + +Sun Microsystems, Inc. + + + + +
+ + While;While...Wend loop + While;While Wend loop + + While...Wend Statement + When a program encounters a While statement, it tests the condition. If the condition is False, the program continues directly following the Wend statement. If the condition is True, the loop is executed until the program finds Wend and then jumps back to the While statement. If the condition is still True, the loop is executed again. +
+ Unlike the Do...Loop statement, you cannot cancel a While...Wend loop with Exit. Never exit a While...Wend loop with GoTo, since this can cause a run-time error. + A Do...Loop is more flexible than a While...Wend. + + + + While syntax + + + While Condition [statements] Wend + + + + Sub ExampleWhileWend + Dim stext As String + Dim iRun As Integer + sText ="This is a short text" + iRun = 1 + While iRun < Len(sText) + If Mid(sText,iRun,1 )<> " " Then Mid( sText ,iRun, 1) = Chr( 1 + Asc( Mid(sText,iRun,1 )) ) + iRun = iRun + 1 + Wend + MsgBox sText,0,"Text encoded" + End Sub + + +
+ Do...Until or Do...While statement + Exit statement +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090300.xhp b/helpcontent2/source/text/sbasic/shared/03090300.xhp new file mode 100644 index 000000000..c4e2a5e62 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090300.xhp @@ -0,0 +1,43 @@ + + + + + + + + +Jumps +/text/sbasic/shared/03090300.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Jumps + The following statements execute jumps. +
+ + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090301.xhp b/helpcontent2/source/text/sbasic/shared/03090301.xhp new file mode 100644 index 000000000..b2331842b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090301.xhp @@ -0,0 +1,91 @@ + + + + + + + GoSub...Return Statement + /text/sbasic/shared/03090301.xhp + + + + + +
+ + GoSub...Return statement + label; in GoSub...Return statement + + +

GoSub...Return Statement

+ Calls a subroutine that is indicated by a label inside a Sub or a Function. The statements following the label are executed until the next Return statement. Afterwards, the program continues with the statement that follows the GoSub statement. +
+ + + +GoSub label[:] + + + +label: A line identifier indicating where to continue execution. The scope of a label in that of the routine it belongs to. +The GoSub statement calls a local subroutine indicated by a label from within a subroutine or a function. The name of the label must end with a colon (":"). + + Sub/Function foo + ' statements + GoSub label + ' statements + Exit Sub/Function + label: + ' statements + Return + End Sub/Function + + +If the program encounters a Return statement not preceded by GoSub, $[officename] Basic returns an error message. Use Exit Sub or Exit Function to ensure that the program leaves a Sub or Function before reaching the next Return statement. +The following example demonstrates the use of GoSub and Return. By executing a program section twice, the program calculates the square root of two numbers that are entered by the user. + + + +Sub ExampleGoSub +Dim iInputa As Single +Dim iInputb As Single +Dim iInputc As Single + iInputa = Int(InputBox("Enter the first number: ","NumberInput")) + iInputb = Int(InputBox("Enter the second number: ","NumberInput")) + iInputc=iInputa + GoSub SquareRoot + Print "The square root of";iInputa;" is";iInputc + iInputc=iInputb + GoSub SquareRoot + Print "The square root of";iInputb;" is";iInputc + Exit Sub +SquareRoot: + iInputc=sqr(iInputc) + Return +End Sub + + +
+ + +
+ + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090302.xhp b/helpcontent2/source/text/sbasic/shared/03090302.xhp new file mode 100644 index 000000000..4f9cd57f5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090302.xhp @@ -0,0 +1,71 @@ + + + + + + + + + GoTo Statement + /text/sbasic/shared/03090302.xhp + + + Sun Microsystems, Inc. + + + + +
+ + GoTo statement + label; in GoTo statement + +GoTo Statement + Continues program execution within a Sub or Function at the procedure line indicated by a label. +
+Syntax: + +GoTo label[:] + + +Parameters: +label: A line identifier indicating where to continue execution. The scope of a label is that of the routine it belongs to. + Use the GoTo statement to instruct $[officename] Basic to continue program execution at another place within the procedure. The position must be indicated by a label. To set a label, assign a name, and end it with a colon (":"). + You cannot use the GoTo statement to jump out of a Sub or Function. +Example: + + Sub/Function + ' statement block + GoTo Label1 + Label2: + ' statement block + Exit Sub/Function + Label1: + ' statement block + GoTo Label2 + End Sub/Function + + +
+ + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090303.xhp b/helpcontent2/source/text/sbasic/shared/03090303.xhp new file mode 100644 index 000000000..cad7a574f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090303.xhp @@ -0,0 +1,84 @@ + + + + + + + On...GoSub Statement; On...GoTo Statement + /text/sbasic/shared/03090303.xhp + + + + + +
+ + On...GoSub statement + On...GoTo statement + label; in On...GoSub statement + label; in On...GoTo statement + + + +

On...GoSub Statement; On...GoTo Statement

+Branches to one of several specified lines in the program code, depending on the value of a numeric expression. +
+ + +On GoSub/GoTo syntax + +On expression GoSub Label1[, Label2[, Label3[,...]]] +On expression GoTo Label1[, Label2[, Label3[,...]]] + + + + expression: Any numeric expression between 0 and 255 that determines which of the lines the program branches to. If expression is 0, the statement is not executed. If expression is greater than 0, the program jumps to the label that has a position number that corresponds to the expression (1 = First label; 2 = Second label) + label: Target line according to GoTo or GoSub structure. +The GoTo or GoSub conventions are valid. + + + +Sub ExampleOnGosub +Dim iVar As Integer +Dim sVar As String + iVar = 2 + sVar ="" + On iVar GoSub Sub1, Sub2 + On iVar GoTo Line1, Line2 + Exit Sub +Sub1: + sVar =sVar & " From Sub 1 to" : Return +Sub2: + sVar =sVar & " From Sub 2 to" : Return +Line1: + sVar =sVar & " Label 1" : GoTo Ende +Line2: + sVar =sVar & " Label 2" +Ende: + MsgBox sVar,0,"On...GoSub" +End Sub + + +
+ + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090400.xhp b/helpcontent2/source/text/sbasic/shared/03090400.xhp new file mode 100644 index 000000000..91ea068ef --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090400.xhp @@ -0,0 +1,50 @@ + + + + + + + + +Further Statements +/text/sbasic/shared/03090400.xhp + + +Sun Microsystems, Inc. + + + +
+ Further Statements + Statements that do not belong to any of the other categories are described here. +
+ + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090401.xhp b/helpcontent2/source/text/sbasic/shared/03090401.xhp new file mode 100644 index 000000000..2737a682c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090401.xhp @@ -0,0 +1,69 @@ + + + + + +Call Statement +/text/sbasic/shared/03090401.xhp + + +Sun Microsystems, Inc. + + + +
+Call statement + +

Call Statement

+Transfers the control of the program to a subroutine, a function, or a procedure of a Dynamic Link Library (DLL). The keyword, type and number of parameters is dependent on the routine that is being called. +
+ + + Call Statement diagram + +[Call] name [(] [param :=] value, ... [)] + + + +name: Name of the subroutine, the function, or the DLL that you want to call + +param: Keyword parameter name to pass to the routine, followed by its value. The name must match the routine declaration. Keywords are optional and can be used in any order. +value: Positional parameter value. The type is dependent on the routine that is being called +When mixing positional and keyword parameters, make sure positional parameters are following the routine declaration order. +When a function is used as an expression, enclosing parameters with brackets becomes necessary. Using a Declare statement is compulsory prior to call a DLL. + + +Sub ExampleCall + Dim value As String + value = "LibreOffice" + Call aRoutine value + aRoutine text := value +End Sub + +Sub aRoutine (text as String) + Msgbox text +End Sub + + +
+ +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090402.xhp b/helpcontent2/source/text/sbasic/shared/03090402.xhp new file mode 100644 index 000000000..18d47e98c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090402.xhp @@ -0,0 +1,81 @@ + + + + + + + Choose Function + /text/sbasic/shared/03090402.xhp + + + + + + +
+ + Choose function + + + +

Choose Function

+Returns a selected value from a list of arguments. +
+ + + + Choose (Index As Integer, Expression1[, Expression2, ... [, Expression_n]]) As Variant + + +Variant. A value inferred from the Index parameter. + + + Index: Any numeric expression rounded to a whole number. Index accepts integer values starting at 1 that specify which of the possible choices to return. + Expression1, Expression2, …, Expression_n: Expressions representing each of the possible choices. +The Choose function returns a value from the list of expressions based on the index value. If Index = 1, the function returns the first expression in the list, if Index = 2, it returns the second expression, and so on. +If the index value is less than 1 or greater than the number of expressions listed, the function returns a Null value. +Error #5 occurs when parameters are omitted. Error #13 occurs if Index equals Null. + If expressions are omitted - e.g. Choose(5) - or Index=Null, Basic runtime raises error #13. If the chosen expression is not defined -e.g. Choose(2,"a",,45) - "Error 448" is returned !!. + + + + + + +The following example uses the or Choose function to select a string from several strings that form a menu: + + +Sub ExampleChoose + Print ChooseMenu(2) ' "Save Format" + MsgBox Choose(index := -5, 9, "Basic", PI) ' Null + MsgBox Choose(index := 3.14, 9, "Basic", PI) ' PI +End Sub + +Function ChooseMenu(Index As Integer) + ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format") +End Function + + +
+ + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090403.xhp b/helpcontent2/source/text/sbasic/shared/03090403.xhp new file mode 100644 index 000000000..2a4b3d519 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090403.xhp @@ -0,0 +1,71 @@ + + + + + + + Declare Statement + /text/sbasic/shared/03090403.xhp + + + + + + +
+ + Declare statement + + + +Declare Statement + + DLL (Dynamic Link Library) + + +Declares and defines a subroutine in a DLL file that you want to execute from $[officename] Basic. +
+See also: FreeLibrary + +Syntax: + +Declare {Sub | Function} Name Lib "Libname" [Alias "Aliasname"] [Parameter] [As Type] + + +Parameters: + Name: A different name than defined in the DLL, to call the subroutine from $[officename] Basic. + Aliasname: Name of the subroutine as defined in the DLL. + Libname: File or system name of the DLL. This library is automatically loaded the first time the function is used. + Argumentlist: List of parameters representing arguments that are passed to the procedure when it is called. The type and number of parameters is dependent on the executed procedure. + Type: Defines the data type of the value that is returned by a function procedure. You can exclude this parameter if a type-declaration character is entered after the name. +To pass a parameter to a subroutine as a value instead of as a reference, the parameter must be indicated by the keyword ByVal. + +Example: + +Declare Sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" ( Long ) +Sub ExampleDeclare +Dim lValue As Long + lValue = 5000 + MyMessageBeep( lValue ) + FreeLibrary("user32.dll" ) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090404.xhp b/helpcontent2/source/text/sbasic/shared/03090404.xhp new file mode 100644 index 000000000..ada8a37a8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090404.xhp @@ -0,0 +1,77 @@ + + + + + + + End Statement + /text/sbasic/shared/03090404.xhp + + + + + + +
+ + End statement + + + +End Statement +Ends a procedure or block. +
+ +Syntax: + +End, End Enum, End Function, End If, End Property, End Select, End Sub, End With + + +Parameters: +Use the End statement as follows: + +Statement +End: Is not required, but can be entered anywhere within a procedure to end the program execution. +End Enum: Ends an Enum VBA statement +End Function: Ends a Function statement. +End If: Marks the end of a If...Then...Else block. +End Property: Marks the end of a Property statement. +End Select: Marks the end of a Select Case block. +End Sub: Ends a Sub statement. +End With: Ends a With statement + +Example: + +Sub ExampleRandomSelect +Dim iVar As Integer + iVar = Int((15 * Rnd) -2) + Select Case iVar + Case 1 To 5 + Print "Number from 1 to 5" + Case 6, 7, 8 + Print "Number from 6 to 8" + Case Is > 8 And iVar < 11 + Print "Greater than 8" + Case Else + Print "Outside range 1 to 10" + End Select +End Sub + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090405.xhp b/helpcontent2/source/text/sbasic/shared/03090405.xhp new file mode 100644 index 000000000..7297dd934 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090405.xhp @@ -0,0 +1,64 @@ + + + + + + + FreeLibrary Function + /text/sbasic/shared/03090405.xhp + + + + + + +
+ + FreeLibrary function + + + +FreeLibrary Function +Releases DLLs that were loaded by a Declare statement. A released DLL is automatically reloaded if one of its functions is called. See also: Declare +
+ +Syntax: + +FreeLibrary (LibName As String) + + +Parameters: + LibName: String expression that specifies the name of the DLL. +FreeLibrary can only release DLLs that are loaded during Basic runtime. + + + +Example: + +Declare Sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" ( Long ) +Sub ExampleDeclare +Dim lValue As Long + lValue = 5000 + MyMessageBeep( lValue ) + FreeLibrary("user32.dll" ) +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090406.xhp b/helpcontent2/source/text/sbasic/shared/03090406.xhp new file mode 100644 index 000000000..7ecfbe73c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090406.xhp @@ -0,0 +1,93 @@ + + + + + + Function Statement + /text/sbasic/shared/03090406.xhp + + + +
+ + Function statement + +

Function Statement

+A function is a block of code which runs when it is called. A function is usually called in an expression. +You can pass data, known as parameters or arguments, into a function. You may pass a parameter by value or by reference. When by reference, modifications applied to the parameter in the function will be sent back to the calling code. +A function usually returns data as a result. +
+ + + + Function Statement diagram + + [Private | Public] Function Name[char] (argument1 [As Type][, argument2[char][,...]]) [As typename] + statements + [Exit Function] + statements + End Function + + +
+ scope: Function default scope is Public. A Private scope denotes a module internal routine, not intended to be used from other modules. +
+ name: Name of the subroutine to contain the value returned by the function. + arguments: Parameters to be passed to the subroutine. + + + +
+

Examples:

+ +Sub ExampleExit +Dim sReturn As String +Dim sListArray(10) As String +Dim siStep As Single + For siStep = 0 To 10 ' Fill array with test data + sListArray(siStep) = chr$(siStep + 65) + MsgBox sListArray(siStep) + Next siStep + sReturn = LinSearch(sListArray(), "B") + Print sReturn +End Sub + +Function LinSearch( sList(), sItem As String ) As Integer +Dim iCount As Integer +' Linsearch searches a TextArray:sList() for a TextEntry: +' Return value Is the index of the entry Or 0 (Null) + For iCount=1 To Ubound( sList() ) + If sList( iCount ) = sItem Then + Exit For ' sItem found + End If + Next iCount + If iCount = Ubound( sList() ) Then iCount = 0 + LinSearch = iCount +End Function + +
+ +
+ Subroutines basics + + + +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090407.xhp b/helpcontent2/source/text/sbasic/shared/03090407.xhp new file mode 100644 index 000000000..7e4239841 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090407.xhp @@ -0,0 +1,61 @@ + + + + + + + Rem Statement + /text/sbasic/shared/03090407.xhp + + + + + + +
+ + Rem statement + comments;Rem statement + + + +

Rem Statement

+Specifies that a program line is a comment. +
+ + +Rem Text + + + Text: Any text that serves as a comment. +You can use the single quotation mark instead of the Rem keyword to indicate that the text on a line is comments. This symbol can be inserted directly to the right of the program code, followed by a comment. +You can use a space followed by the underline character _ as the last two characters of a line to continue the logical line on the next line. To continue comment lines, you must enter "Option Compatible" in the same Basic module. + + + +Sub ExampleMid +Dim sVar As String + sVar = "Las Vegas" + Print Mid(sVar,3,5) ' Returns "s Veg" + ' Nothing occurs here +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090408.xhp b/helpcontent2/source/text/sbasic/shared/03090408.xhp new file mode 100644 index 000000000..8aefe030f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090408.xhp @@ -0,0 +1,58 @@ + + + + + + + Stop Statement + /text/sbasic/shared/03090408.xhp + + + + + +
+ + Stop statement + + +

Stop Statement

+Stops the execution of the Basic program. +
+ + + + Stop Statement diagram + + +Stop + + + + +Sub ExampleStop +Dim iVar As Single + iVar = 36 + Stop + MsgBox Sqr(iVar) +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03090409.xhp b/helpcontent2/source/text/sbasic/shared/03090409.xhp new file mode 100644 index 000000000..f10753bde --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090409.xhp @@ -0,0 +1,68 @@ + + + + + + + Sub Statement + /text/sbasic/shared/03090409.xhp + + + + + +
+ + Sub statement + + +

Sub Statement

+Defines a subroutine. +
+ + + + Sub Statement diagram + + +[Private | Public] Sub name[(argument1 [As typename][, argument2[char][,...]])] + ' statements + [Exit Sub] + ' statements +End Sub + + + + name: Name of the subroutine. + arguments: Optional parameters that you want to pass to the subroutine. + + + + + + +
+ Subroutines basics + + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090410.xhp b/helpcontent2/source/text/sbasic/shared/03090410.xhp new file mode 100644 index 000000000..acade098e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090410.xhp @@ -0,0 +1,72 @@ + + + + + + + Switch Function + /text/sbasic/shared/03090410.xhp + + + + + + +
+ + Switch function + + +

Switch Function

+Evaluates a list of arguments, consisting of an expression followed by a value. The Switch function returns a value that is associated with the expression that is passed by this function. +
+ + + +Switch (Expression1, Value1[, Expression2, Value2[..., Expression_n, Value_n]]) As Variant + + + +The Switch function evaluates the expressions from left to right, and then returns the value that is assigned to the function expression. If expression and value are not given as a pair, a runtime error occurs. + Expression: The expression that you want to evaluate. + Value: The value that you want to return if the expression is True. +In the following example, the Switch function assigns the appropriate gender to the name that is passed to the function: + + + + + +Sub ExampleSwitch +Dim sGender As String + sGender = GetGenderIndex( "John" ) + MsgBox sGender +End Sub + +Function GetGenderIndex (sName As String) As String + GetGenderIndex = Switch(sName = "Jane", "female", sName = "John", "male") +End Function + + +
+ + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090411.xhp b/helpcontent2/source/text/sbasic/shared/03090411.xhp new file mode 100644 index 000000000..aa1740ba6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090411.xhp @@ -0,0 +1,56 @@ + + + + + + + +With Statement +/text/sbasic/shared/03090411.xhp + + +Sun Microsystems, Inc. + + + + +
+With statement + +

With Statement

+ Sets an object as the default object. Unless another object name is declared, all properties and methods refer to the default object until the End With statement is reached. +
+ + +With statement diagram + + With object + [statements] + End With + + +Use With and End With if you have several properties or methods for a single object or an extended data type definition. +Nesting With statements helps writing and reading Basic routines. + +
+ Type Statement +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090412.xhp b/helpcontent2/source/text/sbasic/shared/03090412.xhp new file mode 100644 index 000000000..adad55212 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090412.xhp @@ -0,0 +1,87 @@ + + + + + + + Exit Statement + /text/sbasic/shared/03090412.xhp + + + + + + +
+ + Exit statement + + + +

Exit Statement

+Exits a Do...Loop, For...Next, a function, a property, or a subroutine. +
+ + + +Exit Do, Exit For, Exit Function, Exit Property, Exit Sub + + + + Exit Do +Only valid within a Do...Loop statement to exit the loop. Program execution continues with the statement that follows the Loop statement. If Do...Loop statements are nested, the control is transferred to the loop in the next higher level. + Exit For +Only valid within a For...Next loop to exit the loop. Program execution continues with the first statement that follows the Next statement. In nested statements, the control is transferred to the loop in the next higher level. + Exit Function +Exits the Function procedure immediately. Program execution continues with the statement that follows the Function call. + Exit Property +Exits the Property procedure immediately. Program execution continues with the statement that follows the Property call. + Exit Sub +Exits the subroutine immediately. Program execution continues with the statement that follows the Sub call. +The Exit statement does not define the end of a structure, and must not be confused with the End statement. + + + +Sub ExampleExit +Dim sReturn As String +Dim sListArray(10) As String +Dim siStep As Single + For siStep = 0 To 10 ' Fill array with test data + sListArray(siStep) = chr(siStep + 65) + MsgBox sListArray(siStep) + Next siStep + sReturn = LinSearch(sListArray(), "B") + Print sReturn +End Sub + +Function LinSearch( sList(), sItem As String ) As Integer +Dim iCount As Integer +' LinSearch searches a TextArray:sList() for a TextEntry: +' Returns the index of the entry or 0 (Null) + For iCount=1 To Ubound( sList() ) + If sList( iCount ) = sItem Then + Exit For ' sItem found + End If + Next iCount + If iCount = Ubound( sList() ) Then iCount = 0 + LinSearch = iCount +End Function + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03090413.xhp b/helpcontent2/source/text/sbasic/shared/03090413.xhp new file mode 100644 index 000000000..38c6709ae --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03090413.xhp @@ -0,0 +1,69 @@ + + + + + + + Type Statement + /text/sbasic/shared/03090413.xhp + + + + +
+ + Type statement + +

Type Statement

+ Define non-UNO data structures. +
+ A Type structure is an ordered collection of data fields, that can be manipulated as a single item. + + Type statement diagram + + Type struct_name + DataField1 As TypeName1 + DataField2 As TypeName2 + (...) + End Type ' struct_name + + + + Extended types such as Type statement structures, UNO objects or ClassModule objects are valid typenames. + + A Type structure scope is that of the module it belongs to. + + + Type Customer + Name1 As String + City As String + End Type ' Customer structure + Sub setCustomer + Dim oCustomer as New Customer + oCustomer.Name1 = "The Document Foundation" + oCustomer.City = "Berlin" + End Sub + + Enumerations can be created using Type statement definitions. Calling Python Scripts from Basic illustrates that mechanism. +
+ + CreateObject function +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03100000.xhp b/helpcontent2/source/text/sbasic/shared/03100000.xhp new file mode 100644 index 000000000..1c06b40e8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100000.xhp @@ -0,0 +1,91 @@ + + + + + + + + +Variables +/text/sbasic/shared/03100000.xhp + + +Sun Microsystems, Inc. + + + +
+Variables +The following statements and functions are for working with variables. You can use these functions to declare or define variables, convert variables from one type to another, or determine the variable type. +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03100050.xhp b/helpcontent2/source/text/sbasic/shared/03100050.xhp new file mode 100644 index 000000000..37bb4d404 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100050.xhp @@ -0,0 +1,77 @@ + + + + + + + +CCur Function +/text/sbasic/shared/03100050.xhp + + +CCur + + + +
+CCur function + +

CCur Function

+Converts a string expression or numeric expression to a currency expression. The locale settings are used for decimal separators and currency symbols. +
+ + +CCur(Expression As Variant) As Currency + + +Currency + + +Expression: Any string or a numeric expression that you want to convert to a number.
CCur(EMPTY) returns 0.
+ + + + + + + + Sub CCur_example + Print CCur( expression := 145.279 * "654" ) + Print CCur( -258.0421E+02 ) + End Sub + + +
+ + + +
+ + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03100060.xhp b/helpcontent2/source/text/sbasic/shared/03100060.xhp new file mode 100644 index 000000000..f25a39b2a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100060.xhp @@ -0,0 +1,48 @@ + + + + + + + +CDec Function +/text/sbasic/shared/03100060.xhp + + +CDec + + + +
+CDec function + +CDec Function +Converts a string expression or numeric expression to a decimal expression. +
+Syntax: + +CDec(Expression) + +Return value: +Decimal number. +Parameter: +Expression: Any string or numeric expression that you want to convert. + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03100070.xhp b/helpcontent2/source/text/sbasic/shared/03100070.xhp new file mode 100644 index 000000000..840a6eb66 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100070.xhp @@ -0,0 +1,48 @@ + + + + + + + +CVar Function +/text/sbasic/shared/03100070.xhp + + +CVar + + + +
+CVar function + +CVar Function +Converts a string expression or numeric expression to a variant expression. +
+Syntax: + +CVar(Expression) + +Return value: +Variant. +Parameter: +Expression: Any string or numeric expression that you want to convert. + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03100080.xhp b/helpcontent2/source/text/sbasic/shared/03100080.xhp new file mode 100644 index 000000000..3107ba049 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100080.xhp @@ -0,0 +1,50 @@ + + + + + + + + CVErr Function + /text/sbasic/shared/03100080.xhp + + + CVErr + + + +
+ CVErr function + +

CVErr Function

+ Converts a string expression or numeric expression to a variant expression of the sub type "Error". +
+

Syntax:

+ + CVErr(Expression) + +

Return value:

+ Variant. +

Parameter:

+ Expression: Any string or numeric expression that you want to convert. +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03100100.xhp b/helpcontent2/source/text/sbasic/shared/03100100.xhp new file mode 100644 index 000000000..66dd198cf --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100100.xhp @@ -0,0 +1,88 @@ + + + + + + + CBool Function + /text/sbasic/shared/03100100.xhp + + + + + +
+ + CBool function + + +

CBool Function

+Converts an expression or a set of expressions into a boolean. An expression is composed of strings, numbers and operators. Comparison, logical or mathematical operators are allowed inside expressions. +
+ + + + CBool (expression As Variant) As Boolean + +expression can be a number or a set of combined expressions. + + +Boolean + + +expression: A logical expression, a mathematical formula, a numeric expression or a set of expressions combined with operators. During expression evaluation logical operators take preceedence over comparison operators, which in turn take preceedence over mathematical operators. +The expression can be a number or mathematical formula. When equals to 0, False is returned, otherwise True is returned. +Multiple expressions such as expr1 [[{operator] expr2]..] can be combined. expr1 and expr2 can be any string or numeric expressions that you want to evaluate. CBool combines the expressions and returns either True or False. operator can be a mathematical operator, logical operator or comparison operator. + + + + + +In the following examples, the CBool function evaluates a logical expression, a mathematical formula and the value that is returned by the Instr function. The function checks if the character "a" is found in the sentence that was entered by the user. + +Sub ExampleCBool + Print CBool( 1>2 Xor 44 ) ' computes to True + Print CBool( expression := 15 /2 -7.5 ) ' displays False as expression equals 0 + txt = InputBox("Please enter a short sentence:") + ' Proof if the character "a" appears in the sentence. + ' Instead of the command line + ' If Instr(Input, "a")<>0 Then... + ' the CBool function is applied as follows: + If CBool(Instr(txt, "a")) Then + MsgBox "The character »a« appears in the sentence you entered!" + EndIf +End Sub + + +
+ + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03100300.xhp b/helpcontent2/source/text/sbasic/shared/03100300.xhp new file mode 100644 index 000000000..adabbdc0b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100300.xhp @@ -0,0 +1,62 @@ + + + + + + + CDate Function + /text/sbasic/shared/03100300.xhp + + + + + +
+ + CDate function + +CDate Function +Converts any string or numeric expression to a date value. +
+ + + +CDate (Expression) + + +Return value: +Date + + + Expression: Any string or numeric expression that you want to convert. +
+ When you convert a string expression, the date and time must be entered either in one of the date acceptance patterns defined for your locale setting (see %PRODUCTNAME - PreferencesTools - Options - Language Settings - Languages) or in ISO date format (momentarily, only the ISO format with hyphens, e.g. "2012-12-31" is accepted). In numeric expressions, values to the left of the decimal represent the date, beginning from December 31, 1899. Values to the right of the decimal represent the time. +
+ + + + + Sub ExampleCDate + MsgBox cDate(1000.25) ' 09.26.1902 06:00:00 + MsgBox cDate(1001.26) ' 09.27.1902 06:14:24 + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03100400.xhp b/helpcontent2/source/text/sbasic/shared/03100400.xhp new file mode 100644 index 000000000..9546166c6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100400.xhp @@ -0,0 +1,56 @@ + + + + + + + CDbl Function + /text/sbasic/shared/03100400.xhp + + + + + +
+ + CDbl function + + +

CDbl Function

+Converts any numerical expression or string expression to a double type. +
+ + + +CDbl (Expression As Variant) As Double + + + +Double + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03100500.xhp b/helpcontent2/source/text/sbasic/shared/03100500.xhp new file mode 100644 index 000000000..9dda18512 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100500.xhp @@ -0,0 +1,71 @@ + + + + + + + CInt Function + /text/sbasic/shared/03100500.xhp + + + + + +
+ + CInt function + + +

CInt Function

+Converts any string or numeric expression to an integer. +
+ + + +CInt (Expression As Variant) As Integer + + + +Integer + + + +If the argument is string, the function trims the leading white space; then it tries to recognize a number in following characters. The syntax below are recognized: + + + Decimal numbers (with optional leading sign) using decimal and group separators of locale configured in $[officename] (group separators are accepted in any position), with optional exponential notation like "-12e+1" (where an optionally signed whole decimal number after e or E or d or D defines power of 10); + + + Octal numbers like "&Onnn...", where "nnn..." after "&O" or "&o" is sequence no longer than 11 digits, from 0 to 7, up to the next non-alphanumeric character; + + + Hexadecimal numbers like "&Hnnn...", where "nnn..." after "&H" or "&h" is sequence of characters up to the next non-alphanumeric character, and must be no longer than 8 digits, from 0 to 9, A to F, or a to f. + + +The rest of the string is ignored. If the string is not recognized, e.g. when after trimming leading whitespace it doesn't start with plus, minus, a decimal digit, or "&", or when the sequence after "&O" is longer than 11 characters or contains an alphabetic character, the numeric value of expression is 0. +If the argument is an error, the error number is used as numeric value of the expression. +If the argument is a date, number of days since 1899-12-30 (serial date) is used as numeric value of the expression. Time is represented as fraction of a day. +After calculating the numeric value of the expression, it is rounded to the nearest integer (if needed), and if the result is not between -32768 and 32767, $[officename] Basic reports an overflow error. Otherwise, the result is returned. + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03100600.xhp b/helpcontent2/source/text/sbasic/shared/03100600.xhp new file mode 100644 index 000000000..a8743a0b8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100600.xhp @@ -0,0 +1,58 @@ + + + + + + + CLng Function + /text/sbasic/shared/03100600.xhp + + + + + +
+ + CLng function + + +

CLng Function

+Converts any string or numeric expression to a long integer. +
+ + + +CLng (Expression As Variant) As Long + + + +Long + + + +If Expression lies outside the valid long integer range between -2.147.483.648 and 2.147.483.647, $[officename] Basic returns an overflow error. +This function always rounds the fractional part of a number to the nearest integer. + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03100700.xhp b/helpcontent2/source/text/sbasic/shared/03100700.xhp new file mode 100644 index 000000000..14d00c83b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100700.xhp @@ -0,0 +1,75 @@ + + + + + + + Const Statement + /text/sbasic/shared/03100700.xhp + + + + + +
+ + Const statement + + +Const Statement +Defines one or more identifiers as constants. +
+A constant is a variable that helps to improve the readability of a program. Constants are not defined as a specific type of variable, but rather are used as placeholders in the code. You can only define a constant once and it cannot be modified. + + + + Const syntax + + +[Global|Private|Public] Const name = expression[, ...] + + + + name: Any identifier that follows the standard variable naming conventions. +expression: Any literal expression. +The data type must be omitted. When a library gets loaded in memory, %PRODUCTNAME Basic converts the program code internally so that each time a constant is used, the defined expression replaces it. +

Scope

+By default constants are defined as private in modules and routines. Constants can be made public or global in order to be used from all modules, from all Basic libraries. +Global, Private and Public specifiers can only be used for module constants. + + + Const EARTH = "♁" ' module scope + Private Const MOON = "☾" ' module scope + Public Const VENUS="♀", MARS="♂" ' general scope + Global Const SUN = "☉", STAR = "☆" ' general scope + + Sub ExampleConst + Const SUN = 3 * 1.456 / 56 ' SUN is local + MsgBox SUN,, MOON ' SUN global constant is unchanged + Const Pgm = "Program", Var = 1.00 + MsgBox Pgm & " " & Var, , VENUS &" and "& MARS + End Sub + +
+ Enum statement + Type statement +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03100900.xhp b/helpcontent2/source/text/sbasic/shared/03100900.xhp new file mode 100644 index 000000000..649768f0e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03100900.xhp @@ -0,0 +1,73 @@ + + + + + + + CSng Function + /text/sbasic/shared/03100900.xhp + + + + + +
+ + CSng function + + +

CSng Function

+Converts any string or numeric expression to data type Single. +
+ + + +CSng (Expression As Variant) As Single + + + +Single + + +
+ Expression: Any string or numeric expression that you want to convert. To convert a string expression, the number must be entered using a dot "." as the decimal point and a comma "," as the thousands separator (for instance 123,456.78), which may differ from your %PRODUCTNAME language settings. +
+ + + + +
+Numeric expressions are displayed according %PRODUCTNAME language settings: + +Sub ExampleCountryConvert + MsgBox CDbl(1234.5678) ' 1234.5678 + MsgBox CInt(1234.5678) ' 1235 + MsgBox CLng(1234+5678) ' 6912 + MsgBox CSng(1234.5678) ' 1234.567749023 + + MsgBox CDbl(expression := 5678.1234) ' 5678.1234 + MsgBox CInt(expression := 5678.1234) ' 5678 + MsgBox CLng(expression := 5678+1234) ' 6912 + MsgBox CSng(expression := 5678.1234) ' 5678.123535156 +End Sub + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03101000.xhp b/helpcontent2/source/text/sbasic/shared/03101000.xhp new file mode 100644 index 000000000..f9745a463 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101000.xhp @@ -0,0 +1,115 @@ + + + + + + + CStr Function + /text/sbasic/shared/03101000.xhp + + + + + + +
+ + CStr function + + + +CStr Function +Converts any numeric expression to a string expression. +
+ +Syntax: + +CStr (Expression) + + +Return value: +String + +Parameters: + Expression: Any valid string or numeric expression that you want to convert. + +Expression Types and Conversion Returns + + + + + Boolean : + + + String that evaluates to either True or False. + + + + + Date : + + + String that contains the date and time. + + + + + Null : + + + Run-time error. + + + + + Empty : + + + String without any characters. + + + + + Any : + + + Corresponding number as string. + + +
+ +Zeros at the end of a floating-point number are not included in the returned string. + + + +Example: + +Sub ExampleCSTR +Dim sVar As String + MsgBox CDbl(1234.5678) + MsgBox CInt(1234.5678) + MsgBox CLng(1234.5678) + MsgBox CSng(1234.5678) + sVar = CStr(1234.5678) + MsgBox sVar +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03101100.xhp b/helpcontent2/source/text/sbasic/shared/03101100.xhp new file mode 100644 index 000000000..811494ccb --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101100.xhp @@ -0,0 +1,79 @@ + + + + + + + DefBool Statement + /text/sbasic/shared/03101100.xhp + + + + + +
+ + DefBool statement + + +

DefBool Statement

+If no type-declaration character or keyword is specified, the DefBool statement sets the default data type for variables, according to a letter range. +
+ +
+ + + DefType statements diagram + + + {DefBool|DefCur|DefDate|DefDbl|DefErr|DefInt|DefLng|DefObj|DefStr|DefSng|DefVar} {char|char-char}[,...] + + + + + char: Letter prefix that specifies default data type for variables. + char-char: Letter range prefixes that specify default data type for variables. +
+ +
+ + + ' Prefix definitions for variable types: + DefBool b + DefCur c,l-m + DefDate t + DefDbl f + DefErr e + DefInt i-k,N + DefLng x-z, D + DefObj U, o-R + DefSng w,a + DefStr s + DefVar V,g + +
+ + Sub ExampleDefBool + Print TypeName(Boole), VarType(Babbage), bitcoin ' Displays: Boolean 11 False + bOK=True ' bOK is an implicit boolean variable + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101110.xhp b/helpcontent2/source/text/sbasic/shared/03101110.xhp new file mode 100644 index 000000000..f9774f48c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101110.xhp @@ -0,0 +1,50 @@ + + + + + + + +DefCur Statement +/text/sbasic/shared/03101110.xhp + + +DefCur + + + +
+DefCur statement + +DefCur Statement +If no type-declaration character or keyword is specified, the DefCur statement sets the default variable type, according to a letter range. +
+ + + + + + Sub ExampleDefCur + Print liquid, Typename(coinbit), VarType(money) ' Result is: 0.0000 Currency 6 + cCur=Currency ' cCur is an implicit currency variable. + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101120.xhp b/helpcontent2/source/text/sbasic/shared/03101120.xhp new file mode 100644 index 000000000..35c1cbba7 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101120.xhp @@ -0,0 +1,50 @@ + + + + + + + DefErr Statement + /text/sbasic/shared/03101120.xhp + + + + + +
+ + DefErr statement + + +

DefErr Statement

+If no type-declaration character or keyword is specified, the DefErr statement sets the default variable type, according to a letter range. +
+ + + + + +DefErr e +Sub ExampleDefErr + eErr=Error ' eErr is an implicit error variable +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101130.xhp b/helpcontent2/source/text/sbasic/shared/03101130.xhp new file mode 100644 index 000000000..7fbd6cc98 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101130.xhp @@ -0,0 +1,50 @@ + + + + + + + DefSng Statement + /text/sbasic/shared/03101130.xhp + + + + + +
+ + DefSng statement + + +

DefSng Statement

+If no type-declaration character or keyword is specified, the DefSng statement sets the default variable type, according to a letter range. +
+ + + + + + Sub ExampleDefSng + wSng=Single ' wSng is an implicit single variable + Print afloat, Typename(Word), VarType(anyNum) ' Result is : 0 single 4 + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101140.xhp b/helpcontent2/source/text/sbasic/shared/03101140.xhp new file mode 100644 index 000000000..22be17bbe --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101140.xhp @@ -0,0 +1,51 @@ + + + + + + + DefStr Statement + /text/sbasic/shared/03101140.xhp + + + + + +
+ + DefStr statement + + +

DefStr Statement

+If no type-declaration character or keyword is specified, the DefStr statement sets the default variable type, according to a letter range. +
+ + + + + + + Sub ExampleDefStr + sStr=String ' sStr is an implicit string variable + Print VarType(slice), strng, TypeName(sheet) ' Result is: 8 "" String + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101300.xhp b/helpcontent2/source/text/sbasic/shared/03101300.xhp new file mode 100644 index 000000000..6c84e6563 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101300.xhp @@ -0,0 +1,50 @@ + + + + + + + DefDate Statement + /text/sbasic/shared/03101300.xhp + + + + + +
+ + DefDate statement + + +

DefDate Statement

+If no type-declaration character or keyword is specified, the DefDate statement sets the default variable type, according to a letter range. +
+ + + + + + Sub ExampleDefDate + tDate=Date ' tDate is an implicit date variable + Print VarType(tea), train, TypeName(timedate), IsDate(tick) ' Displays: 7 00:00:00 Date True + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101400.xhp b/helpcontent2/source/text/sbasic/shared/03101400.xhp new file mode 100644 index 000000000..ee96efa7a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101400.xhp @@ -0,0 +1,50 @@ + + + + + + + DefDbl Statement + /text/sbasic/shared/03101400.xhp + + + + + +
+ + DefDbl statement + + +

DefDbl Statement

+Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. +
+ + + + + + Sub ExampleDefDBL + fValue=1.23e43 ' fValue is an implicit double variable type + Print Typename(float), VarType(fire), factory ' Result is: Double 5 0 + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101500.xhp b/helpcontent2/source/text/sbasic/shared/03101500.xhp new file mode 100644 index 000000000..2a371295b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101500.xhp @@ -0,0 +1,50 @@ + + + + + + + DefInt Statement + /text/sbasic/shared/03101500.xhp + + + + + +
+ + DefInt statement + + +

DefInt Statement

+Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. +
+ + + + + + Sub ExampleDefInt + iCount=200 ' iCount is an implicit integer variable + Print kilos, Typename(number), VarType(Java) ' Result is: 0 Integer 2 + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101600.xhp b/helpcontent2/source/text/sbasic/shared/03101600.xhp new file mode 100644 index 000000000..f872bcdf0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101600.xhp @@ -0,0 +1,50 @@ + + + + + + + DefLng Statement + /text/sbasic/shared/03101600.xhp + + + + + +
+ + DefLng statement + + +

DefLng Statement

+Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. +
+ + + + + + Sub ExampleDefLng + xCount=123456789 ' xCount is an implicit long integer variable + Print VarType(Yes), zinc, Typename(Max) ' Result is: 3 0 Long + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03101700.xhp b/helpcontent2/source/text/sbasic/shared/03101700.xhp new file mode 100644 index 000000000..db099499c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03101700.xhp @@ -0,0 +1,49 @@ + + + + + + + +DefObj Statement +/text/sbasic/shared/03101700.xhp + + +Sun Microsystems, Inc. + + + +
+DefObj statement + +

DefObj Statement

+Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. +
+ + + + + + Sub DefObj_example + Print Typename(properties), VarType(ordinal), IsNull(unique), IsObject(org)' Result is: Object 9 True False + End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03102000.xhp b/helpcontent2/source/text/sbasic/shared/03102000.xhp new file mode 100644 index 000000000..2e7a31252 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102000.xhp @@ -0,0 +1,51 @@ + + + + + + + DefVar Statement + /text/sbasic/shared/03102000.xhp + + + + + +
+ + DefVar statement + + +

DefVar Statement

+Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. +
+ + + + + + Sub ExampleDefVar + vDiv=99 ' vDiv is an implicit variant + values="Hello world" + Print Typename(glob), VarType(values), IsEmpty(vOffer) ' Displays: Empty 8 True + End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03102100.xhp b/helpcontent2/source/text/sbasic/shared/03102100.xhp new file mode 100644 index 000000000..b66acc580 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102100.xhp @@ -0,0 +1,163 @@ + + + + + + + Dim Statement + /text/sbasic/shared/03102100.xhp + + + + + +
+ + Dim statement + arrays; dimensioning + dimensioning arrays + + +

Dim Statement

+Declares variables or arrays. +
+ +If the variables are separated by commas - for example Dim v1, v2, v3 As String - first ones get defined as Variant variables. A new line, or colon sign (:), help separate variable definitions. + + Dim text As String + Dim pv As com.sun.star.beans.PropertyValue, d As Date + Dim Units as Integer : Dim EULER As Double + +Dim declares local variables within subroutines. Global variables are declared with the Global, Public or the Private statement. + + + + Dim Statement diagram + + +Dim variable [(start To end)] [As typename][, variable2[char] [(start To end)] [,...]] + +
+New operator is optional when setting Option Compatible option. +
+ +
+ + variable: Any variable or array name. + + typename: Keyword that declares the data type of a variable. + + primitive data types fragment + + Byte: Byte variable (0-255) + Boolean: Boolean variable (True, False) + Currency: Currency variable (Currency with 4 Decimal places) + Date: Date variable + Double: Double-precision floating-point variable (1,79769313486232 x 10E308 - 4,94065645841247 x 10E-324) + Integer: Integer variable (-32768 - 32767) + Long: Long integer variable (-2.147.483.648 - 2.147.483.647) + Object: Object variable (Note: this variable can only subsequently be defined with Set!) + Single: Single-precision floating-point variable (3,402823 x 10E38 - 1,401298 x 10E-45). + String: String variable consisting of a maximum of 64,000 ASCII characters. + Variant: Variant variable type (contains all types, specified by definition). If a type name is not specified, variables are automatically defined as Variant Type, unless a statement from DefBool to DefVar is used. + object: Universal Network object (UNO) object or ClassModule object instance. +char: Special character that declares the data type of a variable. + Type declaration characters fragment + +In %PRODUCTNAME Basic, you do not need to declare variables explicitly. However, you need to declare arrays before you can use them. You can declare a variable with the Dim statement, using commas (,) to separate multiple declarations. To declare a variable type, enter a type-declaration character following the name or use a corresponding type keyword name. + + + Declaration character + Variable type name + + + % + Integer + + + & + Long + + + ! + Single + + + # + Double + + + $ + String + + + @ + Currency + +
+ + array: Array declaration. + + array fragment + + start, end: Numerical values or constants that define the number of elements (NumberElements=(end-start)+1) and the index range.see #i36558 + start and end can be numerical expressions if ReDim is applied at the procedure level. +$[officename] Basic supports single or multi-dimensional arrays that are defined by a specified variable type. Arrays are suitable if the program contains lists or tables that you want to edit. The advantage of arrays is that it is possible to address individual elements according to indexes, which can be formulated as numeric expressions or variables. + Arrays are declared with the Dim statement. There are multiple ways to define the index range: + + Dim text(20) As String ' 21 elements numbered from 0 to 20 + Dim value(5 to 25) As Integer ' 21 values numbered from 5 to 25 + Dim amount(-15 to 5) As Currency ' 21 amounts (including 0), numbered from -15 to 5 + REM Two-dimensional data field + Dim table$(20,2) ' 63 items; from 0 to 20 level 1, from 0 to 20 level 2 and from 0 to 20 level 3. + + +You can declare an array types as dynamic if a ReDim statement defines the number of dimensions in the subroutine or the function that contains the array. Generally, you can only define an array dimension once, and you cannot modify it. Within a subroutine, you can declare an array with ReDim. You can only define dimensions with numeric expressions. This ensures that the fields are only as large as necessary. +
+ + + +Sub ExampleDim1 +Dim sVar As String +Dim iVar As Integer + sVar = "Office" +End Sub + +Sub ExampleDim2 + ' Two-dimensional data field + Dim stext(20,2) As String + Const sDim As String = " Dimension:" + For i = 0 To 20 + For ii = 0 To 2 + stext(i,ii) = str(i) & sDim & str(ii) + Next ii + Next i + For i = 0 To 20 + For ii = 0 To 2 + MsgBox stext(i,ii) + Next ii + Next i +End Sub + + +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03102101.xhp b/helpcontent2/source/text/sbasic/shared/03102101.xhp new file mode 100644 index 000000000..8c71168a4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102101.xhp @@ -0,0 +1,67 @@ + + + + + + + ReDim Statement + /text/sbasic/shared/03102101.xhp + + + + + + +
+ + ReDim statement + + +

ReDim Statement

+Declares or redefines variables or arrays. +
+ + + + ReDim Statement diagram + + +ReDim [Preserve] variable [(start To end)] [As type-name][, variable2 [(start To end)] [As type-name][,...]] + +Optionally, add the Preserve keyword to preserve the contents of the array that is redimensioned. ReDim can only be used in subroutines. + + + +Example: + +Sub ExampleRedim + Dim iVar() As Integer, iCount As Byte + ReDim iVar(5) As Integer + For iCount = 1 To 5 + iVar(iCount) = iCount + Next iCount + ReDim iVar(10) As Integer + For iCount = 1 To 10 + iVar(iCount) = iCount + Next iCount +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03102200.xhp b/helpcontent2/source/text/sbasic/shared/03102200.xhp new file mode 100644 index 000000000..431fee1c8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102200.xhp @@ -0,0 +1,63 @@ + + + + + + + IsArray Function + /text/sbasic/shared/03102200.xhp + + + + + + +
+ + IsArray function + + + +IsArray Function +Determines if a variable is a data field in an array. +
+ +Syntax: + +IsArray (Var) + + +Return value: +Boolean + +Parameters: + Var: Any variable that you want to test if it is declared as an array. If the variable is an array, then the function returns True, otherwise False is returned. + + + +Example: + +Sub ExampleIsArray +Dim sDatf(10) As String + Print isarray(sdatf()) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03102300.xhp b/helpcontent2/source/text/sbasic/shared/03102300.xhp new file mode 100644 index 000000000..41976a79f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102300.xhp @@ -0,0 +1,66 @@ + + + + + + + IsDate Function + /text/sbasic/shared/03102300.xhp + + + + + + +
+ + IsDate function + + + +IsDate Function +Tests if a numeric or string expression can be converted to a Date variable. +
+ +Syntax: + +IsDate (Expression) + + +Return value: +Boolean + +Parameters: + Expression: Any numeric or string expression that you want to test. If the expression can be converted to a date, the function returns True, otherwise the function returns False. + + + +Example: + +Sub ExampleIsDate +Dim sDateVar As String + sDateVar = "12.12.1997" + Print IsDate(sDateVar) ' True + sDateVar = "12121997" + Print IsDate(sDateVar) ' False +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03102400.xhp b/helpcontent2/source/text/sbasic/shared/03102400.xhp new file mode 100644 index 000000000..7343efb89 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102400.xhp @@ -0,0 +1,64 @@ + + + + + + + IsEmpty Function + /text/sbasic/shared/03102400.xhp + + + + + + +
+ + IsEmpty function + + + +IsEmpty Function +Tests if a Variant variable contains the Empty value. The Empty value indicates that the variable is not initialized. +
+ +Syntax: + +IsEmpty (Var) + + +Return value: +Boolean + +Parameters: + Var: Any variable that you want to test. If the Variant contains the Empty value, the function returns True, otherwise the function returns False. + + + +Example: + +Sub ExampleIsEmpty +Dim sVar As Variant + sVar = Empty + Print IsEmpty(sVar) ' True +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03102450.xhp b/helpcontent2/source/text/sbasic/shared/03102450.xhp new file mode 100644 index 000000000..c08464407 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102450.xhp @@ -0,0 +1,50 @@ + + + + + + + + IsError Function + /text/sbasic/shared/03102450.xhp + + + IsError + + + +
+ IsError function + +

IsError Function

+ Tests if a variable contains an error value. +
+

Syntax:

+ + IsError (Var) + +

Return value:

+ Bool +

Parameters:

+ Var: Any variable that you want to test. If the variable contains an error value, the function returns True, otherwise the function returns False. +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03102600.xhp b/helpcontent2/source/text/sbasic/shared/03102600.xhp new file mode 100644 index 000000000..cbad0b2b3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102600.xhp @@ -0,0 +1,65 @@ + + + + + + + IsNull Function + /text/sbasic/shared/03102600.xhp + + + + + + +
+ + IsNull function + Null value + + + +IsNull Function +Tests if a Variant contains the special Null value, indicating that the variable does not contain data. +
+ +Syntax: + +IsNull (Var) + + +Return value: +Boolean + +Parameters: + Var: Any variable that you want to test. This function returns True if the Variant contains the Null value, or False if the Variant does not contain the Null value. + Null - This value is used for a variant data sub type without valid contents. + + + +Example: + +Sub ExampleIsNull +Dim vVar As Variant + MsgBox IsNull(vVar) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03102700.xhp b/helpcontent2/source/text/sbasic/shared/03102700.xhp new file mode 100644 index 000000000..5a868f0fc --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102700.xhp @@ -0,0 +1,66 @@ + + + + + + + IsNumeric Function + /text/sbasic/shared/03102700.xhp + + + + + + +
+ + IsNumeric function + + + +IsNumeric Function +Tests if an expression is a number. If the expression is a number, the function returns True, otherwise the function returns False. +
+ +Syntax: + +IsNumeric (Var) + + +Return value: +Boolean + +Parameters: + Var: Any expression that you want to test. + + + +Example: + +Sub ExampleIsNumeric +Dim vVar As Variant + vVar = "ABC" + Print IsNumeric(vVar) ' False + vVar = "123" + Print IsNumeric(vVar) ' True +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03102800.xhp b/helpcontent2/source/text/sbasic/shared/03102800.xhp new file mode 100644 index 000000000..4655ee47f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102800.xhp @@ -0,0 +1,72 @@ + + + + + + + IsObject Function + /text/sbasic/shared/03102800.xhp + + + Sun Microsystems, Inc. + + + +
+ + IsObject function + +

IsObject Function

+ Tests if a variable is an object, as opposed to primitive data types such as dates, numbers, texts. The function returns True if the variable is an object, otherwise it returns False. +
+ This function returns True for the following object types: + + OLE objects or UNO objects + Class module object instances + Extended types or enumerations + Routines or variables when defined as Object. + %PRODUCTNAME Basic modules + + Data structures return True even when empty. Object defined variables return True even if uninitialized. + + + IsObject(var) + + + Boolean + + + var: The variable to be tested. + + + +
+ + Enum statement + + + + + + + Type statement + Using variables +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03102900.xhp b/helpcontent2/source/text/sbasic/shared/03102900.xhp new file mode 100644 index 000000000..cd12c7460 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03102900.xhp @@ -0,0 +1,70 @@ + + + + + + + LBound Function + /text/sbasic/shared/03102900.xhp + + + + + +
+ + LBound function + + +

LBound Function

+Returns the lower boundary of an array. +
+ + + +LBound (ArrayName [, Dimension]) + + + +Long + + + ArrayName: Name of the array for which you want to return the upper (Ubound) or the lower (LBound) boundary of the array dimension. + [Dimension]: Integer that specifies which dimension to return the upper (Ubound) or the lower (LBound) boundary for. If a value is not specified, the first dimension is assumed. + + + + + + +Sub VectorBounds + Dim v(10 To 20) As String + Print LBound(v()) ' returns 10 + Print UBound(v) ' returns 20 +End Sub ' VectorBounds + +Sub TableBounds + Dim t(10 To 20,-5 To 70) As Currency + Print LBound(t), UBound(t()) ' returns 10 20 + Print LBound(t(),2) ' returns - 5 + Print UBound(t,2) ' returns 70 +End Sub ' TableBounds + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03103000.xhp b/helpcontent2/source/text/sbasic/shared/03103000.xhp new file mode 100644 index 000000000..f87474f46 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103000.xhp @@ -0,0 +1,73 @@ + + + + + + + UBound Function + /text/sbasic/shared/03103000.xhp + + + + + + +
+ + UBound function + + + +

UBound Function

+Returns the upper boundary of an array. +
+ + + +UBound (ArrayName [, Dimension]) + + + +Long + + + ArrayName: Name of the array for which you want to determine the upper (Ubound) or the lower (LBound) boundary. + [Dimension]: Integer that specifies which dimension to return the upper(Ubound) or lower (LBound) boundary for. If no value is specified, the boundary of the first dimension is returned. + + + + + + +Sub VectorBounds + Dim v(10 To 20) As String + Print LBound(v()) ' 10 + Print UBound(v) ' 20 +End Sub + +Sub TableBounds + Dim t(10 To 20,-5 To 70) As Currency + Print LBound(t), UBound(t()) ' 10 20 + Print LBound(t(),2) ' -5 + Print UBound(t,2) ' 70 +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03103100.xhp b/helpcontent2/source/text/sbasic/shared/03103100.xhp new file mode 100644 index 000000000..a03f8e04d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103100.xhp @@ -0,0 +1,63 @@ + + + + + + + Let Statement + /text/sbasic/shared/03103100.xhp + + + + + + +
+ + Let statement + + + +Let Statement +Assigns a value to a variable. +
+ +Syntax: + + Let Statement diagram + + +[Let] variable = expression + + +Parameters: + variable: Variable that you want to assign a value to. Value and variable type must be compatible. +As in most BASIC dialects, the keyword Let is optional. + +Example: + +Sub ExampleLet +Dim sText As String + Let sText = "Las Vegas" + MsgBox Len(sText) ' returns 9 +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03103200.xhp b/helpcontent2/source/text/sbasic/shared/03103200.xhp new file mode 100644 index 000000000..d7418435a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103200.xhp @@ -0,0 +1,54 @@ + + + + + + + Option Base Statement + /text/sbasic/shared/03103200.xhp + + + + + +
+ + Option Base statement + + +

Option Base Statement

+Defines the default lower boundary for arrays as 0 or 1. +
+ + +Option Base { 0 | 1} + + +This statement must be added before the executable program code in a module. + + + +Option Base 1 +Sub ExampleOptionBase + Dim sVar(20) As String + MsgBox LBound(sVar()) +End Sub + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03103300.xhp b/helpcontent2/source/text/sbasic/shared/03103300.xhp new file mode 100644 index 000000000..96c490d39 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103300.xhp @@ -0,0 +1,57 @@ + + + + + + + Option Explicit Statement + /text/sbasic/shared/03103300.xhp + + + + + +
+ + Option Explicit statement + + +

Option Explicit Statement

+Specifies that every variable in the program code must be explicitly declared with the Dim statement. +
+ + +Option Explicit + + + + + + +Option Explicit +Sub ExampleExplicit +Dim sVar As String + sVar = "Las Vegas" + For i% = 1 To 10 ' This results in a run-time error + Rem + Next i% +End Sub + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03103350.xhp b/helpcontent2/source/text/sbasic/shared/03103350.xhp new file mode 100644 index 000000000..1a0b9c522 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103350.xhp @@ -0,0 +1,67 @@ + + + + + + + Option VBASupport Statement + /text/sbasic/shared/03103350.xhp + + + + +
+ + Microsoft Excel macros support;Enable + Microsoft Excel macros support;Option VBASupport statement + VBA Support;Option VBASupport statement + Option VBASupport statement + +

Option VBASupport Statement

+Specifies that %PRODUCTNAME Basic will support some VBA statements, functions and objects. +
+ +The support for VBA is not complete, but covers a large portion of the common usage patterns. +When VBA support is enabled, %PRODUCTNAME Basic function arguments and return values are the same as their VBA functions counterparts. When the support is disabled, %PRODUCTNAME Basic functions may accept arguments and return values different of their VBA counterparts. + +Option VBASupport {1|0} + + + +1: Enable VBA support in %PRODUCTNAME +0: Disable VBA support + + + +Option VBASupport 1 +Sub ExampleVBA + Dim sVar As Single + sVar = Worksheets("Sheet1").Range("A1") + Print sVar +End Sub + + +
+VBA Properties +VBA support in %PRODUCTNAME + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03103400.xhp b/helpcontent2/source/text/sbasic/shared/03103400.xhp new file mode 100644 index 000000000..b56fe0d94 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103400.xhp @@ -0,0 +1,56 @@ + + + + + + + Public Statement + /text/sbasic/shared/03103400.xhp + + + + + + +
+ + Public statement + + + +Public Statement +Dimensions a variable or an array at the module level (that is, not within a subroutine or function), so that the variable and the array are valid in all libraries and modules. +
+ +Syntax: + +Public VarName[(start To end)] [As VarType][, VarName2[(start To end)] [As VarType][,...]] + + +Example: + +Public iPublicVar As Integer +Sub ExamplePublic + iPublicVar = iPublicVar + 1 + MsgBox iPublicVar +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03103450.xhp b/helpcontent2/source/text/sbasic/shared/03103450.xhp new file mode 100644 index 000000000..b2c0e5144 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103450.xhp @@ -0,0 +1,56 @@ + + + + + + + Global Statement + /text/sbasic/shared/03103450.xhp + + + + + + +
+ + Global keyword + + + +Global keyword +Dimensions a variable or an array at the global level (that is, not within a subroutine or function), so that the variable and the array are valid in all libraries and modules for the current session. +
+ +Syntax: + +Global VarName[(start To end)] [As VarType][, VarName2[(start To end)] [As VarType][,...]] + + +Example: + +Global iGlobalVar As Integer +Sub ExampleGlobal + iGlobalVar = iGlobalVar + 1 + MsgBox iGlobalVar +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03103500.xhp b/helpcontent2/source/text/sbasic/shared/03103500.xhp new file mode 100644 index 000000000..52a0261bb --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103500.xhp @@ -0,0 +1,71 @@ + + + + + + + Static Statement + /text/sbasic/shared/03103500.xhp + + + + + + +
+ + Static statement + + + +Static Statement +Declares a variable or an array at the procedure level within a subroutine or a function, so that the values of the variable or the array are retained after exiting the subroutine or function. Dim statement conventions are also valid. +
+The Static statement cannot be used to define variable arrays. Arrays must be specified according to a fixed size. + +Syntax: + +Static VarName[(start To end)] [As VarType], VarName2[(start To end)] [As VarType], ... + + +Example: + +Sub ExampleStatic +Dim iCount As Integer, iResult As Integer + For iCount = 0 To 2 + iResult = InitVar() + Next iCount + MsgBox iResult,0,"The answer is" +End Sub + +' Function for initialization of the static variable +Function InitVar() As Integer + Static iInit As Integer + Const iMinimum As Integer = 40 ' minimum return value of this function + If iInit = 0 Then ' check if initialized + iInit = iMinimum + Else + iInit = iInit + 1 + End If + InitVar = iInit +End Function + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03103600.xhp b/helpcontent2/source/text/sbasic/shared/03103600.xhp new file mode 100644 index 000000000..6f4d3e345 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103600.xhp @@ -0,0 +1,275 @@ + + + + + + + TypeName Function; VarType Function + /text/sbasic/shared/03103600.xhp + + + + +
+ +TypeName function +VarType function +Basic Variable Type constants + +

TypeName Function; VarType Function

+Returns a string (TypeName) or a numeric value (VarType) that contains information for a variable. +
+ + + +TypeName (Variable) / VarType (Variable) + + + +String; Integer + + + Variable: The variable that you want to determine the type of. You can use the following values: + +
+ + + + Keyword + + + Named constant + + + VarType + + + Variable type + + + + + Boolean + + + + + + 11 + + + Boolean variable + + + + Byte + + + + + + 17 + + + Byte variable + + + + + Date + + + V_DATE + + + 7 + + + Date variable + + + + + Currency + + + V_CURRENCY + + + 6 + + + Currency variable + + + + + Double + + + V_DOUBLE + + + 5 + + + Double floating point variable + + + + + Integer + + + V_INTEGER + + + 2 + + + Integer variable + + + + + Long + + + V_LONG + + + 3 + + + Long integer variable + + + + + Object + + + + + + 9 + + + Object variable + + + + + Single + + + V_SINGLE + + + 4 + + + Single floating-point variable + + + + + String + + + V_STRING + + + 8 + + + String variable + + + + + Variant + + + + + + 12 + + + Variant variable (can contain all types specified by the definition) + + + + + Empty + + + V_EMPTY + + + 0 + + + Variable is not initialized + + + + + Null + + + V_NULL + + + 1 + + + No valid data + + +
+
+ + + + + +Sub ExampleType +Dim iVar As Integer +Dim sVar As String +Dim siVar As Single +Dim dVar As Double +Dim bVar As Boolean +Dim lVar As Long +Dim cVar as Currency +Dim tVar as Date + MsgBox TypeName(iVar) & " " & VarType(iVar) & Chr(13) &_ + TypeName(sVar) & " " & VarType(sVar) & Chr(13) &_ + TypeName(siVar) & " " & VarType(siVar) & Chr(13) &_ + TypeName(dVar) & " " & VarType(dVar) & Chr(13) &_ + TypeName(bVar) & " " & VarType(bVar) & Chr(13) &_ + TypeName(cVar) & " " & VarType(cVar) & Chr(13) &_ + TypeName(tVar) & " " & VarType(tVar) & Chr(13) &_ + TypeName(lVar) & " " & VarType(lVar),0,"Some types In $[officename] Basic" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03103700.xhp b/helpcontent2/source/text/sbasic/shared/03103700.xhp new file mode 100644 index 000000000..45f6ce0e0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103700.xhp @@ -0,0 +1,75 @@ + + + + + + + Set Statement + /text/sbasic/shared/03103700.xhp + + + + + +
+ + Set statement + Nothing object + + + +

Set Statement

+Sets an object reference on a variable. +
+ + + + Set Statement diagram + + + [Set] variable = [New] object + + + + variable: a variable or a property that requires an object reference. + expression: A computable combination of terms such as a formula or an object property or method. + object: Object that the variable refers to. + Nothing - Assign Nothing to a variable to remove a previous assignment. +Set keyword is optional. Nothing is the default value for objects. + + +Sub ExampleSet + Dim obj As Object + Set obj = ThisComponent + Print obj.Title + + obj = New com.sun.star.beans.PropertyValue + With obj + .Name = "key" : .Value = 594.34 + Print .Name, .Value + End With +End Sub + +New creates UNO objects or class module objects, before assigning it to a variable. + +
+ +
+ +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03103800.xhp b/helpcontent2/source/text/sbasic/shared/03103800.xhp new file mode 100644 index 000000000..f77b77da8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103800.xhp @@ -0,0 +1,68 @@ + + + + + + + +FindObject Function +/text/sbasic/shared/03103800.xhp + + +Sun Microsystems, Inc. + + + +
+FindObject function + +FindObject Function +Enables an object to be addressed at run-time as a string parameter through the object name. +
+
+For example, the following command: + +MyObj.Prop1.Command = 5 + +corresponds to the command block: + +Dim ObjVar as Object +Dim ObjProp as Object +ObjName As String = "MyObj" +ObjVar = FindObject( ObjName As String ) +PropName As String = "Prop1" +ObjProp = FindPropertyObject( ObjVar, PropName As String ) +ObjProp.Command = 5 + +This allows names to be dynamically created at run-time. For example: +"TextEdit1" to "TextEdit5" in a loop to create five control names. +
+See also: FindPropertyObject +Syntax: + +FindObject( ObjName As String ) + +Parameters: + +ObjName: String that specifies the name of the object that you want to address at run-time. + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03103900.xhp b/helpcontent2/source/text/sbasic/shared/03103900.xhp new file mode 100644 index 000000000..75486f5bf --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03103900.xhp @@ -0,0 +1,56 @@ + + + + + + + +FindPropertyObject Function +/text/sbasic/shared/03103900.xhp + + +Sun Microsystems, Inc. + + + +
+FindPropertyObject function + +FindPropertyObject Function +Enables objects to be addressed at run-time as a string parameter using the object name. +
+ +See also: FindObject +Syntax: + +FindPropertyObject( ObjVar, PropName As String ) + +Parameters: + +ObjVar: Object variable that you want to dynamically define at run-time. + +PropName: String that specifies the name of the property that you want to address at run-time. + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03104000.xhp b/helpcontent2/source/text/sbasic/shared/03104000.xhp new file mode 100644 index 000000000..f12213c9f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03104000.xhp @@ -0,0 +1,52 @@ + + + + + + + +IsMissing function +/text/sbasic/shared/03104000.xhp + + +Sun Microsystems, Inc. + + + +
+IsMissing function + +IsMissing Function +Tests if a function is called with an optional parameter. +
+See also: Optional +Syntax: + +IsMissing( ArgumentName ) + +Parameters: + +ArgumentName: the name of an optional argument. +If the IsMissing function is called by the ArgumentName, then True is returned. +See also Examples. + + + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03104100.xhp b/helpcontent2/source/text/sbasic/shared/03104100.xhp new file mode 100644 index 000000000..26e9b2201 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03104100.xhp @@ -0,0 +1,50 @@ + + + + + + + +Optional (in Function Statement) +/text/sbasic/shared/03104100.xhp + + +Sun Microsystems, Inc. + + + +
+Optional function + +Optional (in Function Statement) +Allows you to define parameters that are passed to a function as optional. +
+See also: IsMissing +Syntax: + +Function MyFunction(Text1 As String, Optional Arg2, Optional Arg3) + +Examples: + + Result = MyFunction("Here", 1, "There") ' all arguments are passed. + Result = MyFunction("Test", ,1) ' second argument is missing. + +See also Examples. + +
diff --git a/helpcontent2/source/text/sbasic/shared/03104200.xhp b/helpcontent2/source/text/sbasic/shared/03104200.xhp new file mode 100644 index 000000000..1ee1a8fff --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03104200.xhp @@ -0,0 +1,58 @@ + + + + + + + Array Function + /text/sbasic/shared/03104200.xhp + + + Sun Microsystems, Inc. + + + +
+ + Array function + +

Array Function

+ Returns the type Variant with a data field. +
+ + + Array (ArgumentList) + + See also DimArray + + + ArgumentList: A list of any number of arguments that are separated by commas. + + + Dim A As Variant + A = Array("Fred","Tom","Bill") + Msgbox A(2) + + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03104300.xhp b/helpcontent2/source/text/sbasic/shared/03104300.xhp new file mode 100644 index 000000000..177c75d38 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03104300.xhp @@ -0,0 +1,54 @@ + + + + + + + +DimArray Function +/text/sbasic/shared/03104300.xhp + + +Sun Microsystems, Inc. + + + +
+DimArray function + +DimArray Function +Returns a Variant array. +
+Syntax: + +DimArray (ArgumentList) + +See also Array +If no parameters are passed, an empty array is created (like Dim A() that is the same as a sequence of length 0 in Uno). If parameters are specified, a dimension is created for each parameter. +Parameters: + +ArgumentList: A list of any number of arguments that are separated by commas. + + +Example: + + a = DimArray( 2, 2, 4 ) ' is the same as DIM a( 2, 2, 4 ) + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03104400.xhp b/helpcontent2/source/text/sbasic/shared/03104400.xhp new file mode 100644 index 000000000..541ce535b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03104400.xhp @@ -0,0 +1,53 @@ + + + + + + + +HasUnoInterfaces Function +/text/sbasic/shared/03104400.xhp + + +Sun Microsystems, Inc. + + + +
+HasUnoInterfaces function + +HasUnoInterfaces Function +Tests if a Basic Uno object supports certain Uno interfaces. +
+Returns True, if all stated Uno interfaces are supported, otherwise False is returned. + +HasUnoInterfaces( oTest, Uno-Interface-Name 1 [, Uno-Interface-Name 2, ...]) + +Bool + + +oTest: the Basic Uno object that you want to test. + +Uno-Interface-Name: list of Uno interface names. + + + bHas = HasUnoInterfaces( oTest, "com.sun.star.beans.XIntrospection" ) + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03104500.xhp b/helpcontent2/source/text/sbasic/shared/03104500.xhp new file mode 100644 index 000000000..49cd4588a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03104500.xhp @@ -0,0 +1,63 @@ + + + + + + + IsUnoStruct Function + /text/sbasic/shared/03104500.xhp + + + +
+ + IsUnoStruct function + +IsUnoStruct Function +Returns True if the given object is a Uno struct. +
+ + +IsUnoStruct( Uno type ) + +Boolean + + +Uno type : A UnoObject + + + +Sub Main +Dim bIsStruct +' Instantiate a service +Dim oSimpleFileAccess +oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" ) +bIsStruct = IsUnoStruct( oSimpleFileAccess ) +MsgBox bIsStruct ' Displays False because oSimpleFileAccess Is NO struct +' Instantiate a Property struct +Dim aProperty As New com.sun.star.beans.Property +bIsStruct = IsUnoStruct( aProperty ) +MsgBox bIsStruct ' Displays True because aProperty is a struct +bIsStruct = IsUnoStruct( 42 ) +MsgBox bIsStruct ' Displays False because 42 is NO struct +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03104600.xhp b/helpcontent2/source/text/sbasic/shared/03104600.xhp new file mode 100644 index 000000000..891421b50 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03104600.xhp @@ -0,0 +1,70 @@ + + + + + + + EqualUnoObjects Function + /text/sbasic/shared/03104600.xhp + + + Sun Microsystems, Inc. + + + + +
+ + EqualUnoObjects function + +

EqualUnoObjects Function

+ Returns True if the two specified Basic variables represent the same Uno object instance. +
+ + + EqualUnoObjects(oObj1, oObj2) + + + oObj1, oObj2: the variables to be tested. + + Bool + + The example below returns True because both oDoc and ThisComponent are references to the same object: + + Dim oDoc as Object + oDoc = ThisComponent + MsgBox EqualUnoObjects(oDoc, ThisComponent) ' True + + The example below returns False because the assignment creates a copy of the original object. Hence Struct1 and Struct2 refer to different object instances. + + Dim Struct1 as new com.sun.star.beans.PropertyValue + Dim Struct2 as Variant + Struct1.Name = "John" + Struct2 = Struct1 + MsgBox EqualUnoObjects(Struct1, Struct2) ' False + Struct2.Name = "Judy" + MsgBox Struct1.Name ' John + MsgBox Struct2.Name ' Judy + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03104700.xhp b/helpcontent2/source/text/sbasic/shared/03104700.xhp new file mode 100644 index 000000000..968cac313 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03104700.xhp @@ -0,0 +1,64 @@ + + + + + + + + Erase Statement + /text/sbasic/shared/03104700.xhp + + Erase + + + + +
+Erase statement + +Erase Statement +Erases the contents of array elements of fixed size arrays, and releases the memory used by arrays of variable size. +
+ + +Erase syntax + + Erase array1 [, array2 [,...]] + + + +array list - A comma delimited list of arrays to be erased. + + + + Sub Erase_Example + a = Array(1,2,3) : b= Array("z","y","x") : c=Array(a,b) + Erase a, c(Ubound(c)) ' b and c(0) are unchanged + Erase b, c(0) ' everything gets cleared + End Sub + + +
+ Dim or ReDim statements + Array or DimArray functions + Lbound and Ubound functions +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03110100.xhp b/helpcontent2/source/text/sbasic/shared/03110100.xhp new file mode 100644 index 000000000..801ba423a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03110100.xhp @@ -0,0 +1,85 @@ + + + + + + + Comparison Operators + /text/sbasic/shared/03110100.xhp + + + + + +
+ + comparison operators;%PRODUCTNAME Basic + Operators;comparison + Operators;equal sign (=) + Operators;greater than (>) + Operators;greater than or equal to (>=) + Operators;less than (<) + Operators;less than or equal to (<=) + Operators;not equal to (<>) + + +

Comparison Operators

+Comparison operators compare two expressions. The result is returned as a boolean expression that determines if the comparison is True (-1) or False (0). +
+ + + + result = expression1 { = | < | > | <= | >= } expression2 + + + + result: Boolean that specifies the result of the comparison (True, or False) + expression1, expression2: Any numeric values or strings that you want to compare. + +Comparison operators += : Equal to +< : Less than +> : Greater than +<= : Less than or equal to +>= : Greater than or equal to +<> : Not equal to + + + +Sub ExampleUnequal +Dim sFile As String +Dim sRoot As String ' Root directory for file in and output + sRoot = "c:\" + sFile = Dir$( sRoot ,22) + If sFile <> "" Then + Do + MsgBox sFile + sFile = Dir$ + Loop Until sFile = "" + End If +End Sub + + +
+ + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03120000.xhp b/helpcontent2/source/text/sbasic/shared/03120000.xhp new file mode 100644 index 000000000..8709a9a24 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120000.xhp @@ -0,0 +1,45 @@ + + + + + + + + +Strings +/text/sbasic/shared/03120000.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Strings + The following functions and statements validate and return strings. +
+ You can use strings to edit text within $[officename] Basic programs. + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120100.xhp b/helpcontent2/source/text/sbasic/shared/03120100.xhp new file mode 100644 index 000000000..dccf9aeb6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120100.xhp @@ -0,0 +1,45 @@ + + + + + + + + +ASCII/ANSI Conversion in Strings +/text/sbasic/shared/03120100.xhp + + +Sun Microsystems, Inc. + + + + + +
+ ASCII/ANSI Conversion in Strings + The following functions convert strings to and from ASCII or ANSI code. +
+ + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120101.xhp b/helpcontent2/source/text/sbasic/shared/03120101.xhp new file mode 100644 index 000000000..deb1b1baf --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120101.xhp @@ -0,0 +1,69 @@ + + + + + + + Asc Function + /text/sbasic/shared/03120101.xhp + + + + + +
+ + Asc function + + +

Asc Function (BASIC)

+Returns the ASCII (American Standard Code for Information Interchange) value of the first character in a string expression. +
+ + + +Asc(string) As Long + + + +Long + + +string: Any valid string expression. Only the first character in the string is relevant. +Use the Asc function to replace keys with values. If the Asc function encounters a blank string, $[officename] Basic reports a run-time error. In addition to 7 bit ASCII characters (Codes 0-127), the ASCII function can also detect non-printable key codes in ASCII code. This function can also handle 16 bit unicode characters. + + + + + +Sub ExampleASC + Print ASC("A") ' returns 65 + Print ASC(string:="Z") ' returns 90 + Print ASC("Las Vegas") ' returns 76, since only the first character is taken into account +End Sub + + +
+ + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120102.xhp b/helpcontent2/source/text/sbasic/shared/03120102.xhp new file mode 100644 index 000000000..e0329d570 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120102.xhp @@ -0,0 +1,74 @@ + + + + + + + Chr Function + /text/sbasic/shared/03120102.xhp + + + + +
+ + Chr function + +

Chr Function

+ Returns the character that corresponds to the specified character code. +
+ + + + Chr[$](charcode As Integer) As String + + + + String + + + charcode: a numeric expression that represents a valid 8-bit ASCII value (0-255) or a 16-bit Unicode value. (To support expressions with a nominally negative argument like Chr(&H8000) in a backwards-compatible way, values in the range −32768 to −1 are internally mapped to the range 32768 to 65535.) + + When VBA compatibility mode is enabled (Option VBASupport 1), charcode is a numeric expression that represents a valid 8-bit ASCII value (0-255) only. + + Use the Chr$ function to send special control sequences to a printer or to another output source. You can also use it to insert quotation marks in a string expression. + + + + An overflow error will occur when VBA compatibility mode is enabled and the expression value is greater than 255. + + + + Sub ExampleChr + ' This example inserts quotation marks (ASCII value 34) in a string. + MsgBox "A " + Chr$(34) + "short" + Chr(34) + " trip." + ' The printout appears in the dialog as: A "short" trip. + MsgBox Chr(charcode := 64) ' "@" sign + End Sub + + + +
+ + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120103.xhp b/helpcontent2/source/text/sbasic/shared/03120103.xhp new file mode 100644 index 000000000..976c53e7e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120103.xhp @@ -0,0 +1,85 @@ + + + + + + + Str Function + /text/sbasic/shared/03120103.xhp + + + + +
+ + Str function + +

Str Function

+ The Str function converts the contents of variables into a string. It handles numeric values, dates, strings and currency values. + Positive numbers are preceded by a blank space. Negative numbers are preceded by a minus sign. + For numeric values the string returned by the Str function is locale-independent. Hence the dot is used as the decimal separator when needed. + If a string is passed as argument, it is returned without any changes. + Dates are converted into locale-dependent strings. +
+ + + Str (Value As Variant) + + + String + + Value: Any value to be converted into a string. + + + + Below are some numeric examples using the Str function. + + Sub ExampleStr_1 + ' Note the blank space at the beginning of the returned strings + MsgBox Str(10) ' " 10" + MsgBox Str(10.5) ' " 10.5" + MsgBox Str(-12345 + 1.3) ' " -12346.3" + MsgBox Str(10000 / 3) ' " 3333.33333333333" + ' Strings passed as arguments are left unchanged + MsgBox Str("A123") ' "A123" + End Sub + + Use the LTrim function to remove the blank space at the beginning of the returned string. + + Sub ExampleStr_2 + MsgBox Str(10.5) ' " 10.5" + MsgBox LTrim(Str(10.5)) ' "10.5" + End Sub + + The Str function can also handle Date variables. + + Sub ExampleStr_3 + Dim aDate as Date, aTime as Date + aDate = DateSerial(2021, 12, 20) + aTime = TimeSerial(10, 20, 45) + Print Str(aDate) ' "12/20/2021" + Print Str(aTime) ' "10:20:45" + End sub + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03120104.xhp b/helpcontent2/source/text/sbasic/shared/03120104.xhp new file mode 100644 index 000000000..b83dc5625 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120104.xhp @@ -0,0 +1,65 @@ + + + + + + + Val Function + /text/sbasic/shared/03120104.xhp + + + + +
+ + Val function + +

Val Function

+ Use the Val function to convert a string that represents a number into numeric data type. + The string passed to the Val function is locale-independent. This means that commas are interpreted as thousands separators and a dot is used as the decimal separator. +
+ + + Val (Text As String) + + + Double + + Text: String that represents a number. + If only part of the string contains numbers, only the first appropriate characters of the string are converted. If the string does not contain any numbers then Val returns 0. + + + + + Sub ExampleVal + MsgBox Val("123.1") + 1 ' 124.1 + ' Below 123,1 is interpreted as 1231 since "," is the thousands separator + MsgBox Val("123,1") + 1 ' 1232 + ' All numbers are considered until a non-numeric character is reached + MsgBox Val("123.4A") ' 123.4 + ' The example below returns 0 (zero) since the string provided does not start with a number + MsgBox Val("A123.123") ' 0 + End Sub + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03120105.xhp b/helpcontent2/source/text/sbasic/shared/03120105.xhp new file mode 100644 index 000000000..e3f925c69 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120105.xhp @@ -0,0 +1,75 @@ + + + + + + + +CByte Function +/text/sbasic/shared/03120105.xhp + + +Sun Microsystems, Inc. + + + +
+CByte function + +

CByte Function

+Converts a string or a numeric expression to the Byte type. +
+ + +Cbyte( expression As Variant) As Byte + + +Byte + + +Expression: Any string or a numeric expression that can be evaluated to a number. Decimal values are rounded to the nearest tenth. Valid values range from 0 to 256. + + + + + + + Sub CByte_example + Print CByte( expression := "17"/2 + 7.44), CByte(EMPTY), CByte(PI) + ' Above expressions are computed as 16, 0 and 3 + End Sub + + +
+ + + +
+ + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120111.xhp b/helpcontent2/source/text/sbasic/shared/03120111.xhp new file mode 100644 index 000000000..fe6d22493 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120111.xhp @@ -0,0 +1,68 @@ + + + + + + + AscW Function + /text/sbasic/shared/03120111.xhp + + + + + + +
+ + AscW function + + + +

AscW Function [VBA]

+Returns the Unicode value of the first character in a string expression. +
+ + + +AscW (string) As Long + + +Long + + string: Any valid string expression. Only the first character in the string is relevant. +Use the AscW function to replace keys with Unicode values. If the AscW function encounters a blank string, %PRODUCTNAME Basic reports a run-time error. Returned values are between 0 and 65535. + + + + +Sub ExampleAscW + Print AscW("A") ' returns 65 + Print AscW(string:="Ω") ' returns 937 + Print AscW("Αθήνα") ' returns 913, since only the first character (Alpha) is taken into account +End Sub + + +
+ + + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120112.xhp b/helpcontent2/source/text/sbasic/shared/03120112.xhp new file mode 100644 index 000000000..e1eba0429 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120112.xhp @@ -0,0 +1,67 @@ + + + + + + + ChrW Function [VBA] + /text/sbasic/shared/03120112.xhp + + + + + +
+ + ChrW function + + +

ChrW Function [VBA]

+Returns the Unicode character that corresponds to the specified character code. +
+ + + +ChrW(charcode As Integer) As String + + +String + + charcode: Numeric expression that represent a valid 16 bit Unicode value (0-65535). (To support expressions with a nominally negative argument like ChrW(&H8000) in a backwards-compatible way, values in the range −32768 to −1 are internally mapped to the range 32768 to 65535.) An empty value returns error code 5. A value out of the range [0 to 65535] returns error code 6. + + + + + +Sub ExampleChrW + ' This example inserts the Greek letters alpha and omega in a string. + MsgBox "From " + ChrW(913) + " to " + ChrW(937) + ' The printout appears in the dialog as: From Α to Ω + MsgBox ChrW(charcode := 116) ' "t" lowercase T letter +End Sub + + +
+ + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03120200.xhp b/helpcontent2/source/text/sbasic/shared/03120200.xhp new file mode 100644 index 000000000..2a432da70 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120200.xhp @@ -0,0 +1,42 @@ + + + + + + + + +Repeating Contents +/text/sbasic/shared/03120200.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Repeating Contents + The following functions repeat the contents of strings. +
+ + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120201.xhp b/helpcontent2/source/text/sbasic/shared/03120201.xhp new file mode 100644 index 000000000..9b60756d9 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120201.xhp @@ -0,0 +1,67 @@ + + + + + + + Space and Spc Function + /text/sbasic/shared/03120201.xhp + + + + + +
+ + Space function + Spc function + + +

Space and Spc Functions

+Returns a string that consists of a specified amount of spaces. +
+The Spc function works the same as the Space function. + + +Space (n As Long)
+Spc (n As Long) + + +String + + + n: Numeric expression that defines the number of spaces in the string. The maximum allowed value of n is 2,147,483,648. + + + + + +Sub ExampleSpace +Dim sText As String, sOut As String +Dim iLen As Integer + iLen = 10 + sText = "Las Vegas" + sOut = sText & Space(iLen) & sText & Chr(13) &_ + sText & Space(iLen*2) & sText & Chr(13) &_ + sText & Space(iLen*4) & sText & Chr(13) + MsgBox sOut,0,"Info:" +End Sub + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120202.xhp b/helpcontent2/source/text/sbasic/shared/03120202.xhp new file mode 100644 index 000000000..9a09d81a3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120202.xhp @@ -0,0 +1,68 @@ + + + + + + + String Function + /text/sbasic/shared/03120202.xhp + + + + + + +
+ + String function + + + +

String Function

+Creates a string according to the specified character, or the first character of a string expression that is passed to the function. +
+ + + +String (n As Long, {expression As Integer | character As String}) + + + +String + + + n: Numeric expression that indicates the number of characters to return in the string. The maximum allowed value of n is 2,147,483,648. + Expression: Numeric expression that defines the ASCII code for the character. + Character: Any single character used to build the return string, or any string of which only the first character will be used. + + + + + +Sub ExampleString +Dim sText As String + sText = String(10,"A") + MsgBox sText + sText = String(10,65) + MsgBox sText +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120300.xhp b/helpcontent2/source/text/sbasic/shared/03120300.xhp new file mode 100644 index 000000000..cc9697f29 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120300.xhp @@ -0,0 +1,54 @@ + + + + + + +Editing String Contents +/text/sbasic/shared/03120300.xhp + + + +
+Editing String Contents +The following functions edit, format, and align the contents of strings. Use the & or + operators to concatenate strings. + + ampersand symbol; in string handling + Operators;concatenation (& or +) + "& or +" concatenation (strings) + +
+ + + + + + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120301.xhp b/helpcontent2/source/text/sbasic/shared/03120301.xhp new file mode 100644 index 000000000..48f9e0b85 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120301.xhp @@ -0,0 +1,108 @@ + + + + + + + Format Function + /text/sbasic/shared/03120301.xhp + + + + + + +
+ + Format function + + + +

Format Function

+Converts a numeric expression to a string, and then formats it according to the format that you specify. +
+ + + +Format(expression [, format As String]) As String + + +
+ + expression: Numeric expression that you want to convert to a formatted string. + format: String that specifies the format code for the number. If format is omitted, the Format function works like the %PRODUCTNAME Basic Str() function. + + +Text string. +
+ +

Formatting Codes

+
+The following list describes the codes that you can use for formatting a numeric expression: + 0: If expression has a digit at the position of the 0 in the format code, the digit is displayed, otherwise a zero is displayed. +If expression has fewer digits than the number of zeros in the format code, (on either side of the decimal), leading or trailing zeros are displayed. If the expression has more digits to the left of the decimal separator than the amount of zeros in the format code, the additional digits are displayed without formatting. +Decimal places in the expression are rounded according to the number of zeros that appear after the decimal separator in the format code. + #: If expression contains a digit at the position of the # placeholder in the format code, the digit is displayed, otherwise nothing is displayed at this position. +This symbol works like the 0, except that leading or trailing zeroes are not displayed if there are more # characters in the format code than digits in the expression. Only the relevant digits of the expression are displayed. + .: The decimal placeholder determines the number of decimal places to the left and right of the decimal separator. +If the format code contains only # placeholders to the left of this symbol, numbers less than 1 begin with a decimal separator. To always display a leading zero with fractional numbers, use 0 as a placeholder for the first digit to the left of the decimal separator. + %: Multiplies the expressionby 100 and inserts the percent sign (%) where the expression appears in the format code. + E- E+ e- e+ : If the format code contains at least one digit placeholder (0 or #) to the right of the symbol E-, E+, e-, or e+, the expression is formatted in the scientific or exponential format. The letter E or e is inserted between the number and the exponent. The number of placeholders for digits to the right of the symbol determines the number of digits in the exponent. +If the exponent is negative, a minus sign is displayed directly before an exponent with E-, E+, e-, e+. If the exponent is positive, a plus sign is only displayed before exponents with E+ or e+. +The thousands delimiter is displayed if the format code contains the delimiter enclosed by digit placeholders (0 or #). +The use of a period as a thousands and decimal separator is dependent on the regional setting. When you enter a number directly in Basic source code, always use a period as decimal delimiter. The actual character displayed as a decimal separator depends on the number format in your system settings. + - + $ ( ) space: A plus (+), minus (-), dollar ($), space, or brackets entered directly in the format code is displayed as a literal character. +To display characters other than the ones listed here, you must precede it by a backslash (\), or enclose it in quotation marks (" "). + \ : The backslash displays the next character in the format code. +Characters in the format code that have a special meaning can only be displayed as literal characters if they are preceded by a backslash. The backslash itself is not displayed, unless you enter a double backslash (\\) in the format code. +Characters that must be preceded by a backslash in the format code in order to be displayed as literal characters are date- and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, :), numeric-formatting characters (#, 0, %, E, e, comma, period), and string-formatting characters (@, &, <, >, !). +You can also use the following predefined number formats. Except for "General Number", all of the predefined format codes return the number as a decimal number with two decimal places. +If you use predefined formats, the name of the format must be enclosed in quotation marks. +
+ +

Predefined format

+
+ General Number: Numbers are displayed as entered. + Currency: Inserts a dollar sign in front of the number and encloses negative numbers in brackets. + Fixed: Displays at least one digit in front of the decimal separator. + Standard: Displays numbers with a thousands separator. + Percent: Multiplies the number by 100 and appends a percent sign to the number. + Scientific: Displays numbers in scientific format (for example, 1.00E+03 for 1000). +A format code can be divided into three sections that are separated by semicolons. The first part defines the format for positive values, the second part for negative values, and the third part for zero. If you only specify one format code, it applies to all numbers. +
+ + + + + + + +Sub ExampleFormat + MsgBox Format(6328.2, "##,##0.00") + ' always use a period as decimal delimiter when you enter numbers in Basic source code. + ' displays for example 6,328.20 in English locale, 6.328,20 in German locale. +End Sub + +
+ Number format codes + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120302.xhp b/helpcontent2/source/text/sbasic/shared/03120302.xhp new file mode 100644 index 000000000..8664f24e6 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120302.xhp @@ -0,0 +1,67 @@ + + + + + + + LCase Function + /text/sbasic/shared/03120302.xhp + + + + + + +
+ + LCase function + + + +

LCase Function

+Converts all uppercase letters in a string to lowercase. +
+See also: UCase Function + + +LCase (Text As String) + + +String + + + Text: Any string expression that you want to convert. + + + + + +Sub ExampleLUCase +Dim sVar As String + sVar = "Las Vegas" + Print LCase(sVar) ' "las vegas" + Print UCase(sVar) ' "LAS VEGAS" +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120303.xhp b/helpcontent2/source/text/sbasic/shared/03120303.xhp new file mode 100644 index 000000000..596b15faa --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120303.xhp @@ -0,0 +1,74 @@ + + + + + + + Left Function + /text/sbasic/shared/03120303.xhp + + + + + + +
+ + Left function + + + +

Left Function

+Returns the number of leftmost characters that you specify of a string expression. +
+ + + +Left (Text As String, n As Long) + + + +String + + + Text: Any string expression that you want to return the leftmost characters from. + n: Numeric expression that specifies the number of characters that you want to return. If n = 0, a zero-length string is returned. The maximum allowed value is 2,147,483,648. +The following example converts a date in YYYY.MM.DD format to MM/DD/YYYY format. + + + + + +Sub ExampleUSDate +Dim sInput As String +Dim sUS_date As String + sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") + sUS_date = Mid(sInput, 6, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Right(sInput, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Left(sInput, 4) + MsgBox sUS_date +End Sub + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03120304.xhp b/helpcontent2/source/text/sbasic/shared/03120304.xhp new file mode 100644 index 000000000..54567d6a0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120304.xhp @@ -0,0 +1,84 @@ + + + + + + + LSet Statement + /text/sbasic/shared/03120304.xhp + + + + + + +
+ + LSet statement + + + +

LSet Statement

+Aligns a string to the left of a string variable, or copies a variable of a user-defined type to another variable of a different user-defined type. +
+ + + +LSet Var As String = Text or LSet Var1 = Var2 + + + + Var: Any String variable that contains the string that you want align to the left. + Text: String that you want to align to the left of the string variable. + Var1: Name of the user-defined type variable that you want to copy to. + Var2: Name of the user-defined type variable that you want to copy from. +If the string is shorter than the string variable, LSet left-aligns the string within the string variable. Any remaining positions in the string variable are replaced by spaces. If the string is longer than the string variable, only the leftmost characters up to the length of the string variable are copied. With the LSet statement, you can also copy a user-defined type variable to another variable of the same type. + + + +Sub ExampleRLSet +Dim sVar As String +Dim sExpr As String + sVar = String(40,"*") + sExpr = "SBX" + ' Align "SBX" within the 40-character reference string + ' Replace asterisks with spaces + RSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(5,"*") + sExpr = "123457896" + RSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(40,"*") + sExpr = "SBX" + ' Left-align "SBX" within the 40-character reference string + LSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(5,"*") + sExpr = "123456789" + LSet sVar = sExpr + Print ">"; sVar; "<" +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120305.xhp b/helpcontent2/source/text/sbasic/shared/03120305.xhp new file mode 100644 index 000000000..730e3cbb7 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120305.xhp @@ -0,0 +1,75 @@ + + + + + + + LTrim Function + /text/sbasic/shared/03120305.xhp + + + + + + +
+ + LTrim function + + + +

LTrim Function

+Removes all leading spaces at the start of a string expression. +
+ + + +LTrim (Text As String) + + + +String + + + Text: Any string expression. +Use this function to remove spaces at the beginning of a string expression. + + + + + +Sub ExampleSpaces +Dim sText2 As String,sText As String,sOut As String + sText2 = " <*Las Vegas*> " + sOut = "'"+sText2 +"'"+ Chr(13) + sText = Ltrim(sText2) ' sText = "<*Las Vegas*> " + sOut = sOut + "'"+sText +"'" + Chr(13) + sText = Rtrim(sText2) ' sText = " <*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + Chr(13) + sText = Trim(sText2) ' sText = "<*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + MsgBox sOut +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120306.xhp b/helpcontent2/source/text/sbasic/shared/03120306.xhp new file mode 100644 index 000000000..d3f4efe7b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120306.xhp @@ -0,0 +1,78 @@ + + + + + + + Mid Function, Mid Statement + /text/sbasic/shared/03120306.xhp + + + + + + +
+ + Mid function + Mid statement + + + +

Mid Function, Mid Statement

+Returns the specified portion of a string expression (Mid function), or replaces the portion of a string expression with another string (Mid statement). +
+ + + +Mid (Text As String, Start As Long [, Length As Long]) or Mid (Text As String, Start As Long , Length As Long, Text As String) + + + +String (only by Function) + + + Text: Any string expression that you want to modify. + Start: Numeric expression that indicates the character position within the string where the string portion that you want to replace or to return begins. The minimum allowed value is 1. The maximum allowed value is 2,147,483,648.see i17928 + Length: Numeric expression that returns the number of characters that you want to replace or return. The maximum allowed value is 2,147,483,648. +If the Length parameter in the Mid function is omitted, all characters in the string expression from the start position to the end of the string are returned. +If the Length parameter in the Mid statement is less than the length of the text that you want to replace, the text is reduced to the specified length. + Text: The string to replace the string expression (Mid statement). + + + + + +Sub ExampleUSDate +Dim sInput As String +Dim sUS_date As String + sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") + sUS_date = Mid(sInput, 6, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Right(sInput, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Left(sInput, 4) + MsgBox sUS_date +End Sub + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03120307.xhp b/helpcontent2/source/text/sbasic/shared/03120307.xhp new file mode 100644 index 000000000..e970b80a1 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120307.xhp @@ -0,0 +1,76 @@ + + + + + + + Right Function + /text/sbasic/shared/03120307.xhp + + + + + + + +See also: Left Function. + + + +Right (Text As String, n As Long) + + + +String + + + Text: Any string expression that you want to return the rightmost characters of. + n: Numeric expression that defines the number of characters that you want to return. If n = 0, a zero-length string is returned. The maximum allowed value is 2,147,483,648. +The following example converts a date in YYYY-MM-DD format to the US date format (MM/DD/YYYY). + + + + + +Sub ExampleUSDate +Dim sInput As String +Dim sUS_date As String + sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") + sUS_date = Mid(sInput, 6, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Right(sInput, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Left(sInput, 4) + MsgBox sUS_date +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120308.xhp b/helpcontent2/source/text/sbasic/shared/03120308.xhp new file mode 100644 index 000000000..e527399c5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120308.xhp @@ -0,0 +1,86 @@ + + + + + + + RSet Statement + /text/sbasic/shared/03120308.xhp + + + + + + +
+ + RSet statement + + + +

RSet Statement

+Right-aligns a string within a string variable, or copies a user-defined variable type into another. +
+ + + +RSet Text As String = Text or RSet Variable1 = Variable2 + + + + Text: Any string variable. + Text: String that you want to right-align in the string variable. + Variable1: User-defined variable that is the target for the copied variable. + Variable2: User-defined variable that you want to copy to another variable. +If the string is shorter than the string variable, RSet aligns the string to the right within the string variable. Any remaining characters in the string variable are replaced with spaces. If the string is longer than the string variable, characters exceeding the length of the variable are truncated, and only the remaining characters are right-aligned within the string variable. +You can also use the RSet statement to assign variables of one user-defined type to another. +The following example uses the RSet and LSet statements to modify the left and right alignment of a string. + + + +Sub ExampleRLSet +Dim sVar As String +Dim sExpr As String + sVar = String(40,"*") + sExpr = "SBX" + ' Right-align "SBX" in a 40-character string + ' Replace asterisks with spaces + RSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(5,"*") + sExpr = "123457896" + RSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(40,"*") + sExpr = "SBX" + ' Left-align "SBX" in a 40-character string + LSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(5,"*") + sExpr = "123456789" + LSet sVar = sExpr + Print ">"; sVar; "<" +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120309.xhp b/helpcontent2/source/text/sbasic/shared/03120309.xhp new file mode 100644 index 000000000..8e6d160f5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120309.xhp @@ -0,0 +1,75 @@ + + + + + + + RTrim Function + /text/sbasic/shared/03120309.xhp + + + + + + +
+ + RTrim function + + + +

RTrim Function

+Deletes the spaces at the end of a string expression. +
+See also: LTrim Function + + + +RTrim (Text As String) + + + +String + + + Text: Any string expression. + + + + + +Sub ExampleSpaces +Dim sText2 As String,sText As String,sOut As String + sText2 = " <*Las Vegas*> " + sOut = "'"+sText2 +"'"+ Chr(13) + sText = Ltrim(sText2) ' sText = "<*Las Vegas*> " + sOut = sOut + "'"+sText +"'" + Chr(13) + sText = Rtrim(sText2) ' sText = " <*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + Chr(13) + sText = Trim(sText2) ' sText = "<*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + MsgBox sOut +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120310.xhp b/helpcontent2/source/text/sbasic/shared/03120310.xhp new file mode 100644 index 000000000..87c0de547 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120310.xhp @@ -0,0 +1,65 @@ + + + + + + + UCase Function + /text/sbasic/shared/03120310.xhp + + + + + + +
+ + UCase function + + + +

UCase Function

+Converts lowercase characters in a string to uppercase. +
+See also: LCase Function + +UCase (Text As String) + +String + + + Text: Any string expression that you want to convert. + + + + + +Sub ExampleLUCase +Dim sVar As String + sVar = "Las Vegas" + Print LCase(sVar) ' "las vegas" + Print UCase(sVar) ' "LAS VEGAS" +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120311.xhp b/helpcontent2/source/text/sbasic/shared/03120311.xhp new file mode 100644 index 000000000..5d12ed80a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120311.xhp @@ -0,0 +1,74 @@ + + + + + + + Trim Function + /text/sbasic/shared/03120311.xhp + + + + + + +
+ + Trim function + + + +

Trim Function

+Removes all leading and trailing spaces from a string expression. +
+ + + +Trim( Text As String ) + + + +String + + + Text: Any string expression. + + + + + +Sub ExampleSpaces +Dim sText2 As String,sText As String,sOut As String + sText2 = " <*Las Vegas*> " + sOut = "'"+sText2 +"'"+ Chr(13) + sText = Ltrim(sText2) ' sText = "<*Las Vegas*> " + sOut = sOut + "'"+sText +"'" + Chr(13) + sText = Rtrim(sText2) ' sText = " <*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + Chr(13) + sText = Trim(sText2) ' sText = "<*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + MsgBox sOut +End Sub + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120312.xhp b/helpcontent2/source/text/sbasic/shared/03120312.xhp new file mode 100644 index 000000000..8c67769f5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120312.xhp @@ -0,0 +1,60 @@ + + + + + +ConvertToURL Function +/text/sbasic/shared/03120312.xhp + + +Sun Microsystems, Inc. + + + +
+ConvertToURL function + +

ConvertToURL Function

+Converts a system file name to a file URL. +
+ + +ConvertToURL(filename) + + +String + +filename: A file name as string. + + +
+ + + systemFile$ = "c:\folder\mytext.txt" + url$ = ConvertToURL( systemFile$ ) + print url$ + systemFileAgain$ = ConvertFromURL( url$ ) + print systemFileAgain$ + +
+
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03120313.xhp b/helpcontent2/source/text/sbasic/shared/03120313.xhp new file mode 100644 index 000000000..0c4ab4ba8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120313.xhp @@ -0,0 +1,51 @@ + + + + + +ConvertFromURL Function +/text/sbasic/shared/03120313.xhp + + +Sun Microsystems, Inc. + + + +
+ConvertFromURL function + +

ConvertFromURL Function

+Converts a file URL to a system file name. +
+ + +ConvertFromURL(filename) + + +String + +filename: A file name as a string. + + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03120314.xhp b/helpcontent2/source/text/sbasic/shared/03120314.xhp new file mode 100644 index 000000000..059f5e95e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120314.xhp @@ -0,0 +1,104 @@ + + + + + + + Split Function + /text/sbasic/shared/03120314.xhp + + + + + + +
+ + Split function + + + +

Split Function

+Returns an array of substrings from a string expression. +
+ + + +Split (Text As String, delimiter, number) + + + +With Option VBASupport 1: String, with Option VBASupport 0: Variant/String + + + Text: Any string expression. + delimiter (optional): A string of one or more characters length that is used to delimit the Text. The default is the space character. + number (optional): The number of substrings that you want to return. + + + +
+ +Dim a(3) +Sub main() + a(0) = "ABCDE" + a(1) = 42 + a(2) = "MN" + a(3) = "X Y Z" + JStr = Join1() + Call Show(JStr, Split1(JStr)) + JStr = Join2() + Call Show(JStr, Split1(JStr)) + JStr = Join3() + Call Show(JStr, Split1(JStr)) +End Sub + +Function Join1() + Join1 = Join(a(), "abc") +End Function + +Function Join2() + Join2 = Join(a(), ",") +End Function + +Function Join3() + Join3 = Join(a()) +End Function + +Function Split1(aStr) + Split1 = Split(aStr, "D") +End Function + +Sub Show(JoinStr, TheArray) + l = LBound(TheArray) + u = UBound(TheArray) + total$ = "=============================" + Chr$(13) + JoinStr + Chr$(13) + Chr$(13) + For i = l To u + total$ = total$ + TheArray(i) + Str(Len(TheArray(i))) + Chr$(13) + Next i + MsgBox total$ +End Sub + +
+
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120315.xhp b/helpcontent2/source/text/sbasic/shared/03120315.xhp new file mode 100644 index 000000000..68e406f3b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120315.xhp @@ -0,0 +1,51 @@ + + + + + +Join Function +/text/sbasic/shared/03120315.xhp + + +Sun Microsystems, Inc. + + + +
+Join function + +

Join Function

+Returns a string from a number of substrings in a string array. +
+ + +Join (Text As String Array, delimiter) + + +String + +Text: A string array. +delimiter (optional): A string character that is used to separate the substrings in the resulting string. The default delimiter is the space character. If delimiter is a string of length zero "", the substrings are joined without separator. + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03120400.xhp b/helpcontent2/source/text/sbasic/shared/03120400.xhp new file mode 100644 index 000000000..b3012ca68 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120400.xhp @@ -0,0 +1,43 @@ + + + + + + + + +Editing String Length +/text/sbasic/shared/03120400.xhp + + +Sun Microsystems, Inc. + + + + + +
+ Editing String Length + The following functions determine string lengths and compare strings. +
+ + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120401.xhp b/helpcontent2/source/text/sbasic/shared/03120401.xhp new file mode 100644 index 000000000..ae53e0d99 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120401.xhp @@ -0,0 +1,71 @@ + + + + + + + InStr Function + /text/sbasic/shared/03120401.xhp + + + + + + +
+ + InStr function + + + +

InStr Function

+Returns the position of a string within another string. +
+The Instr function returns the position at which the match was found. If the string was not found, the function returns 0. + +

Syntax:

+ +InStr ([Start As Long,] Text1 As String, Text2 As String[, Compare]) + + +

Return value:

+Integer + +

Parameters:

+ Start: A numeric expression that marks the position in a string where the search for the specified substring starts. If you omit this parameter, the search starts at the first character of the string. The minimum allowed value is 1. The maximum allowed value is 2,147,483,648.see i17928 + Text1: The string expression that you want to search. + Text2: The string expression that you want to search for. + Compare: Optional numeric expression that defines the type of comparison. The value of this parameter can be 0 or 1. The default value of 1 specifies a text comparison that is not case-sensitive. The value of 0 specifies a binary comparison that is case-sensitive.fixes i17929 +To avoid a run-time error, do not set the Compare parameter if the first optional parameter is omitted. + + + +

Example:

+ +Sub ExamplePosition +Dim sInput As String +Dim iPos As Integer + sInput = "Office" + iPos = Instr(sInput,"c") + Print iPos +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120402.xhp b/helpcontent2/source/text/sbasic/shared/03120402.xhp new file mode 100644 index 000000000..e57cb67fd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120402.xhp @@ -0,0 +1,59 @@ + + + + + + + +Len Function +/text/sbasic/shared/03120402.xhp + + +Sun Microsystems, Inc. + + + +
+Len function + +Len Function +Returns the number of characters in a string, or the number of bytes that are required to store a variable. +
+Syntax: + +Len (Text As String) + +Return value: +Long +Parameters: + +Text: Any string expression or a variable of another type. + + +Example: + +Sub ExampleLen +Dim sText as String + sText = "Las Vegas" + MsgBox Len(sText) ' 9 +End Sub + + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03120403.xhp b/helpcontent2/source/text/sbasic/shared/03120403.xhp new file mode 100644 index 000000000..6551e263d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120403.xhp @@ -0,0 +1,81 @@ + + + + + + + StrComp Function + /text/sbasic/shared/03120403.xhp + + + + + + +
+ + StrComp function + + + +StrComp Function +Compares two strings and returns an integer value that represents the result of the comparison. +
+ +Syntax: + +StrComp (Text1 As String, Text2 As String[, Compare]) + + +Return value: +Integer + +Parameter: + Text1: Any string expression + Text2: Any string expression + Compare: This optional parameter sets the comparison method. If Compare = 1, the string comparison is case-sensitive. If Compare = 0, no distinction is made between uppercase and lowercase letters. + +Return value + + + + If Text1 < Text2 the function returns -1 + + + If Text1 = Text2 the function returns 0 + + + If Text1 > Text2 the function returns 1 + + + + +Example: + +Sub ExampleStrComp +Dim iVar As Single +Dim sVar As String + iVar = 123.123 + sVar = Str$(iVar) + MsgBox strcomp(sVar , Str$(iVar),1) +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03120411.xhp b/helpcontent2/source/text/sbasic/shared/03120411.xhp new file mode 100644 index 000000000..5ba7cc315 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120411.xhp @@ -0,0 +1,76 @@ + + + + + + + InStrRev Function [VBA] + /text/sbasic/shared/03120411.xhp + + + + + + +
+ + InStrRev function + + + +InStrRev Function [VBA] +Returns the position of a string within another string, starting from the right side of the string. +
+ +The InStrRev function returns the position at which the match was found, from the right. If the string was not found, the function returns 0. + + +InStrRev (Text1 As String, Text2 As String [,Start As Long] [, Compare As Integer]) + + +Long + + Text1: The string expression that you want to search. + Text2: The string expression that you want to search for. + Start: Optional numeric expression that marks the position from the left in a string where the search for the specified substring starts. If you omit this parameter, the search starts at the last character of the string. The maximum allowed value is 65535. + Compare: Optional numeric expression that defines the type of comparison. The value of this parameter can be +1: The default value of 1 specifies a text comparison that is not case-sensitive. +0: The value of 0 specifies a binary comparison that is case-sensitive. +To avoid a run-time error, do not set the Compare parameter if the first return parameter is omitted. + + + + +Sub ExamplePosition +Dim sInput As String +Dim iPos As Integer + sInput = "The book is on the table" + iPos = InStrRev(sInput,"the",10,1) ' Returns 1, search is case-insensitive + Print iPos + iPos = InStrRev(sInput,"the",10,0) ' Returns 0, search is case-sensitive + Print iPos +End Sub + + +
+InStr +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03120412.xhp b/helpcontent2/source/text/sbasic/shared/03120412.xhp new file mode 100644 index 000000000..0c743326c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120412.xhp @@ -0,0 +1,57 @@ + + + + + + + StrReverse Function [VBA] + /text/sbasic/shared/03120412.xhp + + + + + + +
+ + StrReverse function + +StrReverse Function [VBA] +Returns the string with the character order reversed. +
+ + + +StrReverse (Text1 As String) + + +String + + Text1: The string expression that you want to reverse the character order. + + + + +Sub ExampleReverse + Print StrReverse("ABCdefGH") ' return "HGfedCBA" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03130000.xhp b/helpcontent2/source/text/sbasic/shared/03130000.xhp new file mode 100644 index 000000000..c281ca33c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03130000.xhp @@ -0,0 +1,50 @@ + + + + + + + + +Other Commands +/text/sbasic/shared/03130000.xhp + + +Sun Microsystems, Inc. + + + +
+Other Commands +This is a list of the functions and the statements that are not included in the other categories. +
+ + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03130100.xhp b/helpcontent2/source/text/sbasic/shared/03130100.xhp new file mode 100644 index 000000000..f8e90b2dd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03130100.xhp @@ -0,0 +1,59 @@ + + + + + + + +Beep Statement +/text/sbasic/shared/03130100.xhp + + +Sun Microsystems, Inc. + + + +
+Beep statement + +

Beep Statement

+Plays a tone through the computer's speaker. The tone is system-dependent and you cannot modify its volume or pitch. +
+ + + + Beep Statement diagram + + +Beep + + + + + + +Sub ExampleBeep + Beep + Beep + Beep +End Sub + + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03130500.xhp b/helpcontent2/source/text/sbasic/shared/03130500.xhp new file mode 100644 index 000000000..c6c6fb321 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03130500.xhp @@ -0,0 +1,137 @@ + + + + + + + Shell Function + /text/sbasic/shared/03130500.xhp + + + + + +
+ + Shell function + + +

Shell Function

+Starts another application and defines the respective window style, if necessary. +
+ + +Shell (Pathname As String[, Windowstyle As Integer][, Param As String][, bSync]) + + + +

Pathname

+Complete path and program name of the program that you want to start. + +

Windowstyle

+Optional integer expression that specifies the style of the window that the program is executed in. The following values are possible: + + + + + + Windowstyle + + + Meaning + + + + + + 0 + + + The focus is on the hidden program window. + + + + + 1 + + + The focus is on the program window in standard size. + + + + + 2 + + + The focus is on the minimized program window. + + + + + 3 + + + focus is on the maximized program window. + + + + + 4 + + + Standard size program window, without focus. + + + + + 6 + + + Minimized program window, focus remains on the active window. + + + + + 10 + + + Full-screen display. + + +
+ +

Param

+Any string expression that specifies the command line that want to pass. + +

bSync

+If this value is set to true, the Shell command and all $[officename] tasks wait until the shell process completes. If the value is set to false, the shell returns directly. The default value is false. + + + + + + + +Sub ExampleShellForWin + Shell("c:\windows\calc.exe",2) +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03130600.xhp b/helpcontent2/source/text/sbasic/shared/03130600.xhp new file mode 100644 index 000000000..849f00c86 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03130600.xhp @@ -0,0 +1,60 @@ + + + + + + + +Wait Statement +/text/sbasic/shared/03130600.xhp + + +Sun Microsystems, Inc. + + + +
+Wait statement + +Wait Statement +Interrupts the program execution for the amount of time that you specify in milliseconds. +
+ +Wait millisec + + +millisec: Numeric expression that contains the amount of time (in milliseconds) to wait before the program is executed. + + + + +Sub ExampleWait +Dim lTick As Long + lTick = GetSystemTicks() + Wait 2000 + lTick = (GetSystemTicks() - lTick) + MsgBox "" & lTick & " Ticks" ,0,"The pause lasted" +End Sub + +
+ WaitUntil statement +
+ +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03130610.xhp b/helpcontent2/source/text/sbasic/shared/03130610.xhp new file mode 100644 index 000000000..dc0edc5e3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03130610.xhp @@ -0,0 +1,51 @@ + + + + + + + + WaitUntil Statement + /text/sbasic/shared/03130610.xhp + + + +
+ + WaitUntil statement + +

WaitUntil Statement

+ Interrupts the program execution until the time specified. +
+ + WaitUntil Time + + + Time: A Date and Time expression that contains the date and time to wait before the program is executed. + + + + + + REM Wait until 6:00 PM then call MyMacro. + REM If after 6:00 PM, exit. + Sub ExampleWaitUntil + Dim vTimeschedule As Double + vTimeSchedule = Date() + TimeValue("18:00:00") + If vTimeSchedule < Now() Then Exit Sub + WaitUntil vTimeSchedule + Call MyMacro + End Sub + +
+ Wait statement +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03130700.xhp b/helpcontent2/source/text/sbasic/shared/03130700.xhp new file mode 100644 index 000000000..bb7fe6cf9 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03130700.xhp @@ -0,0 +1,65 @@ + + + + + + + GetSystemTicks Function + /text/sbasic/shared/03130700.xhp + + + + + +
+ + GetSystemTicks function + + +GetSystemTicks Function +Returns the number of system ticks provided by the operating system. You can use this function to optimize certain processes. +
+ +Syntax: + +GetSystemTicks() + + +Return value: +Long + + + +Example: + +Sub ExampleWait +Dim lTick As Long + lTick = GetSystemTicks() + Wait 2000 + lTick = (GetSystemTicks() - lTick) + MsgBox "" & lTick & " Ticks" ,0,"The pause lasted" +End Sub + + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03130800.xhp b/helpcontent2/source/text/sbasic/shared/03130800.xhp new file mode 100644 index 000000000..c5e84cd5d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03130800.xhp @@ -0,0 +1,65 @@ + + + + + + + Environ Function + /text/sbasic/shared/03130800.xhp + + + + + + +
+ + Environ function + + + +Environ Function +Returns the value of an environment variable as a string. Environment variables are dependent on the type of operating system that you have. +
+ +Syntax: + +Environ (Environment As String) + + +Return value: +String + +Parameters: +Environment: Environment variable that you want to return the value for. + + + +Example: + +Sub ExampleEnviron +Dim sTemp As String + sTemp=Environ ("TEMP") + If sTemp = "" Then sTemp=Environ("TMP") + MsgBox "'" & sTemp & "'" ,64,"Directory of temporary files:" +End Sub + + + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03131000.xhp b/helpcontent2/source/text/sbasic/shared/03131000.xhp new file mode 100644 index 000000000..92a2a316f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03131000.xhp @@ -0,0 +1,57 @@ + + + + + + + GetSolarVersion Function + /text/sbasic/shared/03131000.xhp + + + + + +
+ + GetSolarVersion function + + +GetSolarVersion Function +Returns the internal number of the current $[officename] version. +
+ +Syntax: + +s = GetSolarVersion + + +Return value: +String + +Example: + +Sub ExampleGetSolarVersion +Dim sSep As String + sSep = GetSolarVersion + MsgBox sSep,64,"Version number of the solar technology" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03131300.xhp b/helpcontent2/source/text/sbasic/shared/03131300.xhp new file mode 100644 index 000000000..264a5b644 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03131300.xhp @@ -0,0 +1,55 @@ + + + + + + + TwipsPerPixelX Function + /text/sbasic/shared/03131300.xhp + + + + + +
+ + TwipsPerPixelX function + + +TwipsPerPixelX Function +Returns the number of twips that represent the width of a pixel. +
+ +Syntax: + +n = TwipsPerPixelX + + +Return value: +Integer + +Example: + +Sub ExamplePixelTwips + MsgBox "" & TwipsPerPixelX() & " Twips * " & TwipsPerPixelY() & " Twips",0,"Pixel size" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03131400.xhp b/helpcontent2/source/text/sbasic/shared/03131400.xhp new file mode 100644 index 000000000..5b4586b02 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03131400.xhp @@ -0,0 +1,55 @@ + + + + + + + TwipsPerPixelY Function + /text/sbasic/shared/03131400.xhp + + + + + +
+ + TwipsPerPixelY function + + +TwipsPerPixelY Function +Returns the number of twips that represent the height of a pixel. +
+ +Syntax: + +n = TwipsPerPixelY + + +Return value: +Integer + +Example: + +Sub ExamplePixelTwips + MsgBox "" & TwipsPerPixelX() & " Twips * " & TwipsPerPixelY() & " Twips",0,"Pixel size" +End Sub + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03131500.xhp b/helpcontent2/source/text/sbasic/shared/03131500.xhp new file mode 100644 index 000000000..a249debd2 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03131500.xhp @@ -0,0 +1,49 @@ + + + + + + + + CreateUnoStruct Function + /text/sbasic/shared/03131500.xhp + + + Sun Microsystems, Inc. + + + +
+ CreateUnoStruct function + +

CreateUnoStruct Function

+ Creates an instance of a Uno structure type. +
+ + oStruct = CreateUnoStruct( Uno type name ) + + + oStruct = CreateUnoStruct( "com.sun.star.beans.Property" ) + + Or use the following structure for your statement: + + Dim oStruct as new com.sun.star.beans.Property + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03131600.xhp b/helpcontent2/source/text/sbasic/shared/03131600.xhp new file mode 100644 index 000000000..bf62e3df4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03131600.xhp @@ -0,0 +1,76 @@ + + + + + + CreateUnoService Function + /text/sbasic/shared/03131600.xhp + + + +
+ + CreateUnoService function + API;FilePicker + API;SimpleFileAccess + +

CreateUnoService Function

+ Instantiates a Uno service with the ProcessServiceManager. +
+ + oService = CreateUnoService( UNO service name ) + For a list of available services, visit the com::sun::star Module reference page. + + The example below creates the function FileExists that uses the service com.sun.star.ucb.SimpleFileAccess to test if a given path is an existing file. + + Function FileExists(sPath as String) as Boolean + Dim svcSFA as Object + Set svcSFA = CreateUnoService("com.sun.star.ucb.SimpleFileAccess") + Dim bExists as Boolean : bExists = svcSFA.exists(sPath) + Dim bIsFolder as Boolean : bIsFolder = svcSFA.IsFolder(sPath) + FileExists = bExists And Not bIsFolder + End Function + + UNO services have an extensive online documentation in the api.libreoffice.org website. Visit the SimpleFileAccess Service reference page to learn more about the methods provided by the service used in the example above. + + +filepicker;API service + +The following code uses the service com.sun.star.ui.dialogs.FilePicker to show a file open dialog: + +Sub Main + fName = FileOpenDialog ("Please select a file") + Print "file chosen: "+fName +End Sub + +Function FileOpenDialog(title As String) As String + res = com.sun.star.ui.dialogs.ExecutableDialogResults + filepicker = createUnoService("com.sun.star.ui.dialogs.FilePicker") + filepicker.Title = title + If res.OK = filepicker.execute() Then + files = filepicker.getSelectedFiles() + FileOpenDialog=files(0) + EndIf +End Function + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03131700.xhp b/helpcontent2/source/text/sbasic/shared/03131700.xhp new file mode 100644 index 000000000..e04eac85d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03131700.xhp @@ -0,0 +1,50 @@ + + + + + + + +GetProcessServiceManager Function +/text/sbasic/shared/03131700.xhp + + +Sun Microsystems, Inc. + + + +
+GetProcessServiceManager function +ProcessServiceManager + +GetProcessServiceManager Function +Returns the ProcessServiceManager (central Uno ServiceManager). +
+This function is required when you want to instantiate a service using CreateInstanceWithArguments. + +oServiceManager = GetProcessServiceManager() + + + oServiceManager = GetProcessServiceManager() + oIntrospection = oServiceManager.createInstance("com.sun.star.beans.Introspection"); + ' this is the same as the following statement: + oIntrospection = CreateUnoService("com.sun.star.beans.Introspection") + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03131800.xhp b/helpcontent2/source/text/sbasic/shared/03131800.xhp new file mode 100644 index 000000000..26f71a677 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03131800.xhp @@ -0,0 +1,54 @@ + + + + + + + +CreateUnoDialog Function +/text/sbasic/shared/03131800.xhp + + +Sun Microsystems, Inc. + + + + +
+ + CreateUnoDialog function + +CreateUnoDialog Function +Creates a Basic Uno object that represents a Uno dialog control during Basic runtime. +
+Dialogs are defined in the dialog libraries. To display a dialog, a "live" dialog must be created from the library. +See Examples. + +CreateUnoDialog( oDlgDesc ) + + + ' Get dialog description from the dialog library + oDlgDesc = DialogLibraries.Standard.Dialog1 + ' Generate "live" dialog + oDlgControl = CreateUnoDialog( oDlgDesc ) + ' display "live" dialog + oDlgControl.execute + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03131900.xhp b/helpcontent2/source/text/sbasic/shared/03131900.xhp new file mode 100644 index 000000000..e91105025 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03131900.xhp @@ -0,0 +1,64 @@ + + + + + + + +GlobalScope +/text/sbasic/shared/03131900.xhp + + +Sun Microsystems, Inc. + + + +
+GlobalScope specifier +library systems +Library container +GlobalScope +API; BasicLibraries +API; DialogLibraries +BasicLibraries; library container +DialogLibraries; library container + +

GlobalScope specifier

+To manage personal or shared library containers (Application Macros or My Macros) from within a document, use the GlobalScope specifier. +
+
+ Basic source code and dialogs are organized in library containers. Libraries can contain modules and dialogs. +
+

In Basic:

+Basic libraries and modules can be managed with the BasicLibraries object. Libraries can be searched, explored and loaded on request. Monitoring Documents Events illustrates %PRODUCTNAME library loading. +

In dialogs:

+Dialog libraries and dialogs can be managed with the DialogLibraries object. Opening a Dialog With Basic illustrates how to display %PRODUCTNAME shared dialogs. +BasicLibraries and DialogLibraries containers exist at application level and within every document. Document's library containers do not need the GlobalScope specifier to be managed. If you want to call a global library container (located in Application Macros or My Macros) from within a document, you must use the GlobalScope specifier. + +GlobalScope specifier + +Example in the document Basic + + ' calling Dialog1 in the document library Standard + oDlgDesc = DialogLibraries.Standard.Dialog1 + ' calling Dialog2 in the application library Library1 + oDlgDesc = GlobalScope.DialogLibraries.Library1.Dialog2 + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03132000.xhp b/helpcontent2/source/text/sbasic/shared/03132000.xhp new file mode 100644 index 000000000..475fd4333 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03132000.xhp @@ -0,0 +1,131 @@ + + + + + + + CreateUnoListener Function + /text/sbasic/shared/03132000.xhp + + + + + + +
+ + CreateUnoListener function + + + +CreateUnoListener Function +Creates a Listener instance. +
+Many Uno interfaces let you register listeners on a special listener interface. This allows you to listen for specific events and call up the appropriate listener method. The CreateUnoListener function waits for the called listener interface and then passes the interface an object that the interface supports. This object is then passed to the method to register the listener. + +oListener = CreateUnoListener( Prefixname, ListenerInterfaceName ) + +The following example is based on a Basic library object. + +Dim oListener +oListener = CreateUnoListener( "ContListener_","com.sun.star.container.XContainerListener" ) + +The CreateUnoListener method requires two parameters. The first is a prefix and is explained in detail below. The second parameter is the fully qualified name of the Listener interface that you want to use. +The Listener must then be added to the Broadcaster Object. This is done by calling the appropriate method for adding a Listener. These methods always follow the pattern "addFooListener", where "Foo" is the Listener Interface Type, without the 'X'. In this example, the addContainerListener method is called to register the XContainerListener: + +Dim oLib +oLib = BasicLibraries.Library1 ' Library1 must exist! +oLib.addContainerListener( oListener ) ' Register the listener + +The Listener is now registered. When an event occurs, the corresponding Listener calls the appropriate method from the com.sun.star.container.XContainerListener Interface. +The prefix calls registered Listeners from Basic-subroutines. The Basic run-time system searches for Basic-subroutines or functions that have the name "PrefixListenerMethode" and calls them when found. Otherwise, a run-time error occurs. +In this example, the Listener-Interface uses the following methods: + + + + disposing: + + + Listener base interface (com.sun.star.lang.XEventListener): base interface for all Listener Interfaces + + + elementInserted: + + + Method of the com.sun.star.container.XContainerListener interface + + + elementRemoved: + + + Method of the com.sun.star.container.XContainerListener interface + + + elementReplaced: + + + Method of the com.sun.star.container.XContainerListener interface + +In this example, the prefix is ContListener_. The following subroutines must therefore be implemented in Basic: + + + + ContListener_disposing + + + ContListener_elementInserted + + + ContListener_elementRemoved + + + ContListener_elementReplaced + +An event structure type that contains information about an event exists for every Listener type. When a Listener method is called, an instance of this event is passed to the method as a parameter. Basic Listener methods can also call these event objects, so long as the appropriate parameter is passed in the Sub declaration. For example: + +Sub ContListener_disposing( oEvent ) + MsgBox "disposing" + MsgBox oEvent.Dbg_Properties +End Sub + +Sub ContListener_elementInserted( oEvent ) + MsgBox "elementInserted" + MsgBox oEvent.Dbg_Properties +End Sub + +Sub ContListener_elementRemoved( oEvent ) + MsgBox "elementRemoved" + MsgBox oEvent.Dbg_Properties +End Sub + +Sub ContListener_elementReplaced( oEvent ) + MsgBox "elementReplaced" + MsgBox oEvent.Dbg_Properties +End Sub + +You do not need to include the parameter of an event object if the object is not used: + +' Minimal implementation of Sub disposing +Sub ContListener_disposing +End Sub + +Listener methods must always be implemented to avoid Basic run-time errors. + + +
diff --git a/helpcontent2/source/text/sbasic/shared/03132100.xhp b/helpcontent2/source/text/sbasic/shared/03132100.xhp new file mode 100644 index 000000000..c95d845ff --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03132100.xhp @@ -0,0 +1,56 @@ + + + + + + + + GetGuiType Function + /text/sbasic/shared/03132100.xhp + + + +
+GetGuiType function + +

GetGuiType Function

+ Returns a numerical value that specifies the graphical user interface. +
+ This function is only provided for downward compatibility to previous versions. The return value is not defined in client-server environments. + Syntax: + +GetGUIType() + + Return value: + Integer + Return values: + 1: Windowsremoved 3: Mac OS, see i95717 +4: UNIX + Example: + + Sub ExampleEnvironment + MsgBox GetGUIType + End Sub + +
+ +
+ +
+ diff --git a/helpcontent2/source/text/sbasic/shared/03132200.xhp b/helpcontent2/source/text/sbasic/shared/03132200.xhp new file mode 100644 index 000000000..b89a5d3cb --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03132200.xhp @@ -0,0 +1,67 @@ + + + + + + ThisComponent Object + /text/sbasic/shared/03132200.xhp + + + +
+ + ThisComponent object + components;addressing + + +

ThisComponent Object

+ThisComponent represents the current document in Basic macros. It addresses the active component whose properties can be read and set, and whose methods can be called. Properties and methods available through ThisComponent depend on the document type.see i60932 +
+ + + + ThisComponent + +When the active window is a Base form, query, report, table or view, ThisComponent returns the current Form information. +When active window is the Basic IDE, ThisComponent object returns the component owning the current script. + + + +Sub Main +' updates the "Table of Contents" in a text doc +Dim allindexes, index As Object + allindexes = ThisComponent.getDocumentIndexes() + index = allindexes.getByName("Table of Contents1") + ' use the default name for Table of Contents and a 1 + index.update() +End Sub + + +
+ com.sun.star.text.TextDocument API service + com.sun.star.sheet.SpreadsheetDocument API service + com.sun.star.presentation.PresentationDocument API service + com.sun.star.drawing.DrawingDocument API service + com.sun.star.formula.FormulaProperties API service + com.sun.star.sdb.OfficeDatabaseDocument API service + com.sun.star.document.OfficeDocument API service +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03132300.xhp b/helpcontent2/source/text/sbasic/shared/03132300.xhp new file mode 100644 index 000000000..0a490c7a3 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03132300.xhp @@ -0,0 +1,47 @@ + + + + + + + +CreateUnoValue Function +/text/sbasic/shared/03132300.xhp + + +Sun Microsystems, Inc. + + + +
+CreateUnoValue function + +CreateUnoValue Function +Returns an object that represents a strictly typed value referring to the Uno type system. +
+This object is automatically converted to an Any of the corresponding type when passed to Uno. The type must be specified by its fully qualified Uno type name. +The $[officename] API frequently uses the Any type. It is the counterpart of the Variant type known from other environments. The Any type holds one arbitrary Uno type and is used in generic Uno interfaces. + +oUnoValue = CreateUnoValue( "[]byte", MyBasicValue ) ' to get a byte sequence. +If CreateUnoValue cannot be converted to the specified Uno type, and error occurs. For the conversion, the com.sun.star.script.Converter service is used. +This function is intended for use in situations where the default Basic to Uno type converting mechanism is insufficient. This can happen when you try to access generic Any based interfaces, such as XPropertySet::setPropertyValue( Name, Value ) or X???Container::insertBy???( ???, Value ), from $[officename] Basic. The Basic runtime does not recognize these types as they are only defined in the corresponding service. +In this type of situation, $[officename] Basic chooses the best matching type for the Basic type that you want to convert. However, if the wrong type is selected, an error occurs. You use the CreateUnoValue() function to create a value for the unknown Uno type. +You can also use this function to pass non-Any values, but this is not recommend. If Basic already knows the target type, using the CreateUnoValue() function will only lead to additional converting operations that slow down the Basic execution. + +
diff --git a/helpcontent2/source/text/sbasic/shared/03132400.xhp b/helpcontent2/source/text/sbasic/shared/03132400.xhp new file mode 100644 index 000000000..665fe359d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03132400.xhp @@ -0,0 +1,59 @@ + + + + + + + CreateObject Function + /text/sbasic/shared/03132400.xhp + + + +
+ + CreateObject function + +

CreateObject Function

+ Creates a UNO object. On Windows, can also create OLE objects.see i70942 + This method creates instances of the type that is passed as parameter. +
+ + + oObj = CreateObject(type) + + + type: the type of the object to be created, as a string. + + + Type address + Name1 As String + City As String + End Type + + Sub main + myaddress = CreateObject("address") + MsgBox IsObject(myaddress) + End Sub + + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03132500.xhp b/helpcontent2/source/text/sbasic/shared/03132500.xhp new file mode 100644 index 000000000..f67ad0589 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03132500.xhp @@ -0,0 +1,41 @@ + + + + + + + + +GetDefaultContext Function +/text/sbasic/shared/03132500.xhp + + +GetDefaultContext function + + + +
+GetDefaultContext function + +GetDefaultContext Function +Returns the default context of the process service factory, if existent, else returns a null reference. +
+This function returns the default component context to be used, if instantiating services via XmultiServiceFactory. See the Professional UNO chapter in the Developer's Guide on api.libreoffice.org for more information. + +
diff --git a/helpcontent2/source/text/sbasic/shared/03140000.xhp b/helpcontent2/source/text/sbasic/shared/03140000.xhp new file mode 100644 index 000000000..2b7426f53 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140000.xhp @@ -0,0 +1,71 @@ + + + + + + + DDB Function [VBA] + /text/sbasic/shared/03140000.xhp + + + + + + +
+ + DDB function + + + +DDB Function [VBA] +Returns the depreciation of an asset for a specified period using the arithmetic-declining method. +
+ + + +DDB(Cost As Double, Salvage As Double, Life as Double, Period as Double, [Factor as Variant]) + + +Double + +Cost fixes the initial cost of an asset. +Salvage fixes the value of an asset at the end of its life. +Life is the number of periods (for example, years or months) defining how long the asset is to be used. +Period states the period for which the value is to be calculated. +Factor (optional) is the factor by which depreciation decreases. If a value is not entered, the default is factor 2. +Use this form of depreciation if you require a higher initial depreciation value as opposed to linear depreciation. The depreciation value gets less with each period and is usually used for assets whose value loss is higher shortly after purchase (for example, vehicles, computers). Please note that the book value will never reach zero under this calculation type. + + + + +Sub ExampleDDB + Dim ddb_yr1 As Double + ddb_yr1 = DDB(75000,1,60,12,2) + Print ddb_yr1 ' returns 1,721.81 currency units. +End Sub + + +
+DDB function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03140001.xhp b/helpcontent2/source/text/sbasic/shared/03140001.xhp new file mode 100644 index 000000000..1731bcc97 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140001.xhp @@ -0,0 +1,72 @@ + + + + + + + FV Function [VBA] + /text/sbasic/shared/03140001.xhp + + + + + + +
+ + FV function + + + +FV Function [VBA] +Returns the future value of an investment based on periodic, constant payments and a constant interest rate (Future Value). +
+ + + +FV(Rate as Double, NPer as Double, Pmt as Double, [PV as Variant], [Due as Variant]) + + +Double + +Rate is the periodic interest rate. +NPer is the total number of periods (payment period). +Pmt is the annuity paid regularly per period. +PV (optional) is the (present) cash value of an investment. +Due (optional) defines whether the payment is due at the beginning or the end of a period. +0 - the payment is due at the end of the period; +1 - the payment is due at the beginning of the period. + + + + +Sub ExampleFV + Dim myFV As Double + myFV = =FV(0.04, 2, 750, 2500) + Print myFV ' returns 4234.00 currency units. The value at the end of the investment is 4234.00 currency units. +End Sub + + +
+FV function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03140002.xhp b/helpcontent2/source/text/sbasic/shared/03140002.xhp new file mode 100644 index 000000000..9b47710a9 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140002.xhp @@ -0,0 +1,73 @@ + + + + + + + IPmt Function [VBA] + /text/sbasic/shared/03140002.xhp + + + + + + +
+ + IPmt function + + + +IPmt Function [VBA] +Calculates the periodic amortizement for an investment with regular payments and a constant interest rate. +
+ + + +IPmt(Rate as Double, Per as Double, NPer as Double, PV as Double, [FV as Variant], [Due as Variant]) + + +Double + +Rate is the periodic interest rate. +Per is the period, for which the compound interest is calculated. Period=NPER if compound interest for the last period is calculated. +NPer is the total number of periods, during which annuity is paid. +PV is the present cash value in sequence of payments. +FV (optional) is the desired value (future value) at the end of the periods. +Due (optional) is the due date for the periodic payments. +0 - the payment is due at the end of the period; +1 - the payment is due at the beginning of the period. + + + + +Sub ExampleIPmt + Dim myIPmt As Double + myIPmt = IPmt(0.05,5,7,15000) + Print myIPmt ' returns -352.97 currency units. The compound interest during the fifth period (year) is 352.97 currency units. +End Sub + + +
+IPMT function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03140003.xhp b/helpcontent2/source/text/sbasic/shared/03140003.xhp new file mode 100644 index 000000000..8b1707e22 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140003.xhp @@ -0,0 +1,73 @@ + + + + + + + IRR Function [VBA] + /text/sbasic/shared/03140003.xhp + + + + + + +
+ + IRR function + + + +IRR Function [VBA] +Calculates the internal rate of return for an investment. +
+ + + +IRR(Values() as Double , [Guess as Variant]) + + +Double + +Values(): The array of values of the cash-flow. The values represent cash flow values at regular intervals, at least one value must be negative (payments), and at least one value must be positive (income). +Guess An initial estimate at what the IRR will be. + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExampleIRR + Dim cashFlow(0 to 3) As Double + cashFlow(0) = -10000 + cashFlow(1) = 3500 + cashFlow(2) = 7600 + cashFlow(3) = 1000 + irrValue = IRR(cashFlow) * 100 + Print irrValue ' returns 11.3321028236252 . The internal rate of return of the cash flow. +End Sub + + +
+IRR function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03140004.xhp b/helpcontent2/source/text/sbasic/shared/03140004.xhp new file mode 100644 index 000000000..18d65dd5a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140004.xhp @@ -0,0 +1,74 @@ + + + + + + + MIRR Function [VBA] + /text/sbasic/shared/03140004.xhp + + + + + + +
+ + MIRR function + + + +MIRR Function [VBA] +Calculates the modified internal rate of return of a series of investments. +
+ + + +MIRR(Values() as Double, Investment as Double, ReinvestRate as Double) + + +Double + +Values(): An array of cash flows, representing a series of payments and income, where negative values are treated as payments and positive values are treated as income. This array must contain at least one negative and at least one positive value. +Investment: is the rate of interest of the investments (the negative values of the array). +ReinvestRate: the rate of interest of the reinvestment (the positive values of the array). + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExampleMIRR + Dim cashFlow(0 to 3) As Double + cashFlow(0) = -5 + cashFlow(1) = 10 + cashFlow(2) = 15 + cashFlow(3) = 8 + mirrValue = MIRR(cashFlow,0.5,0.1) * 100 + Print mirrValue ' returns 94.16. The modified internal rate of return of the cash flow. +End Sub + + +
+MIRR function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03140005.xhp b/helpcontent2/source/text/sbasic/shared/03140005.xhp new file mode 100644 index 000000000..488d46ec9 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140005.xhp @@ -0,0 +1,74 @@ + + + + + + + NPer Function [VBA] + /text/sbasic/shared/03140005.xhp + + + + + + +
+ + NPer function + + + +NPer Function [VBA] +Calculates the number of periods for a loan or investment. +
+ + + +NPer (Rate as Double, Pmt as Double, PV as Double, [FV as Variant], [Due as Variant]) + + +Double + +Rate is the periodic interest rate. +Pmt is the annuity paid regularly per period. +PV is the (present) cash value of an investment. +FV (optional) is the future value of the loan / investment. +Due (optional) defines whether the payment is due at the beginning or the end of a period. +0 - the payment is due at the end of the period; +1 - the payment is due at the beginning of the period. + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExampleNPer + Dim period As Double + period = NPer( 0.06, 153.75, 2600) + Print period ' returns -12,02. The payment period covers 12.02 periods. +End Sub + + +
+NPER function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03140006.xhp b/helpcontent2/source/text/sbasic/shared/03140006.xhp new file mode 100644 index 000000000..94b4b9bbd --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140006.xhp @@ -0,0 +1,77 @@ + + + + + + + NPV Function [VBA] + /text/sbasic/shared/03140006.xhp + + + + + + +
+ + NPV function + + + +NPV Function [VBA] +Calculates the Net Present Value of an investment, based on a supplied discount rate, and a series of deposits and withdrawals. +
+ + + +NPV (Rate as Double, Values() as Double) + + +Double + +Rate is the discount rate for a period. +Values() is an array that represent deposits (positive values) or withdrawals (negative values). + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExampleNPV + Dim r As Double + Dim pValues(5) as Double + pValues(0) = 100 + pValues(1) = 100 + pValues(2) = 100 + pValues(3) = -300 + pValues(4) = 100 + pValues(5) = 100 + r = 0.06 + p = NPV( r, pValues) + Print p ' returns 174,894967305331 +End Sub + + +
+NPV function in CALC + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03140007.xhp b/helpcontent2/source/text/sbasic/shared/03140007.xhp new file mode 100644 index 000000000..9d2e7001e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140007.xhp @@ -0,0 +1,76 @@ + + + + + + + Pmt Function [VBA] + /text/sbasic/shared/03140007.xhp + + + + + + +
+ + Pmt function + + + +Pmt Function [VBA] +Calculates the constant periodic payments for a loan or investment. +
+ + + +Pmt( Rate as Double, NPer as Double , PV as Double , [FV as Variant], [Due as Variant] ) + + +Double + +Rate is the periodic interest rate. +NPer is the total number of periods, during which annuity is paid. +PV is the (present) cash value of an investment. +FV (optional) is the future value of the loan / investment. +Due (optional) defines whether the payment is due at the beginning or the end of a period. +0 - the payment is due at the end of the period; +1 - the payment is due at the beginning of the period. + + + + +REM ***** BASIC ***** +Option VBASUPPORT 1 +' Calculate the monthly payments to a loan that is to be paid in full over 6 years. +' Interest is 10% per year and payments are made at the end of the month. +Sub ExamplePmt + Dim myPmt As Double + myPmt = Pmt( 0.1/12, 72, 100000 ) + print MyPmt 'is calculated to be -1852,58377757705 +End Sub + + +
+PMT function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03140008.xhp b/helpcontent2/source/text/sbasic/shared/03140008.xhp new file mode 100644 index 000000000..c9694aa3e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140008.xhp @@ -0,0 +1,82 @@ + + + + + + + PPmt Function [VBA] + /text/sbasic/shared/03140008.xhp + + + + + + +
+ + PPmt function + + + +PPmt Function [VBA] +Returns for a given period the payment on the principal for an investment that is based on periodic and constant payments and a constant interest rate. +
+ + + +Pmt( Rate as Double, Per as Double, NPer as Double, PV as Double, [FV as Variant], [Due as Variant] ) + + +Double + +Rate is the periodic interest rate. +Per The period number for which you want to calculate the principal payment (must be an integer between 1 and Nper). +NPer is the total number of periods, during which annuity is paid. +PV is the (present) cash value of an investment. +FV (optional) is the future value of the loan / investment. +Due (optional) defines whether the payment is due at the beginning or the end of a period. +0 - the payment is due at the end of the period; +1 - the payment is due at the beginning of the period. + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExamplePPmt +' Calculate the principal payments during months 4 & 5, for a loan that is to be paid in full +' over 6 years. Interest is 10% per year and payments are made at the end of the month. +Dim ppMth4 As Double +Dim ppMth5 As Double +' Principal payment during month 4: +ppMth4 = PPmt( 0.1/12, 4, 72, 100000 ) +print ppMth4 ' ppMth4 is calculated to be -1044,94463903636. +' Principal payment during month 5: +ppMth5 = PPmt( 0.1/12, 5, 72, 100000 ) +print ppMth5' ppMth5 is calculated to be -1053,65251102833. +End Sub + + +
+PPMT function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03140009.xhp b/helpcontent2/source/text/sbasic/shared/03140009.xhp new file mode 100644 index 000000000..2e8620daa --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140009.xhp @@ -0,0 +1,76 @@ + + + + + + + PV Function [VBA] + /text/sbasic/shared/03140009.xhp + + + + + + +
+ + PV function + + + +PV Function [VBA] +Returns the Present Value of an investment resulting from a series of regular payments. +
+ + + +Pmt( Rate as Double, NPer as Double, Pmt as Double, [FV as Variant], [Due as Variant] ) + + +Double + +Rate is the periodic interest rate. +NPer is the total number of periods, during which annuity is paid. +Pmt is the regular payment made per period. +FV (optional) is the future value of the loan / investment. +Due (optional) defines whether the payment is due at the beginning or the end of a period. +0 - the payment is due at the end of the period; +1 - the payment is due at the beginning of the period. + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExamplePV +' Calculate the present value of an annuity that pays $1,000 per month over 6 years. +' Interest is 10% per year and each payment is made at the end of the month. +Dim pv1 As Double +pv1 = PV( 0.1/12, 72, -1000 ) +print pv1 ' pv1 is calculated to be 53978,6654781073. +End Sub + + +
+PV function in CALC + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03140010.xhp b/helpcontent2/source/text/sbasic/shared/03140010.xhp new file mode 100644 index 000000000..f76bf540e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140010.xhp @@ -0,0 +1,77 @@ + + + + + + + Rate Function [VBA] + /text/sbasic/shared/03140010.xhp + + + + + + +
+ + Rate function + + + +Rate Function [VBA] +Returns the interest rate of a loan or an investment. +
+ + + +Rate( NPer as Double, Pmt as Double, PV as Double [FV as Variant], [Due as Variant], [Guess as Variant] ) + + +Double + +NPer is the total number of periods, during which annuity is paid. +Pmt is the regular payment made per period. +PV is the present value of the loan / investment. +FV (optional) is the future value of the loan / investment. +Due (optional) defines whether the payment is due at the beginning or the end of a period. +0 - the payment is due at the end of the period; +1 - the payment is due at the beginning of the period. +Guess(optional) determines the estimated value of the interest with iterative calculation. + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExampleRate +' Calculate the interest rate required to pay off a loan of $100,000 over +' 6 years, with payments of $1,500, due at the end of each month. + Dim mRate As Double + mRate = Rate( 72, -1500, 100000 ) + print mRate' mRate is calculated to be 0.00213778025343334 +End sub + + +
+RATE function in CALC + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03140011.xhp b/helpcontent2/source/text/sbasic/shared/03140011.xhp new file mode 100644 index 000000000..6864384ba --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140011.xhp @@ -0,0 +1,72 @@ + + + + + + + SLN Function [VBA] + /text/sbasic/shared/03140011.xhp + + + + + + +
+ + SLN function + + + +SLN Function [VBA] +Returns the straight-line depreciation of an asset for one period. The amount of the depreciation is constant during the depreciation period. +
+ + + +SLN (Cost as Double, Salvage as Double, Life as Double) + + +Double + +Cost is the initial cost of an asset. +Salvage is the value of an asset at the end of the depreciation. +Life is the depreciation period determining the number of periods in the depreciation of the asset. + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExampleSLN +REM Calculate the yearly depreciation of an asset that cost $10,000 at +REM the start of year 1, and has a salvage value of $1,000 after 5 years. +Dim y_dep As Double +y_dep = SLN( 10000, 1000, 6 ) +print y_dep ' returns 1500. +End Sub + + +
+SLN function in CALC + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03140012.xhp b/helpcontent2/source/text/sbasic/shared/03140012.xhp new file mode 100644 index 000000000..9ad42e26b --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03140012.xhp @@ -0,0 +1,74 @@ + + + + + + + SYD Function [VBA] + /text/sbasic/shared/03140012.xhp + + + + + + +
+ + SYD function + + + +SYD Function [VBA] +Returns the arithmetic-declining depreciation rate. +
+ + + +SYD (Cost as Double, Salvage as Double, Life as Double, Period as Double) + + +Double + +Cost is the initial cost of an asset. +Salvage is the value of an asset at the end of the depreciation. +Life is the depreciation period determining the number of periods in the depreciation of the asset. +Period is the period number for which you want to calculate the depreciation. + + + + +REM ***** BASIC ***** +Option VBASupport 1 +Sub ExampleSYD +REM Calculate the yearly depreciation of an asset that cost $10,000 at +REM the start of year 1, and has a salvage value of $1,000 after 5 years. +Dim syd_yr1 As Double +REM Calculate the depreciation during year 1. +syd_yr1 = SYD( 10000, 1000, 5, 1 ) +print syd_yr1 ' syd_yr1 is now equal to 3000. +End Sub + + +
+SYD function in CALC + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/03150000.xhp b/helpcontent2/source/text/sbasic/shared/03150000.xhp new file mode 100644 index 000000000..01ed09073 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03150000.xhp @@ -0,0 +1,142 @@ + + + + + + + FormatDateTime Function [VBA] + /text/sbasic/shared/03150000.xhp + + + + + +
+ + FormatDateTime function + + + FormatDateTime Function [VBA] + Applies a date and/or time format to a date expression and returns the result as a string. +
+ + + + FormatDateTime (DateExpression as Date [, NamedFormat as Integer]) + + + String + + DateExpression: The date expression to be formatted. + NamedFormat: An optional vbDateTimeFormat enumeration specifying the format that is to be applied to the date and time expression. If omitted, the value vbGeneralDate is used. + Date and Time formats (vbDateTimeFormat enumeration) +
+ + + + Named Constant + + + Value + + + Description + + + + + vbGeneralDate + + + 0 + + + Displays a date and/or time as defined in your system's General Date setting. If a date only, no time is displayed; If a time only, no date is displayed. + + + + + vbLongDate + + + 1 + + + Display a date using the long date format specified in your computer's regional settings. + + + + + vbShortDate + + + 2 + + + Display a date using the short date format specified in your computer's regional settings. + + + + + vbLongTime + + + 3 + + + Displays a time as defined in your system's Long Time settings. + + + + + vbShortTime + + + 4 + + + Display a time using the 24-hour format (hh:mm). + + +
+
+ + + + + + REM ***** BASIC ***** + Option VBASupport 1 + Sub DateFormat + Dim d as Date + d = ("1958-01-29 00:25") + msgbox("General date format : " & FormatDateTime(d)) + msgbox("Long date format : " & FormatDateTime(d,vbLongDate)) + msgbox("Short date format : " & FormatDateTime(d,vbShortDate)) + msgbox("Long time format : " & FormatDateTime(d,3)) + msgbox("Short time format : " & FormatDateTime(d,vbShortTime)) + End Sub + + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03150001.xhp b/helpcontent2/source/text/sbasic/shared/03150001.xhp new file mode 100644 index 000000000..d3e0e20c8 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03150001.xhp @@ -0,0 +1,173 @@ + + + + + + + WeekdayName Function [VBA] + /text/sbasic/shared/03150001.xhp + + + + + + +
+ + WeekdayName function + + + WeekdayName Function [VBA] + The WeekdayName function returns the weekday name of a specified day of the week. +
+ + + + WeekdayName(Weekday as Integer [,Abbreviate as Boolean [,FirstDayofWeek as Integer]]) + + + String + + Weekday: Value from 1 to 7, Mon­day to Sun­day, whose Week Day Name need to be calculated. + Abbreviate: Optional. A Boolean value that indicates if the weekday name is to be abbreviated. + FirstDayofWeek: Optional. Specifies the first day of the week. + First day of Week: + + + + Named constant + + + Value + + + Description + + + + + vbUseSystemDayOfWeek + + + 0 + + + Use National Language Support (NLS) API setting + + + + + vbSun­day + + + 1 + + + Sun­day (default) + + + + + vbMonday + + + 2 + + + Monday + + + + + vbTuesday + + + 3 + + + Tuesday + + + + + vbWednesday + + + 4 + + + Wednesday + + + + + vbThursday + + + 5 + + + Thursday + + + + + vbFriday + + + 6 + + + Friday + + + + + vbSaturday + + + 7 + + + Saturday + + +
+ + + + None + + + REM ***** BASIC ***** + Option VBASupport 1 + Sub Example_WeekdayName + Dim tgf as Integer + tgf = 6 + print tgf &" "& WeekdayName(tgf,False,vbSunday) + End Sub + + +
+ + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03150002.xhp b/helpcontent2/source/text/sbasic/shared/03150002.xhp new file mode 100644 index 000000000..5516ab45c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03150002.xhp @@ -0,0 +1,66 @@ + + + + + + + MonthName Function [VBA] + /text/sbasic/shared/03150002.xhp + + + + +
+ + MonthName function + + + MonthName Function [VBA] + The MonthName function returns the localized month name of a specified month number. +
+ + + + MonthName(Month as Integer [,Abbreviate as Boolean]) + + + String + + Month: Value from 1 to 12, January to December, whose localized month name need to be returned. + Abbreviate: Optional. A Boolean value that indicates if the month name is to be abbreviated. + + + + + + REM ***** BASIC ***** + Option VBASupport 1 + Sub Example_MonthName + Dim mBirthday as Integer + mBirthday = 1 + print mBirthday &" "& MonthName(mBirthday,False) + End Sub + + +
+ +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03160000.xhp b/helpcontent2/source/text/sbasic/shared/03160000.xhp new file mode 100644 index 000000000..aa429b151 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03160000.xhp @@ -0,0 +1,73 @@ + + + + + + + Input Function [VBA] + /text/sbasic/shared/03160000.xhp + + + + +
+ + Input function + +

Input Function [VBA]

+ Returns the open stream of an Input or Binary file (String). +
+ + + + Input( Number as Integer, [# ] FileNumber as Integer) + + + String + + Number: Required. Numeric expression specifying the number of characters to return. + #: Optional. + FileNumber: Required. Any valid file number. + + + + + + + + REM ***** BASIC ***** + Option VBASupport 1 + Sub Example_Input + Dim MyData + Open "MyDataFile.txt" For Input As #1 + Do While Not EOF(1) + MyData = Input(1, #1) + Print MyData + Loop + Close #1 + End Sub + + +
+ + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/03170000.xhp b/helpcontent2/source/text/sbasic/shared/03170000.xhp new file mode 100644 index 000000000..7f5d824fb --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03170000.xhp @@ -0,0 +1,84 @@ + + + + + + + Round Function [VBA] + /text/sbasic/shared/03170000.xhp + + + + +
+ + Round function (VBA) + +

Round Function [VBA]

+ Rounds a numeric value to a specified number of decimal digits. +
+ + This function implements the rounding rule known as "round-to-even". With this rule, whenever the difference between the number to be rounded and its nearest integer is equal to 0.5, the number is rounded to the nearest even number. See the examples below to learn more about this rule. + Beware that VBA's Round function works differently than %PRODUCTNAME Calc's Round function. In Calc, if the difference between the number to be rounded and the nearest integer is exactly 0.5, then the number is rounded up. Hence, in Calc the number 2.5 is rounded to 3 whereas using VBA's Round function the value 2.5 is rounded to 2 due to the "round-to-even" rule. + + + Round(expression [,numdecimalplaces]) + + + Double + + expression: The numeric expression to be rounded. + numdecimalplaces: Optional argument that specifies the number of decimal digits in the resulting rounded value. The default value is 0. + + + + + Option VBASupport 1 + Sub Example_Round + Dim r + r = Pi + print r ' 3,14159265358979 + print Round(r, 5) ' 3,14159 + r = exp(1) + print r ' 2,71828182845904 + print Round(r) ' 3 + End Sub + +
+ The following examples illustrate the "round-to-even" rule: +
+ + ' Rounding to the nearest integer (decimalplaces = 0) + MsgBox Round(3.5) ' 4 + MsgBox Round(4.5) ' 4 + MsgBox Round(5.5) ' 6 + MsgBox Round(6.5) ' 6 + ' Rounding with 2 decimal digits (decimalplaces = 2) + MsgBox Round(1.555, 2) ' 1.56 + MsgBox Round(1.565, 2) ' 1.56 + MsgBox Round(1.575, 2) ' 1.58 + MsgBox Round(1.585, 2) ' 1.58 + + +
+ Calc ROUND function + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/03170010.xhp b/helpcontent2/source/text/sbasic/shared/03170010.xhp new file mode 100644 index 000000000..2202cd123 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03170010.xhp @@ -0,0 +1,118 @@ + + + + + + + FormatNumber Function [VBA] + /text/sbasic/shared/03170010.xhp + + + +
+ + + FormatNumber function + + FormatNumber [VBA] + Returns a string with a number formatting applied to a numeric expression. +
+ + + FormatNumber( expression, numDigitsAfterDecimal as Integer, includeLeadingDigit as Integer,
useParensForNegativeNumbers as Integer, groupDigits as Integer )
+ + String + + + + expression: Required. The numeric expression to be formatted. + + numDigitsAfterDecimal: Optional. A numeric value specifying the number of digits that should be displayed after the decimal. If omitted, it defaults to the value -1, meaning that the default settings for user interface locale should be used. + + includeLeadingDigit: Optional. A vbTriState enumeration value, specifying whether a leading zero should be displayed for fractional values. + + + + vbTrue or -1: Display a leading zero. + + + vbFalse or 0: Do not display leading zeros. + + + vbUseDefaults or -2: Use the user interface locale settings. This is the default when omitted. + + + useParensForNegativeNumbers: Optional. A vbTriState enumeration value specifying whether negative numbers should be encased in parenthesis. + + + vbTrue or -1: Use parenthesis for negative numbers. + + + vbFalse or 0: Do not display parenthesis. + + + vbUseDefaults or -2: Same as vbFalse. This is the default when omitted. + + + + groupDigits: Optional. A vbTriState enumeration value specifying the number should be grouped (into thousands, etc.), using the group delimiter that is specified on the system's regional settings. + + + + vbTrue or -1: Group digits. + + + vbFalse or 0: Do not group digits. + + + vbUseDefaults or -2: Same as vbFalse. This is the default when omitted. + + + + + + + Sub TestFormatNumber + testName = "Test 1: positive, 2 decimals" + str2 = "12.20" + str1 = FormatNumber("12.2", 2, vbFalse, vbFalse, vbFalse) + msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2) + + testName = "Test 2: negative, 20 decimals, use leading zero" + str2 = "-0.20000000000000000000" + str1 = FormatNumber("-.2", 20, vbTrue, vbFalse, vbFalse) + msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2) + + testName = "Test 3: negative, 20 decimals, no leading zero" + str2 = "-.20000000000000000000" + str1 = FormatNumber("-0.2", 20, vbFalse, vbFalse, vbFalse) + msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2) + + testName = "Test 4: negative, no leading zero, use parens" + str2 = "(.20)" + str1 = FormatNumber("-0.2", -1, vbFalse, vbTrue, vbFalse) + msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2) + + testName = "Test 5: negative, default leading zero, use parens" + str2 = "(0.20)" + str1 = FormatNumber("-0.2", -1, vbUseDefault, vbTrue, vbFalse) + msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2) + + testName = "Test 6: group digits" + str2 = "-12,345,678.00" + str1 = FormatNumber("-12345678", -1, vbUseDefault, vbUseDefault, vbTrue) + msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2) + End Sub + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/05060700.xhp b/helpcontent2/source/text/sbasic/shared/05060700.xhp new file mode 100644 index 000000000..f785cc03a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/05060700.xhp @@ -0,0 +1,372 @@ + + + + + + + + +Macro +/text/sbasic/shared/05060700.xhp + + +Sun Microsystems, Inc. + + + +
+events;linked to objects + +Macro +Choose the macro that you want to execute when the selected graphic, frame, or OLE object is selected. Depending on the object that is selected, the function is either found on the Macro tab of the Object dialog, or in the Assign Macro dialog. +
+Event +Lists the events that are relevant to the macros that are currently assigned to the selected object. +The following table describes the macros and the events that can by linked to objects in your document: + + + +Event + + +Event trigger + + +OLE object + + +Graphics + + +Frame + + +AutoText + + +ImageMap area + + +Hyperlink + + + + +Click object + + +Object is selected. + + + + + + + + + + + + + + + + + + + +Mouse over object + + +Mouse moves over the object. + + + + + + + + + + + + + + + + + + + + + +Trigger Hyperlink + + +Hyperlink assigned to the object is clicked. + + + + + + + + + + + + + + + + + + + + +Mouse leaves object + + +Mouse moves off of the object. + + + + + + + + + + + + + + + + + + + + + +Graphics load successful + + +Graphics are loaded successfully. + + + + + + + + + + + + + + + + + +Graphics load terminated + + +Loading of graphics is stopped by the user (for example, when downloading the page). + + + + + + + + + + + + + + + + + +Graphics load faulty + + +Graphics not successfully loaded, for example, if a graphic was not found. + + + + + + + + + + + + + + + + + +Input of alpha characters + + +Text is entered from the keyboard. + + + + + + + + + + + + + + + + + +Input of non-alpha characters + + +Nonprinting characters are entered from the keyboard, for example, tabs and line breaks. + + + + + + + + + + + + + + + + + +Resize frame + + +Frame is resized with the mouse. + + + + + + + + + + + + + + + + + +Move frame + + +Frame is moved with the mouse. + + + + + + + + + + + + + + + + + +Before inserting AutoText + + +Before a text block is inserted. + + + + + + + + + + + + + + + + + +After inserting AutoText + + +After a text block is inserted. + + + + + + + + + + + + + + + +
+ +Macros +Choose the macro that you want to execute when the selected event occurs. +Frames allow you to link events to a function, so that the function can determine if it processes the event or $[officename] Writer. +Category +Lists the open $[officename] documents and applications. Click the name of the location where you want to save the macros. +Macro name +Lists the available macros. Click the macro that you want to assign to the selected object. +Assign +Assigns the selected macro to the specified event. The assigned macro's entries are set after the event. +Remove +Removes the macro that is assigned to the selected item. + +Macro selection +Select the macro that you want to assign. + +
diff --git a/helpcontent2/source/text/sbasic/shared/CallByName.xhp b/helpcontent2/source/text/sbasic/shared/CallByName.xhp new file mode 100644 index 000000000..1933be217 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/CallByName.xhp @@ -0,0 +1,125 @@ + + + + + + + CallByName Function + /text/sbasic/shared/CallByName.xhp + + + + + +
+

CallByName Function

+Invokes a subroutine by its string name. +
+ + CallByName function + API;OfficeFilePicker + + + + + CallByName(object As Object, ProcName As String, CallType As Integer [,arg0 [,arg1 …]]) + + + +result: An optional variable that contains the result of the called method or property. + + +object: A Basic module, ClassModule instance or UNO service holding properties or methods. +ProcName: The Function, Sub or Property that is being called. +CallType: The type of performed action such as Get, Let, Method and Set. +arg0, arg1 …: The Function optional parameters given as positional arguments. +Arguments are provided in the exact same order defined in the method signature. Keyword arguments are not possible. + + + Value + CallType Description + + + 1 + Method: Calls a procedure as a function or a subroutine. + + + 2 + Get: Reads a property or variable content. + + + 4 + Let: Assigns a content to a Property or variable. + + + 8 + Set: Assigns a reference value to an Object or Variant variable. + +
+ + + + + A Calc.Maths module contains a Multiply function expecting a varying list of numbers. + + + ScriptForge.Platform.Architecture information is retrieved. + + + DisplayDirectory property of com.sun.star.ui.dialogs.FilePicker UNO service is set to the user home folder, its content is read twice. + + + + Sub CallByName_example + Const _Method = 1, _Get = 2, _Let = 4, _Set = 8 + + BasicLibraries.loadLibrary("Calc") ' Calc.Maths user library.module + Dim cm As Object : cm = Calc.Maths + MsgBox CallByName(cm, "Multiply", _Method, 3, 45, 1, 89) ' 12015 + MsgBox CallByName(cm, "Multiply", _Method, 1.85e15, 44, 10^8) ' 8.14E+24 + + GlobalScope.BasicLibraries.loadLibrary("ScriptForge") + Dim p As Object : p = CreateScriptService("ScriptForge.Platform") + MsgBox CallByName(p, "Architecture", _Get) ' 32bit/64bit + + Dim uno As Object : uno = CreateUNOService("com.sun.star.ui.dialogs.OfficeFilePicker") + Dim fs As Object : fs = CreateScriptService("ScriptForge.FileSystem") + CallByName(uno, "DisplayDirectory", _Let, fs.HomeFolder) + MsgBox CallByName(uno, "DisplayDirectory", _Get) + var = CallByName(uno, "getDisplayDirectory", _Get) + End Sub + + +

Calc.Maths module

+ + Option Compatible ' Calc.Maths module + Option Explicit + + Public Function Multiply(ParamArray args() As Double) As Variant + ''' Multiply a variable list of numbers ''' + Dim ndx As Integer + If UBound(args) >= 0 Then + Multiply = 1.0 + For ndx = 0 To UBound(args) + Multiply = Multiply * args(ndx) + Next ndx + End If + End Function 'Calc.Maths.Multiply() + + +
+ + + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/Compiler_options.xhp b/helpcontent2/source/text/sbasic/shared/Compiler_options.xhp new file mode 100644 index 000000000..675c1891c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/Compiler_options.xhp @@ -0,0 +1,49 @@ + + + + + + Compiler Options + /text/sbasic/shared/Compiler_options.xhp + + + + + Compiler Options + Runtime conditions + + +
+

Compiler Options, Runtime Conditions

+ Compiler options specified at the module level affect %PRODUCTNAME Basic compiler checks and error messages. Basic syntax as well as Basic set of instructions can be different according to the options that are in use. The less Option, the easiest and tolerant %PRODUCTNAME Basic language is. The more Option, the richer and controlled Basic language gets. +
+ Compiler options must be specified before the executable program code in a module. + + Option Statement diagram + + + + + + + +

Option Private Module

+ Specifies that the scope of the module is that of the Basic library it belongs to. + + Options specified at the module level also affect %PRODUCTNAME Basic runtime conditions. The behaviour of %PRODUCTNAME Basic instructions can differ. + +
+ Property statement + + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/ErrVBA.xhp b/helpcontent2/source/text/sbasic/shared/ErrVBA.xhp new file mode 100644 index 000000000..1badcbf05 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/ErrVBA.xhp @@ -0,0 +1,132 @@ + + + + + + Err VBA Object + /text/sbasic/shared/ErrVBA.xhp + + + +
+ + Err object + Error;raising + Error;handling + +

Err Object [VBA]

+ Use VBA Err object to raise or handle runtime errors. +
+ Err is a built-in VBA global object that allows: + + to raise predefined Basic errors + to throw user-defined exceptions + to name the routine originating the error + to describe the error and possible solutions + + + The VBA Err object has the following properties and methods: +

Properties

+ + Err.Description As String + + The Description property gives the nature of the error. Description details the various reasons that may be the cause of the error. Ideally, it provides the multiple course of actions to help solve the issue and prevent its reoccurrence. The Basic alias is the Error function for %PRODUCTNAME predefined errors. + + Err.Number As Long + + The error code associated with the error. Err object default property is Number. The %PRODUCTNAME Basic alias is the Err function. + + Err.Source As String + + Source indicates the name of the routine that produces the error. Source is an option for user-defined errors. +

Methods

+ + Err.Clear() + + Resets description, Erl, number and source properties of current error. The %PRODUCTNAME Basic alias is the Resume statement. + + Err.Raise(Number As Long, Optional source As String, Optional description As String) + + Throws user-defined errors or predefined errors. The %PRODUCTNAME Basic alias is the Error statement. +

Parameters

+ Number: A user-defined or predefined error code to be raised. +
+ Error code range 0-2000 is reserved for %PRODUCTNAME Basic. User-defined errors may start from higher values in order to prevent collision with %PRODUCTNAME Basic future developments. +
+ Source: The name of the routine raising the error. A name in the form of "myLibrary.myModule.myProc" is recommended. + Description: A description of the problem leading to stop the running process, accompanied with the various reasons that may cause it. A detailed list of the possible course of actions that may help solve the problem is recommended. + + + Option VBASupport 1 + + Sub ThrowErrors + Dim aDesc As String : aDesc = Space(80) + On Local Error GoTo AlertAndExecNext + Err.Raise(91, "ThrowErrors", Error(91)) + Err.Raise 2020, Description:="This is an intended user-defined error …" + Err.Raise(4096, "Standard.Module1.ThrowErrors", aDesc) + Exit Sub + AlertAndExecNext: + errTitle = "Error "& Err &" at line "& Erl &" in "& Err.Source + MsgBox Err.Description, MB_ICONEXCLAMATION, errTitle + Resume Next + End Sub + +

Exception ClassModule

+ A short ClassModule, that wraps VBA Err object, can distribute Err properties and methods for standard %PRODUCTNAME Basic modules. + + Option ClassModule + Option VBASupport 1 + + Public Property Get Description As String + Description = Err.Description + End Property + Public Property Get Number As Long + Number = Err.Number + End Property + Public Property Get Source As String + Source = Err.Source + End Property + Public Sub Clear + Err.Clear + End Sub + Public Sub Raise( number As Long, Optional Source As String, Optional Description As String) + Err.Raise number, Source, Description + End Sub + +

Example

+ + Function Exc As Object + Exc = New Exception + End Function + + Sub aRoutine + try: + On Local Error GoTo catch: + Exc.Raise(4096, "myLib.myModule.aRoutine", _ + "Any multi-line description for this user-defined exception") + ' your code goes here … + finally: + Exit Sub + catch: + errTitle = "Error "& Exc.Number &" at line "& Erl &" in "& Exc.Source + MsgBox Exc.Description, MB_ICONSTOP, errTitle + Resume finally + End Sub + + The Error statement or an Exception-like class module can be used interchangeably, while the latter adds extra features. +
+ + + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/GetPathSeparator.xhp b/helpcontent2/source/text/sbasic/shared/GetPathSeparator.xhp new file mode 100644 index 000000000..97b22e576 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/GetPathSeparator.xhp @@ -0,0 +1,64 @@ + + + + + + GetPathSeparator function + /text/sbasic/shared/GetPathSeparator.xhp + + + + + GetPathSeparator function + +
+ GetPathSeparator Function + Returns the operating system-dependent directory separator used to specify file paths. +
+ + GetPathSeparator() + + String + + + "\" Windows + + + "/" UNIX, including MacOS + + + + + None. + + + + + + Sub ExampleGetPathSeparator + MsgBox GetPathSeparator() + End Sub + +
+ + It is recommended to use: + + + ConvertFromURL function to convert a file URL to a system file name. + + + ConvertToURL function to convert a system file name to a file URL. + + + See also URL Notation + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/Resume.xhp b/helpcontent2/source/text/sbasic/shared/Resume.xhp new file mode 100644 index 000000000..fa9e60dcc --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/Resume.xhp @@ -0,0 +1,77 @@ + + + + + + Resume Statement + /text/sbasic/shared/Resume.xhp + + + + + Resume statement + +
+

Resume Statement

+ Resets error information and indicates what to execute next. +
+ + Resume Statement diagram + + Resume [ [0] | label | Next ] + + + 0: Resets error information and re-executes the instruction that caused the error. 0 is optional. + label: Resets error information and resumes execution at the specified label of the current subroutine. + Next: Resets error information and executes the instruction following the one that caused the error. + Error information is built with Erl, Err and Error$ functions. + + Erl: Module line number where error occurs. + Err: Error number. + Error[$]: Error description. + + Using Resume to reset error information prevents the propagation of the handled condition to calling routines. + + +

Examples:

+ Typical error handling routines are: alerting the user, fixing the error, logging error information or re-throwing custom errors that provide explanations with resolution instructions. Use Resume label when requiring such mechanisms. + + Sub Error_Handling + try: On Error GoTo catch + ' routine code goes here + Error 91 ' example error + finally: + ' routine cleanup code goes here + Exit Sub + catch: + Print Erl, Err, Error$ + Resume finally + End Sub ' Error_Handling + + Use Resume Next, for example, when reporting anomalies encountered for an iterating process that must not be interrupted. In which case multiple handling routines may be required. + + Sub Iteration + planets = Array("☿","♀","♁","♂","♃","♄","⛢","♆") + try: + On Error GoTo ReportAndProcessNext + For ndx = -3 To 11 Step 1 + MsgBox planets(ndx) + Next + On Error GoTo 0 ' Stop error catching + finally: + Exit Sub + ReportAndProcessNext: + Print "Error "& Err &" at line "& Erl &" - "& Error$ + Resume Next + End Sub ' Iteration + + Using Resume without parameters to re-execute the faulty instruction can fit certain situations. However that may cause a never ending loop. + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/calc_functions.xhp b/helpcontent2/source/text/sbasic/shared/calc_functions.xhp new file mode 100644 index 000000000..fa495681f --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/calc_functions.xhp @@ -0,0 +1,1037 @@ + + + + + + + Using Calc Functions in Macros + /text/sbasic/shared/calc_functions.xhp + + + + + calling Calc function;macros + setting Calc function;macros + macros;calling Calc function + macros;setting Calc function + createUNOservice function;calling Calc function + API;sheet.addin.Analysis + API;sheet.FunctionAccess + +

Using Calc Functions in Macros

+ In addition to the native BASIC functions, you can call Calc functions in your macros and scripts and set Calc functions in cell formulas. +

Calling Internal Calc functions in Basic

+ Use the CreateUNOService function to access the com.sun.star.sheet.FunctionAccess service. + + The example below creates a function named MyVlook that calls the VLOOKUP Calc function over a data array passed as argument and returns the value found by the function. + + Function MyVlook(Lookup, DataArray As Object, Index As Integer, SortedRangeLookup as Byte) + Dim oService As Object + Set oService = createUnoService("com.sun.star.sheet.FunctionAccess") + ' Always use the function name in English + MyVlook = oService.callFunction("VLOOKUP", Array(Lookup, DataArray, Index, SortedRangeLookup)) + End Function + + The macro below presents an example of how the MyVlook function can be called. It first creates a 5-by-2 data array and then calls the function MyVlook and shows the returned value using MsgBox. + + Sub CallingMyVlook() + ' Creates a 5 by 2 array and fills it with data + Dim myData(1 to 5, 1 to 2) as Variant + myData(1, 1) = 1 : myData(1, 2) = "Strongly disagree" + myData(2, 1) = 3 : myData(2, 2) = "Disagree" + myData(3, 1) = 5 : myData(3, 2) = "Undecided" + myData(4, 1) = 7 : myData(4, 2) = "Agree" + myData(5, 1) = 9 : myData(5, 2) = "Strongly agree" + ' Looks up the data array + Dim result as String + result = MyVlook(4, myData, 2, 1) + ' Shows the message "Disagree" + MsgBox result + End Sub + +

Setting Cell Formulas Containing Internal Calc Functions

+ Use the formula text string to add a formula to a spreadsheet cell. + All Calc functions must be expressed with their English names. + + +Sub AssignFormulaToCell +REM Add a formula to cell A1. Function name must be in English. + oCell = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("A1") + oCell.Formula = "=SUM(B1:B10)" +REM Cell A1 displays the localized function name +End Sub + + +

Calling Add-In Calc Functions in BASIC

+ The Calc Add-In functions are in the UNO services com.sun.star.sheet.addin.Analysis, com.sun.star.sheet.addin.DateFunctions and com.sun.star.sheet.addin.PricingFunctions. + + +REM Example calling Add-in function SQRTPI +Function MySQRTPI(arg as double) as double + Dim oService as Object + oService = createUNOService("com.sun.star.sheet.addin.Analysis") + MySQRTPI = oService.getSqrtPi(arg) +End Function + + +

Setting Cell Formulas with Add-In Functions

+The Add-In function must be expressed by its UNO service name. + + +Sub AssignAddInFormulaToCell +REM Add an Add-In formula to cell A1. Function name is the UNO service name. + oCell = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("A1") + oCell.Formula = "=com.sun.star.sheet.addin.Analysis.getBin2Dec(B1)" +REM Cell A1 displays the localized function name +End Sub + +
+

UNO Service Names for Analysis Add-In Functions

+The table below presents a list of all Calc Analysis Add-In functions and their respective UNO service names. + + + + Calc Function name + + + UNO service name + + + + + ACCRINT + + + com.sun.star.sheet.addin.Analysis.getAccrint + + + + + ACCRINTM + + + com.sun.star.sheet.addin.Analysis.getAccrintm + + + + + AMORDEGRC + + + com.sun.star.sheet.addin.Analysis.getAmordegrc + + + + + AMORLINC + + + com.sun.star.sheet.addin.Analysis.getAmorlinc + + + + + BESSELI + + + com.sun.star.sheet.addin.Analysis.getBesseli + + + + + BESSELJ + + + com.sun.star.sheet.addin.Analysis.getBesselj + + + + + BESSELK + + + com.sun.star.sheet.addin.Analysis.getBesselk + + + + + BESSELY + + + com.sun.star.sheet.addin.Analysis.getBessely + + + + + BIN2DEC + + + com.sun.star.sheet.addin.Analysis.getBin2Dec + + + + + BIN2HEX + + + com.sun.star.sheet.addin.Analysis.getBin2Hex + + + + + BIN2OCT + + + com.sun.star.sheet.addin.Analysis.getBin2Oct + + + + + COMPLEX + + + com.sun.star.sheet.addin.Analysis.getComplex + + + + + CONVERT + + + com.sun.star.sheet.addin.Analysis.getConvert + + + + + COUPDAYBS + + + com.sun.star.sheet.addin.Analysis.getCoupdaybs + + + + + COUPDAYS + + + com.sun.star.sheet.addin.Analysis.getCoupdays + + + + + COUPDAYSNC + + + com.sun.star.sheet.addin.Analysis.getCoupdaysnc + + + + + COUPNCD + + + com.sun.star.sheet.addin.Analysis.getCoupncd + + + + + COUPNUM + + + com.sun.star.sheet.addin.Analysis.getCoupnum + + + + + COUPPCD + + + com.sun.star.sheet.addin.Analysis.getCouppcd + + + + + CUMIPMT + + + com.sun.star.sheet.addin.Analysis.getCumipmt + + + + + CUMPRINC + + + com.sun.star.sheet.addin.Analysis.getCumprinc + + + + + DEC2BIN + + + com.sun.star.sheet.addin.Analysis.getDec2Bin + + + + + DEC2HEX + + + com.sun.star.sheet.addin.Analysis.getDec2Hex + + + + + DEC2OCT + + + com.sun.star.sheet.addin.Analysis.getDec2Oct + + + + + DELTA + + + com.sun.star.sheet.addin.Analysis.getDelta + + + + + DISC + + + com.sun.star.sheet.addin.Analysis.getDisc + + + + + DOLLARDE + + + com.sun.star.sheet.addin.Analysis.getDollarde + + + + + DOLLARFR + + + com.sun.star.sheet.addin.Analysis.getDollarfr + + + + + DURATION + + + com.sun.star.sheet.addin.Analysis.getDuration + + + + + EDATE + + + com.sun.star.sheet.addin.Analysis.getEdate + + + + + EFFECT + + + com.sun.star.sheet.addin.Analysis.getEffect + + + + + EOMONTH + + + com.sun.star.sheet.addin.Analysis.getEomonth + + + + + ERF + + + com.sun.star.sheet.addin.Analysis.getErf + + + + + ERFC + + + com.sun.star.sheet.addin.Analysis.getErfc + + + + + FACTDOUBLE + + + com.sun.star.sheet.addin.Analysis.getFactdouble + + + + + FVSCHEDULE + + + com.sun.star.sheet.addin.Analysis.getFvschedule + + + + + GCD + + + com.sun.star.sheet.addin.Analysis.getGcd + + + + + GESTEP + + + com.sun.star.sheet.addin.Analysis.getGestep + + + + + HEX2BIN + + + com.sun.star.sheet.addin.Analysis.getHex2Bin + + + + + HEX2DEC + + + com.sun.star.sheet.addin.Analysis.getHex2Dec + + + + + HEX2OCT + + + com.sun.star.sheet.addin.Analysis.getHex2Oct + + + + + IMABS + + + com.sun.star.sheet.addin.Analysis.getImabs + + + + + IMAGINARY + + + com.sun.star.sheet.addin.Analysis.getImaginary + + + + + IMARGUMENT + + + com.sun.star.sheet.addin.Analysis.getImargument + + + + + IMCONJUGATE + + + com.sun.star.sheet.addin.Analysis.getImconjugate + + + + + IMCOS + + + com.sun.star.sheet.addin.Analysis.getImcos + + + + + IMCOSH + + + com.sun.star.sheet.addin.Analysis.getImcosh + + + + + IMCOT + + + com.sun.star.sheet.addin.Analysis.getImcot + + + + + IMCSC + + + com.sun.star.sheet.addin.Analysis.getImcsc + + + + + IMCSCH + + + com.sun.star.sheet.addin.Analysis.getImcsch + + + + + IMDIV + + + com.sun.star.sheet.addin.Analysis.getImdiv + + + + + IMEXP + + + com.sun.star.sheet.addin.Analysis.getImexp + + + + + IMLN + + + com.sun.star.sheet.addin.Analysis.getImln + + + + + IMLOG10 + + + com.sun.star.sheet.addin.Analysis.getImlog10 + + + + + IMLOG2 + + + com.sun.star.sheet.addin.Analysis.getImlog2 + + + + + IMPOWER + + + com.sun.star.sheet.addin.Analysis.getImpower + + + + + IMPRODUCT + + + com.sun.star.sheet.addin.Analysis.getImproduct + + + + + IMREAL + + + com.sun.star.sheet.addin.Analysis.getImreal + + + + + IMSEC + + + com.sun.star.sheet.addin.Analysis.getImsec + + + + + IMSECH + + + com.sun.star.sheet.addin.Analysis.getImsech + + + + + IMSIN + + + com.sun.star.sheet.addin.Analysis.getImsin + + + + + IMSINH + + + com.sun.star.sheet.addin.Analysis.getImsinh + + + + + IMSQRT + + + com.sun.star.sheet.addin.Analysis.getImsqrt + + + + + IMSUB + + + com.sun.star.sheet.addin.Analysis.getImsub + + + + + IMSUM + + + com.sun.star.sheet.addin.Analysis.getImsum + + + + + IMTAN + + + com.sun.star.sheet.addin.Analysis.getImtan + + + + + INTRATE + + + com.sun.star.sheet.addin.Analysis.getIntrate + + + + + ISEVEN + + + com.sun.star.sheet.addin.Analysis.getIseven + + + + + ISODD + + + com.sun.star.sheet.addin.Analysis.getIsodd + + + + + LCM + + + com.sun.star.sheet.addin.Analysis.getLcm + + + + + MDURATION + + + com.sun.star.sheet.addin.Analysis.getMduration + + + + + MROUND + + + com.sun.star.sheet.addin.Analysis.getMround + + + + + MULTINOMIAL + + + com.sun.star.sheet.addin.Analysis.getMultinomial + + + + + NETWORKDAYS + + + com.sun.star.sheet.addin.Analysis.getNetworkdays + + + + + NOMINAL + + + com.sun.star.sheet.addin.Analysis.getNominal + + + + + OCT2BIN + + + com.sun.star.sheet.addin.Analysis.getOct2Bin + + + + + OCT2DEC + + + com.sun.star.sheet.addin.Analysis.getOct2Dec + + + + + OCT2HEX + + + com.sun.star.sheet.addin.Analysis.getOct2Hex + + + + + ODDFPRICE + + + com.sun.star.sheet.addin.Analysis.getOddfprice + + + + + ODDFYIELD + + + com.sun.star.sheet.addin.Analysis.getOddfyield + + + + + ODDLPRICE + + + com.sun.star.sheet.addin.Analysis.getOddlprice + + + + + ODDLYIELD + + + com.sun.star.sheet.addin.Analysis.getOddlyield + + + + + PRICE + + + com.sun.star.sheet.addin.Analysis.getPrice + + + + + PRICEDISC + + + com.sun.star.sheet.addin.Analysis.getPricedisc + + + + + PRICEMAT + + + com.sun.star.sheet.addin.Analysis.getPricemat + + + + + QUOTIENT + + + com.sun.star.sheet.addin.Analysis.getQuotient + + + + + RANDBETWEEN + + + com.sun.star.sheet.addin.Analysis.getRandbetween + + + + + RECEIVED + + + com.sun.star.sheet.addin.Analysis.getReceived + + + + + SERIESSUM + + + com.sun.star.sheet.addin.Analysis.getSeriessum + + + + + SQRTPI + + + com.sun.star.sheet.addin.Analysis.getSqrtpi + + + + + TBILLEQ + + + com.sun.star.sheet.addin.Analysis.getTbilleq + + + + + TBILLPRICE + + + com.sun.star.sheet.addin.Analysis.getTbillprice + + + + + TBILLYIELD + + + com.sun.star.sheet.addin.Analysis.getTbillyield + + + + + WEEKNUM + + + com.sun.star.sheet.addin.Analysis.getWeeknum + + + + + WORKDAY + + + com.sun.star.sheet.addin.Analysis.getWorkday + + + + + XIRR + + + com.sun.star.sheet.addin.Analysis.getXirr + + + + + XNPV + + + com.sun.star.sheet.addin.Analysis.getXnpv + + + + + YEARFRAC + + + com.sun.star.sheet.addin.Analysis.getYearfrac + + + + + YIELD + + + com.sun.star.sheet.addin.Analysis.getYield + + + + + YIELDDISC + + + com.sun.star.sheet.addin.Analysis.getYielddisc + + + + + YIELDMAT + + + com.sun.star.sheet.addin.Analysis.getYieldmat + + +
+
+
+

UNO Service Names for Date Add-In Functions

+The table below presents a list of all Calc Date Add-In functions and their respective UNO service names. + + + + Calc Function name + + + UNO service name + + + + + DAYSINMONTH + + + com.sun.star.sheet.addin.DateFunctions.getDaysInMonth + + + + + DAYSINYEAR + + + com.sun.star.sheet.addin.DateFunctions.getDaysInMonth + + + + + MONTHS + + + com.sun.star.sheet.addin.DateFunctions.getDiffMonths + + + + + WEEKS + + + com.sun.star.sheet.addin.DateFunctions.getDiffWeeks + + + + + YEARS + + + com.sun.star.sheet.addin.DateFunctions.getDiffYears + + + + + ROT13 + + + com.sun.star.sheet.addin.DateFunctions.getRot13 + + + + + WEEKSINYEAR + + + com.sun.star.sheet.addin.DateFunctions.getWeeksInYear + + +
+
+
+

UNO Service Names for Pricing Add-In Functions

+The table below presents a list of all Calc Pricing Add-In functions and their respective UNO service names. + + + + Calc Function name + + + UNO service name + + + + + OPT_BARRIER + + + com.sun.star.sheet.addin.PrincingFunctions.getOptBarrier + + + + + OPT_PROB_HIT + + + com.sun.star.sheet.addin.PrincingFunctions.getOptProbHit + + + + + OPT_PROB_INMONEY + + + com.sun.star.sheet.addin.PrincingFunctions.getOptProbInMoney + + + + + OPT_TOUCH + + + com.sun.star.sheet.addin.PrincingFunctions.getOptTouch + + +
+
+
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/classmodule.xhp b/helpcontent2/source/text/sbasic/shared/classmodule.xhp new file mode 100644 index 000000000..df14f9ad7 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/classmodule.xhp @@ -0,0 +1,63 @@ + + + + + + Option ClassModule + /text/sbasic/shared/classmodule.xhp + + + + + Option ClassModule + + +
+

Option ClassModule Statement

+ Specifies that the module is a class module that contains members, properties, procedures and functions. +
+ + + This statement must be used jointly with Option Compatible statement or Option VBASupport 1, the former is enabling VBA compatibility mode, while the latter is enforcing VBA support on top of compatibility. + + Option ClassModule + + + Option Compatible + Option ClassModule + + ' Optional members go here + + Private Sub Class_Initialize() + ' Optional construction code goes here + End Sub ' Constructor + Private Sub Class_Terminate() + ' Optional destruction code goes here + End Sub ' Destructor + + ' Properties go here. + + ' Procedures & functions go here. + + +
+ + Refer to Identifying the Operating System and Getting Session Information for class module simple examples. + + + Multiple thorough class examples are available from Access2Base shared Basic library. + + + + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/code-stubs.xhp b/helpcontent2/source/text/sbasic/shared/code-stubs.xhp new file mode 100644 index 000000000..53161098a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/code-stubs.xhp @@ -0,0 +1,58 @@ + + + + + + + BasicCodeStubs + /text/sbasic/shared/code-stubs.xhp + + + + +
+ + Dim aPicker As com.sun.star.ui.dialogs.XFilePicker + +
+
+ + aPicker.getDisplayDirectory() + +
+
+ + Dim intVar as Integer + +
+
+ + Sub Some_Calc_UNO_Types + REM A spreadsheet object + Dim oSheet As com.sun.star.sheet.XSpreadsheet + oSheet = ThisComponent.getSheets().getByIndex(0) + REM A cell object + Dim oCell As com.sun.star.table.XCell + oCell = oSheet.getCellByPosition(0,0) + End Sub + +
+ + +
\ No newline at end of file diff --git a/helpcontent2/source/text/sbasic/shared/collection.xhp b/helpcontent2/source/text/sbasic/shared/collection.xhp new file mode 100644 index 000000000..6652dc52d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/collection.xhp @@ -0,0 +1,191 @@ + + + + + + + Collection Object + /text/sbasic/shared/collection.xhp + + + +
+ + Collection Object + + + Collection;Count + +

Collection Object

+ Collections can be used to store items of different types. Each item can be accessed by its index or by an optional key associated with it. +
+ A Collection object has the following methods: + + + Add: inserts a new item into the collection. Optionally a string value can be defined as the key to the item. + + + Count: returns the number of items in the collection. + + + Item: returns the item in the collection by passing its index or key. + + + Remove: removes the specified item from the collection by its index or key. + + + Items in a Collection can be accessed either by their indices (as in a 1-based single-dimensional Array) or by their associated keys. + The ScriptForge Dictionary service extends the Collection object by providing supplemental features as key retrieval and replacement, as well as import/export to Array objects and JSON strings. +

Creating a Collection

+ To create a Collection use the New keyword. The following example creates a Collection object and populates it with three items: + + Dim myCollection as New Collection + myCollection.Add("Some text") + myCollection.Add(100) + myCollection.Add(Array(1, 2, 3, 4)) + MsgBox myCollection.Count ' 3 + + +

Adding Items

+ + Collection;Add + + The Add method can be used to add new items into the Collection object. + + + oCollection.Add(item, [key], [before|after]) + + + item: the item to be added to the Collection. May be of any type. + key: string value used as the unique key used to identify this value. + before, after: optional keyword argument that indicates where the new item will be placed in the Collection. Only one of the arguments before or after can be specified to determine the index or key before which (or after which) the new item is to be placed. + + The example below adds two elements into a Collection. The first has a key associated with it, whereas the second does not. + + Dim myCollection as New Collection + myCollection.Add(100, "first") + myCollection.Add(101) + + The Add method also supports keyword arguments: + + myCollection.Add(item := 100, key := "first") + + Keys must be unique in a Collection object. Comparison between keys is case-insensitive. Adding duplicated keys will result in a runtime error. + The example below illustrates how to use the Before and After keyword arguments to determine the position of the item that is being added. + + Dim myCollection as Variant + myCollection = New Collection + myCollection.Add(item := 101, key := "first") + myCollection.Add(item := 103, key := "third") + myCollection.Add(item := 105, key := "fifth") + MsgBox myCollection.Item(2) ' 103 + myCollection.Add(item := 102, key := "second", before := "third") + MsgBox myCollection.Item(2) ' 102 + myCollection.Add(item := 104, key := "fourth", after := 3) + MsgBox myCollection.Item(4) ' 104 + + Items in a Collection object are assigned an integer index value that starts at 1 and corresponds to the order in which they were added. + +

Accessing Items

+ + Collection;Item + + Use the Item method to access a given item by its index or key. + + oCollection.Item(index) + + + oCollection.Item(key) + + + index: an integer value specifying the index of the item to be returned. + key: a string value specifying the key of the item to be returned. + + + Dim myCollection as New Collection + myCollection.Add(item := 101, key := "A") + myCollection.Add(item := 102, key := "B") + myCollection.Add(item := 103, key := "C") + MsgBox myCollection.Item("A") ' 101 + MsgBox myCollection.Item(3) ' 103 + + +

Removing Items

+ + Collection;Remove + + Use the Remove method to delete items from a Collection object. + + Items can be removed either by their indices or key values. + + oCollection.Remove(index) + + + oCollection.Remove(key) + + + index: an integer value specifying the index of the item to be removed. + key: a string value specifying the key of the item to be removed. + + + Dim myCollection as New Collection + myCollection.Add(item := 101, key := "first") + myCollection.Add(item := 102, key := "second") + myCollection.Add(item := 103, key := "third") + MsgBox myCollection.Count ' 3 + ' Removes the first value + myCollection.Remove(1) + ' Removes the value whose key is "third" + myCollection.Remove("third") + MsgBox myCollection.Count ' 1 + + +

Iterating Over all Items

+ It is possible to use a For Each ... Next statement to iterate over all items in a Collection. + + Dim myCollection as New Collection + myCollection.Add(item := 101, key := "A") + myCollection.Add(item := 102, key := "B") + myCollection.Add(item := 103, key := "C") + For Each value In myCollection + MsgBox value + Next value + + +

Clearing a Collection

+ To remove all items from a Collection object call the Remove method for each item, as illustrated in the example below: + + ' Create a sample Collection with two entries + Dim myCollection as New Collection + myCollection.Add(item := 10, key := "A") + myCollection.Add(item := 11, key := "B") + MsgBox myCollection.Count ' 2 + ' Removes all items in the collection + For i = myCollection.Count To 1 Step -1 + myCollection.Remove(i) + Next i + MsgBox myCollection.Count ' 0 + + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/compatibilitymode.xhp b/helpcontent2/source/text/sbasic/shared/compatibilitymode.xhp new file mode 100644 index 000000000..f772f92c5 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/compatibilitymode.xhp @@ -0,0 +1,92 @@ + + + + + + CompatibilityMode function + /text/sbasic/shared/compatibilitymode.xhp + + + + + CompatibilityMode + VBA compatibility mode + +
+

CompatibilityMode() Function

+ CompatibilityMode() function controls or queries runtime mode. It affects all code executed after setting or resetting the runtime mode. +
+ Use this feature with caution, limit it to document conversion for example. + + + + CompatibilityMode(Optional Enable As Boolean) As Boolean + + + + CompatibilityMode function always returns the mode that is active after its execution. That is if called with argument, it returns the new mode, if called without argument, it returns active mode without modifying it. + + + Enable: Sets or unsets new compatibility mode when the argument is present. + CompatibilityMode function relates to Option VBASupport 1, in which case it always returns True. It is unrelated to Option Compatible compiler directive. + + This function may affect or help in the following situations: + + Scoping of variables. + Running RmDir command in VBA mode. In VBA only empty directories are removed by RmDir while %PRODUCTNAME Basic removes a directory recursively. + Changing behavior of Basic Dir command. The directory flag (16) for the Dir command means that only directories are returned in %PRODUCTNAME Basic, while in VBA normal files and directories are returned. + + Color components calculation with the Red and Blue functions which are interchanged (The Green function is not affected). + + + + + Given a NOT empty directory at file:///home/me/Test + + Sub RemoveDir + MsgBox CompatibilityMode() ' False + + CompatibilityMode( True ) + RmDir( "file:///home/me/Test" ) + CompatibilityMode False + + MsgBox CompatibilityMode ' False + End Sub + + With CompatibilityMode( True ) the program raises an error, otherwise the Test directory and all its content is deleted. + + Modifying Dir behavior + + Sub VBADirCommand + CompatibilityMode( Enable := True ) ' Shows also normal files + Entry$ = Dir( "file:///home/me/Tmp/*.*", 16 ) + Total$ = "" + While Entry$ <> "" + Total$ = Total$ + Entry$ + Chr$(13) + Entry$ = Dir + Wend + MsgBox Total$ + CompatibilityMode Enable := False ' Shows only directories + End Sub + + +
+ + + + Variables scope modification in Using Procedures and Functions with CompatibilityMode() function. + + + + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/compatible.xhp b/helpcontent2/source/text/sbasic/shared/compatible.xhp new file mode 100644 index 000000000..271bd2511 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/compatible.xhp @@ -0,0 +1,63 @@ + + + + + + Option Compatible + /text/sbasic/shared/compatible.xhp + + + + + Option Compatible + + +
+

Option Compatible Statement

+ Option Compatible extends %PRODUCTNAME Basic compiler and runtime, allowing supplemental language constructs to Basic. +
+ + This option may affect or assist in the following situations: + + Allow special characters as identifiers. all characters that are defined as + letter in the Latin-1 (ISO 8859-1) character set, are accepted + as part of identifiers. + Create VBA constants including non-printable characters. + Allow the New operator to be optional in Dim statements. + Allow default values for optional parameters in procedures. + Use named arguments when multiple optional parameters exist. + Preload of %PRODUCTNAME Basic libraries + + Option Compatible is required when coding class modules. + + Option Compatible + +

Special characters as identifiers

+ + Option Compatible + ' With this option the code works, otherwise it causes a compiling error + Sub Main + ä = 10 + print ä + End Sub + + Statement Option VBAsupport 1 implies Option Compatible statement automatically. +
+ + + + + + + Variables scope modification in Using Procedures and Functions with CompatibilityMode() function. + Refer to Identifying the Operating System and Getting Session Information for class module examples, or Access2Base shared Basic library for other class examples making use of Option Compatible compiler mode. +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/conventions.xhp b/helpcontent2/source/text/sbasic/shared/conventions.xhp new file mode 100644 index 000000000..974db923a --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/conventions.xhp @@ -0,0 +1,70 @@ + + + + + + Syntax Diagrams + /text/sbasic/shared/conventions.xhp + + + + + Syntax diagrams; How to read + Statements syntax;How to read + Typographical conventions + +

How to Read Syntax Diagrams and Statements

+ %PRODUCTNAME Basic statements use syntax diagrams and textual conventions that follow these typographical rules: + + %PRODUCTNAME Basic keywords or functions use proper casing: Call, DimArray, InputBox, Property. + Lowercase characters indicate information to supply: end, expression, start, variable. + + The syntax of a %PRODUCTNAME Basic one line statement is illustrated herewith: + +

Diagram example

+ + Basic statement diagrams start and end with double vertical bars, + Loops indicate a possible repetition, an optional separator may be present, + Rectangles denote subsequent diagram fragments, + Diagram fragments extremities exhibit single vertical bars. + + syntax of a statement + A set of %PRODUCTNAME Basic statements - with optional labels - is using a colon : sign to separate them, it can be terminated with an optional comment. REM or an apostrophe sign introduce a comment. + diagram fragment + +

Textual example

+
+ + [opt1|opt2|opt3] Items inside brackets are optional, alternatives are indicated with a vertical bar, + case[[sep]…] An ellipsis indicates a possible repetition, an optional separator may be specified, + {choice1|choice2} Items inside curly braces are compulsory, alternatives are indicated with a vertical bar. + +
+ + [ [label:] statement [: …] ] [{REM|'} text] + + A set of %PRODUCTNAME Basic statements - with optional labels - is using a colon : sign to separate them, it can be terminated with an optional comment. REM or an apostrophe sign introduce a comment. + + + + Sub Main
+ GoTo there ' skip first statement + here: Print 1, : there: Print 2 REM explanatory text here + End Sub +
+ +
+ + + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/enum.xhp b/helpcontent2/source/text/sbasic/shared/enum.xhp new file mode 100644 index 000000000..5781585ae --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/enum.xhp @@ -0,0 +1,70 @@ + + + + + + Enum Statement + /text/sbasic/shared/enum.xhp + + + + + Enum statement + constant groups + enumerations + +
+

Enum Statement [VBA]

+ Define enumerations or non UNO constant groups. An enumeration is a value list that facilitates programming and eases code logic review. +
+ + + + Enum syntax + + + Enum list_name
+ ' Object Statement block + End Enum ' list_name +
+

Parameters:

+ Within a given enumeration, fit together values that logically relate to one another. + + + Option VBASupport 1
+ Private Enum _WindowManager + W1ND0WS = 1 ' Windows + OS2PM = 2 ' OS/2 Presentation Manager + MACINTOSH = 3 ' Macintosh + MOTIF = 4 ' Motif Window Manager / Unix-like + OPENLOOK = 5 ' Open Look / Unix-like + End Enum + Public Function WindowManager() As Object + WindowManager = _WindowManager + End Function ' <library>.<module>.WindowManager.XXX +
+ Enumerated values are rendered to Long datatype. Basic functions are public accessors to enumerations. Enumeration names and value names must be unique within a library and across modules. + +

Usage:

+ Display WindowManager grouped constant values: + + Dim winMgr As Object : winMgr = <library>.<module>.WindowManager + With winMgr + Print .MACINTOSH, .MOTIF, .OPENLOOK, .OS2PM, .W1ND0WS + End With + + Enumerations can be extended to other data types using Type statement definitions. Calling Python Scripts from Basic illustrates that mechanism. +
+ Const statement, constants + Option VBASupport statement + With statement +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/fragments.xhp b/helpcontent2/source/text/sbasic/shared/fragments.xhp new file mode 100644 index 000000000..9da8abd51 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/fragments.xhp @@ -0,0 +1,70 @@ + + + + + + Basic syntax diagrams fragments + /text/sbasic/shared/fragments.xhp + + + +
+

Syntax fragments

+ %PRODUCTNAME Basic syntax fragments. +
+ +
+

argument fragment

+ argument fragment + + {[Optional [ByRef|ByVal]]|ParamArray} argument {{As typename|char}[ = expression]|[()]As Variant} + +

Parameters

+ Optional: The argument is not mandatory. + ByRef: The argument is passed by reference. ByRef is the default. + ByVal: The argument is passed by value. Its value can be modified by the called routine. + char: Type declaration character. + typename: Primitive data type name. Library or module defined types can also be specified. + = expression: Specify a default value for the argument, matching its declared type. Optional is necessary for each argument specifying a default value. + ParamArray: Use ParamArray when the number of parameters is undetermined. A typical scenario is that of a Calc user-defined function. Using ParamArray should be limited to the last argument of a routine. + UsingParamArray or = expression require Option Compatible to be placed before the executable program code in a module. + When using Option VBASupport 1, Optional arguments with no default value (= expression) are initialized according to their data type, except if Variant. +
+ +
+

array fragment

+ array fragment + + ( [[start To] end], .. ) + +

Parameters

+ start: Lower bound of a dimension. + end: Upper bound of a dimension. + Multiple dimensions for an array are denoted using comma (,) sign. +
+ +
+

typename fragment

+ primitive data types fragment + + {Boolean|Byte|Currency|Date|Double|Integer|Long|Object|Single|String|Variant} + +
+ +
+

char fragment

+ type declaration characters + + { % | & | ! | # | $ | @ } + +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/is_keyword.xhp b/helpcontent2/source/text/sbasic/shared/is_keyword.xhp new file mode 100644 index 000000000..0724cfe66 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/is_keyword.xhp @@ -0,0 +1,71 @@ + + + + + + + Is Operator + /text/sbasic/shared/is_keyword.xhp + + + +
+ + Is Operator + +

Is Operator

+ Tests if two Basic variables refer to the same object instance. +
+ + + result = oObj1 Is oObj2 + + If oObj1 and oObj2 are references to the same object instance, the result will be True. + + The example below first defines a new type Student. Calling TestObjects creates the object oStudent1 as a new object of this type. + The assignment oStudent2 = oStudent1 actually copies the reference to the same object. Hence the result of applying the Is operator is True. + + Type Student + FirstName as String + Program as String + End Type + + Sub TestObjects + Dim oStudent1 as new Student + Dim oStudent2 as Variant + oStudent2 = oStudent1 + MsgBox Student1 Is Student2 ' True + End Sub + + The example below returns False because oStudent1 and oStudent2 are references to two different object instances, each created with the New operator. + + Sub TestObjects_v2 + Dim oStudent1 as new Student + Dim oStudent2 as new Student + MsgBox oStudent1 Is oStudent2 ' False + End Sub + + +
+ + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/keys.xhp b/helpcontent2/source/text/sbasic/shared/keys.xhp new file mode 100644 index 000000000..5dfef6e6c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/keys.xhp @@ -0,0 +1,110 @@ + + + + + + + + +Keyboard Shortcuts in the Basic IDE +/text/sbasic/shared/keys.xhp + + +Sun Microsystems, Inc. + + + +
+keyboard;in IDE +shortcut keys;Basic IDE +IDE;keyboard shortcuts + +Keyboard Shortcuts in the Basic IDE +
+In the Basic IDE you can use the following keyboard shortcuts: + + + +Action + + +Keyboard shortcut + + + + +Run code starting from the first line, or from the current breakpoint, if the program stopped there before. + + +F5 + + + + +Stop + + +Shift+F5 + + + + +Add watch for the variable at the cursor. + + +F7 + + + + +Single step through each statement, starting at the first line or at that statement where the program execution stopped before. + + +F8 + + + + +Single step as with F8, but a function call is considered to be only one statement. + + +Shift+F8 + + + + +Set or remove a breakpoint at the current line or all breakpoints in the current selection. + + +F9 + + + + +Enable/disable the breakpoint at the current line or all breakpoints in the current selection. + + +Shift+F9 + + +
+ +A running macro can be aborted with Shift+CommandCtrl+Q, also from outside of the Basic IDE. If you are inside the Basic IDE and the macro halts at a breakpoint, Shift+CommandCtrl+Q stops execution of the macro, but you can recognize this only after the next F5, F8, or Shift+F8. + +
diff --git a/helpcontent2/source/text/sbasic/shared/main0211.xhp b/helpcontent2/source/text/sbasic/shared/main0211.xhp new file mode 100644 index 000000000..ab420627d --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/main0211.xhp @@ -0,0 +1,76 @@ + + + + + + + + +Macro Toolbar +/text/sbasic/shared/main0211.xhp + + +Sun Microsystems, Inc. + + + + + +
+ toolbars; Basic IDEmacro toolbarMacro Toolbar + The Macro Toolbar contains commands to create, edit, and run macros. +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/main0601.xhp b/helpcontent2/source/text/sbasic/shared/main0601.xhp new file mode 100644 index 000000000..569773563 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/main0601.xhp @@ -0,0 +1,79 @@ + + + + + + + $[officename] Basic Help + /text/sbasic/shared/main0601.xhp + + + + + + + +

%PRODUCTNAME Basic Help

+ +
+%PRODUCTNAME provides an Application Programming Interface (API) that allows controlling the $[officename] components with different programming languages by using the $[officename] Software Development Kit (SDK). For more information about the $[officename] API and the Software Development Kit, visit https://api.libreoffice.org +This help section explains the most common functions of %PRODUCTNAME Basic. For more in-depth information please refer to the OpenOffice.org BASIC Programming Guide on the Wiki. +
+ +Working with %PRODUCTNAME Basic + + + + + + + + + + +Working with VBA Macros + + + +

Working with Macros in Python

+ + + + + + + + +%PRODUCTNAME internal Basic macro libraries +%PRODUCTNAME installs a set of Basic macro libraries that can be accessed from your Basic macros. + + + + + + + + + + + + + + +
diff --git a/helpcontent2/source/text/sbasic/shared/new_keyword.xhp b/helpcontent2/source/text/sbasic/shared/new_keyword.xhp new file mode 100644 index 000000000..c6df340a4 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/new_keyword.xhp @@ -0,0 +1,78 @@ + + + + + + + New Operator + /text/sbasic/shared/new_keyword.xhp + + + +
+ + New Operator + +

New Operator

+ Use the New operator to instantiate objects of user-defined types, as well as Uno services, structs and enumerations. +
+ + + Dim oObj as New ObjectType + + + oObj = New ObjectType + + The New operator can be used either during variable declaration or in an assignment operation. + + The following example uses the New operator to create an instance of the PropertyValue Uno struct. + + ' Instantiating the object during variable declaration + Dim oProp1 as New com.sun.star.beans.PropertyValue + oProp1.Name = "Some name" + oProp1.Value = 100 + ' The same can be accomplished with an assignment + Dim oProp2 as Object + oProp2 = New com.sun.star.beans.PropertyValue + oProp2.Name = "Other name" + oProp2.Value = 200 + + + The example below creates a new type Student and instantiates an object of this type: + + Type Student + FirstName as String + Program as String + End Type + + Sub TestObjects + Dim oStudent1 as New Student + oStudent1.FirstName = "John" + oStudent2.Program = "Computer Science" + End Sub + + +
+ + + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/partition.xhp b/helpcontent2/source/text/sbasic/shared/partition.xhp new file mode 100644 index 000000000..617f0d806 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/partition.xhp @@ -0,0 +1,60 @@ + + + + + + + Partition Function + /text/sbasic/shared/partition.xhp + + + +
+ + Partition Function + +

Partition Function [VBA]

+ Returns a string indicating where a number occurs within a calculated series of ranges. +
+ + + Partition( Number, Start, End, Interval) + + String + + + Number: Required. The number to determine the partition. + Start: Required. An integer number defining the lower value of the range of numbers. + End: Required. An integer number defining the highest value of the range. + Interval: Required. An integer number that specifies the size of the partitions within the range of numbers (between Start and End). + + + + Option VBASupport 1 + Option Explicit + Sub Test_Partition + Dim retStr As String + retStr = Partition(20, 0, 98, 5) + print "20:24 the number 20 occurs in the range: " & retStr + retStr = Partition(20, 0, 99, 1) + print " 20: 20 the number 20 occurs in the range: " & retStr + retStr = Partition(120, 0, 99, 5) + print "100: the number 120 occurs in the range: " & retStr + retStr = Partition(-5, 0, 99, 5) + print " : -1 the number -5 occurs in the range: " & retStr + retStr = Partition(2, 0, 5, 2) + print " 2: 3 the number 2 occurs in the range: " & retStr + End Sub + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/property.xhp b/helpcontent2/source/text/sbasic/shared/property.xhp new file mode 100644 index 000000000..7a72e417e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/property.xhp @@ -0,0 +1,127 @@ + + + + + + Property Statement + /text/sbasic/shared/property.xhp + + + + + Property statement + + +

Property Statement

+ A property, also called field or attribute, characterizes a given object or piece of information. Properties can be used to control access to data. It is common use to include instructions at setting or reading time of properties. Code can vary from simple assignment to complex context dependent routines. Using Get, Let or Set accessors enforces properties' consistency when necessary. + This statement requires Option Compatible to be placed before the executable program code in a module. + + + + Property Get Statement diagram + + + [Private | Public] Property Get name[char | As typename] + End Property + + + + Property Set Statement diagram + + + [Private | Public] Property [Let | Set] name[char] [([Optional [ByRef | ByVal]]value[char | As typename])] [As typename] + End Property + + + + name: The property name. + + argument: Value to be passed to the Property setter routine. + Property setters often use a single argument. Multiple arguments are equally accepted. + + + + + +

Examples

+ + Option Compatible + Sub Main + ProductName = "Office" + Print ProductName ' displays "%PRODUCTNAME" + End Sub + + Private _office As String + Property Get ProductName As String + ProductName = _office + End Property + Property Let ProductName(value As String) + _office = "Libre"& value + End Property + + In the absence of Property Let or Property Set, Property Get helps define protected information, which can not be accidently altered by a foreign module: + + Option Compatible + Public Property Get PathDelimiter As String ' Read-only variable + Static this As String + If this = "" Then : Select Case GetGuiType() + Case 1 : this = ";" ' Windows + Case 4 : this = ":" ' Linux or macOS + Case Else : Error 423 ' Property or method not defined: PathDelimiter + End Select : End If + PathDelimiter = this + End Property ' read-only PathDelimiter + + Sub Main + PathDelimiter = "a sentence" ' does nothing + End Sub + + Use Let or Set when handling UNO services or class objects: + + Option Compatible + Sub Main + 'Set anObject = CreateUnoService( "com.sun.star.frame.Desktop" ) + anObject = CreateUnoService( "com.sun.star.frame.Desktop" ) + Print anObject.SupportedServiceNames(0) ' displays "com.sun.star.frame.Frame" + End Sub + + Property Get anObject As Object + Set anObject = _obj + End Property + + Private _obj As Object + + 'Property Set anObject(value As Object) + 'Set _obj = value.CurrentFrame + 'End Property + Property Let anObject(value As Object) + Set _obj = value.CurrentFrame + End Property + +
+ Subroutines basics + + + + End, Exit statements + + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/replace.xhp b/helpcontent2/source/text/sbasic/shared/replace.xhp new file mode 100644 index 000000000..091a2f082 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/replace.xhp @@ -0,0 +1,62 @@ + + + + + + + Replace Function + /text/sbasic/shared/replace.xhp + + + +
+ + Replace function + +

Replace Function

+ Replaces some string by another. +
+ + + + Replace (Expression As String, Find As String, Replace As String [, Start = 1 [, Count = -1 [, Compare = True]]]) As String + + + + String + + + Expression: Any string expression that you want to modify. + Find: Any string expression that shall be searched for. + Replace: Any string expression that shall replace the found search string. + Start: Optional numeric expression that indicates the character position where the search starts and also the start of the substring to be returned. + Count: Optional maximum number of times the replace shall be performed. When set to -1, all possible replacements are performed. + Compare: Optional boolean expression that defines the type of comparison. The value of this parameter can be True or False. The default value of True specifies a text comparison that is not case-sensitive. The value of False specifies a binary comparison that is case-sensitive. You can as well use 0 instead of False or 1 instead of True. + + + + + + + MsgBox Replace ("aBbcnnbnn", "b", "$", 1, 1, False) 'returns "aB$cnnbnn" + REM meaning: "b" should be replaced, but + REM * only when lowercase (compare=False), hence second occurrence of "b" + REM * only first (respecting case) occurrence (count=1) + MsgBox Replace ("ABCDEFGHI", "E", "*", 4) + REM returns D*FGHI because the search starts at position 4, which is also the start of the returned string. + MsgBox Replace("aBbcnnbnn", "b", "$£", compare:=False) 'returns "aB$£cnn$£nn" + REM Replace all (count = -1) "b" with "$£" respecting casing (compare=False) starting from first letter (start=1) + +
+ + +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/special_vba_func.xhp b/helpcontent2/source/text/sbasic/shared/special_vba_func.xhp new file mode 100644 index 000000000..92e88d44e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/special_vba_func.xhp @@ -0,0 +1,121 @@ + + + + + + + Exclusive VBA functions + /text/sbasic/shared/special_vba_func.xhp + + + + +
+ +VBA Functions;Introduction + + +

Exclusive VBA Functions and Statements

+%PRODUCTNAME Basic adds this set of functions when VBA support is enabled. +
+These exclusive VBA functions are enabled when the statement Option VBASupport 1 is placed before the first macro of a %PRODUCTNAME Basic module. + +
+ +VBA Statements + +

VBA Statements

+ Option Compatible is not a VBA statement, it extends LibreOffice Basic constructs. + + + +
+ +
+ +VBA Functions;Text Functions + +

Text functions

+ + + + + +
+ +
+ +VBA Functions;Financial Functions + +

Financial functions

+ + + + + + + + + + + + + +
+ +
+ +VBA Functions;Date and Time Functions + +

Date and time functions

+ + + +
+ +
+ +VBA Functions;I/O Functions + + +

I/O Functions

+ +
+ +
+ +VBA Functions;Mathematical Functions +VBA Functions;formatting numbers +VBA Functions;partitioning numbers + +

Mathematical Functions

+ + + +
+ +
+ +VBA Functions;Object Properties and Methods + +

Object Properties and Methods

+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/stardesktop.xhp b/helpcontent2/source/text/sbasic/shared/stardesktop.xhp new file mode 100644 index 000000000..fec1efd76 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/stardesktop.xhp @@ -0,0 +1,38 @@ + + + + + + StarDesktop object + /text/sbasic/shared/stardesktop.xhp + + + + +
+ + StarDesktop + API; Desktop + + +

StarDesktop object

+ The StarDesktop object represents %PRODUCTNAME application. Some routines or user interface objects such as current window can be used via StarDesktop. +
+

Example:

+ + Dim docURL As String + Dim doc As Object, docProperties() + docURL = ConvertToURL("C:\My Documents\example.odt") + Rem com.sun.star.frame.Desktop + doc = StarDesktop.LoadComponentFromURL(docURL, "_blank", 0, docProperties) + + +
+ diff --git a/helpcontent2/source/text/sbasic/shared/strconv.xhp b/helpcontent2/source/text/sbasic/shared/strconv.xhp new file mode 100644 index 000000000..e00a005e0 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/strconv.xhp @@ -0,0 +1,181 @@ + + + + + + StrConv Function [VBA] + /text/sbasic/shared/strconv.xhp + + + + +StrConv function + +
+

StrConv Function

+ Convert a string as specified by a conversion type. +
+ + +StrConv(Text, Conversion, [ LCID ]) + +String + +Text: Any valid string expression. +Conversion: The type of conversion to perform, as defined in the table below. +
+ + + + Conversion + + + Value + + + Description + + + + + vbUpperCase + + + 1 + + + Converts Text characters to uppercase. + + + + + vbLowerCase + + + 2 + + + Converts Text characters lowercase. + + + + + vbProperCase + + + 3 + + + Converts the first letter of every word in Text to uppercase. + + + + + vbWide + + + 4 + + + Converts narrow (half-width) characters in Text to wide (full-width) characters. + + + + + vbNarrow + + + 8 + + + Converts wide (full-width) characters in Text to narrow (half-width) characters. + + + + + vbKatakana + + + 16 + + + Converts Hiragana characters in Text to Katakana characters. + + + + + vbHiragana + + + 32 + + + Converts Katakana characters in Text to Hiragana characters. + + + + + vbUnicode + + + 64 + + + Converts Text characters to Unicode characters using the default code page of the system. + + + + + vbFromUnicode + + + 128 + + + Converts Text characters from Unicode to the default code page of the system. + + +
+
+LCID Optional. The Locale ID in decimal number. If this parameter is omitted, it assumes the system Locale ID. Refer to the file msi-encodinglist.txt for the available LCID values. + + +Option VBASupport 1 +Option Explicit +Sub Test_StrConv + Print StrConv("abc EFG hij", vbUpperCase) '= "ABC EFG HIJ" + Print StrConv("abc EFG hij", vbLowerCase) ' = "abc efg hij" + Print StrConv("abc EFG hij", vbProperCase) ' = "Abc Efg Hij" + + REM Converts narrow (single-byte) characters in string to wide + Print StrConv("ABCDEVB¥ì¥¹¥­¥å©", vbWide) ' = "ABCDEVB¥ì¥¹¥­¥å©" + + REM Converts wide (double-byte) characters in string to narrow (single-byte) characters + Print StrConv("ABCD@$%23'?EG", vbNarrow) ' = "ABCD@$%23'?EG" + + REM Converts Hiragana characters in string to Katakana characters + Print StrConv("かたかな", vbKatakana) ' = "カタカナ" + + REM Converts Katakana characters in string to Hiragana characters + Print StrConv("カタカナ", vbHiragana) '= "かたかな" + + REM Assumes CP-1252 encoding associated with en-US locale used in unit tests. + Dim x() As Byte + x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode) + Print UBound(x) ' 8 characters + Print x(2) ' = 186 + Print StrConv(x, vbUnicode)' = "ÉϺ£ÊÐABC" +End Sub + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/thisdbdoc.xhp b/helpcontent2/source/text/sbasic/shared/thisdbdoc.xhp new file mode 100644 index 000000000..8f4a1c61c --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/thisdbdoc.xhp @@ -0,0 +1,52 @@ + + + + + + ThisDatabaseDocument object + /text/sbasic/shared/thisdbdoc.xhp + + + + +
+ + ThisDatabaseDocument + API; Database document + +

ThisDatabaseDocument object

+ ThisDatabaseDocument addresses the active Base document whose properties can be read and set, and whose methods can be called. + ThisDatabaseDocument returns an object of type com.sun.star.sdb.XOfficeDatabaseDocument. +
+ + + + ThisDatabaseDocument + + When the active window does not relate to a Base document, ThisDatabaseDocument returns Nothing. + When the active window is the Basic IDE, ThisDatabaseDocument object returns the database owning the current script. + + + Opening current database "formName" and maximizing it can be achieved as shown: + + Dim form As Object + ThisDatabaseDocument.CurrentController.connect("","") + form = ThisDatabaseDocument.FormDocuments.getByName("formName").open ) + form.currentController.frame.ContainerWindow.IsMaximized = True + + +
+ ThisComponent object + com.sun.star.sdb.OfficeDatabaseDocument API service + com.sun.star.document.OfficeDocument API service +
+ + +
diff --git a/helpcontent2/source/text/sbasic/shared/uno_objects.xhp b/helpcontent2/source/text/sbasic/shared/uno_objects.xhp new file mode 100644 index 000000000..1916fa279 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/uno_objects.xhp @@ -0,0 +1,59 @@ + + + + + + UNO Objects + /text/sbasic/shared/uno_objects.xhp + + + + + programming;UNO objects + UNO objects + UNO functions + +
+

UNO Objects, Functions and Services

+ Functions, objects and services of Unified Network Objects (UNO). +
+ +

%PRODUCTNAME Global Objects

+ + + + + +

Active document Objects

+ The following objects can be used from the active document. +

BasicLibraries Object

+

DialogLibraries Object

+ + + +

UNO Methods

+ Use the following methods to manage or query Unified Network Objects (UNO). + + + + + + + + + + + %PRODUCTNAME provides an Application Programming Interface (API) that allows controlling the $[officename] components with different programming languages by using the $[officename] Software Development Kit (SDK). For more information about the $[officename] API and the Software Development Kit, visit https://api.libreoffice.org + +
+ +
+ +
diff --git a/helpcontent2/source/text/sbasic/shared/vbasupport.xhp b/helpcontent2/source/text/sbasic/shared/vbasupport.xhp new file mode 100644 index 000000000..e07bc4817 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/vbasupport.xhp @@ -0,0 +1,54 @@ + + + + + + + Support for VBA Macros + /text/sbasic/shared/vbasupport.xhp + + + + + + +
+Working with VBA Macros +Visual Basic for Applications (VBA) is an implementation of Microsoft's Visual Basic which is built into all Microsoft Office applications. +
+Support for VBA is not complete, but it covers a large portion of the common usage patterns. Most macros use a manageable subset of objects in the Excel API (such as the Range, Worksheet, Workbook, etc.) and the support include those objects, and the most commonly used method/properties of those objects. + +Loading Microsoft Office documents with executable VBA macros +Choose %PRODUCTNAME - PreferencesTools - Options - Load/Save - VBA Properties and mark the Executable code checkbox. Then load or open your document. + + +Running VBA Macros +Run VBA macros in the same way as %PRODUCTNAME Basic macros. +Since support for VBA is not complete, you may have to edit the VBA code and complete the missing support with %PRODUCTNAME Basic objects, statements and functions. + +Editing VBA Macros +VBA macros can be edited in the %PRODUCTNAME Basic IDE. + +
+VBA Properties +%PRODUCTNAME Basic IDE +
+ + +
-- cgit v1.2.3