PowerBuilder Converts String To List. Powerbuilder Converts The String To A Specific Delimiter String List
Source Code
f_convert_stringtolist from function_object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | global type f_convert_stringtolist from function_object end type forward prototypes global function any f_convert_stringtolist (string as_str, string as_delimiter) end prototypes global function any f_convert_stringtolist (string as_str, string as_delimiter);//==================================================================== // Function: f_convert_stringtolist() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value string as_str // value string as_delimiter //-------------------------------------------------------------------- // Returns: any //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2021/06/23 //-------------------------------------------------------------------- // Usage: f_convert_stringtolist ( string as_str, string as_delimiter ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== String ls_list [] // return receive a list of strings String ls_temp Integer li_i = 1 Long ll_pos Integer li_len li_len = Len (as_delimiter) // length delimiter ll_pos = Pos(as_str,as_delimiter) Do If ll_pos = 0 Then ls_list[li_i] = as_str Else ls_list[li_i] = Left(as_str,ll_pos - 1) li_i++ as_str = Mid(as_str,ll_pos + li_len) ll_pos = Pos(as_str,as_delimiter) If ll_pos = 0 Then ls_list[li_i] = as_str End If Loop While ll_pos <> 0 Return ls_list end function |
Example code w_main from window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | forward global type w_main from window end type type lv_list from listview within w_main end type type cb_convert from commandbutton within w_main end type type st_1 from statictext within w_main end type type sle_delimiter from singlelineedit within w_main end type type mle_input from multilineedit within w_main end type end forward global type w_main from window integer width = 1550 integer height = 1712 boolean titlebar = true string title = "Converts String To List" boolean controlmenu = true boolean minbox = true boolean maxbox = true boolean resizable = true long backcolor = 67108864 string icon = "AppIcon!" boolean center = true lv_list lv_list cb_convert cb_convert st_1 st_1 sle_delimiter sle_delimiter mle_input mle_input end type global w_main w_main on w_main.create this.lv_list=create lv_list this.cb_convert=create cb_convert this.st_1=create st_1 this.sle_delimiter=create sle_delimiter this.mle_input=create mle_input this.Control[]={this.lv_list,& this.cb_convert,& this.st_1,& this.sle_delimiter,& this.mle_input} end on on w_main.destroy destroy(this.lv_list) destroy(this.cb_convert) destroy(this.st_1) destroy(this.sle_delimiter) destroy(this.mle_input) end on type lv_list from listview within w_main integer x = 37 integer y = 608 integer width = 1426 integer height = 928 integer taborder = 40 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 borderstyle borderstyle = stylelowered! listviewview view = listviewlist! long largepicturemaskcolor = 536870912 long smallpicturemaskcolor = 536870912 long statepicturemaskcolor = 536870912 end type type cb_convert from commandbutton within w_main integer x = 1061 integer y = 448 integer width = 402 integer height = 112 integer taborder = 30 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Convert" boolean default = true end type event clicked;String ls_list[] Int li_i lv_list.DeleteItems() ls_list = f_convert_stringtolist(mle_input.Text , sle_delimiter.Text) For li_i = 1 To UpperBound(ls_list) lv_list.additem( ls_list[li_i], li_i) Next end event type st_1 from statictext within w_main integer x = 142 integer y = 472 integer width = 293 integer height = 96 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Delimiter:" alignment alignment = right! boolean focusrectangle = false end type type sle_delimiter from singlelineedit within w_main integer x = 439 integer y = 460 integer width = 585 integer height = 100 integer taborder = 20 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 string text = "/" borderstyle borderstyle = stylelowered! end type type mle_input from multilineedit within w_main integer x = 37 integer y = 32 integer width = 1426 integer height = 384 integer taborder = 10 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type |
Find Projects On Github click here
Good Luck!