BMS-HOSxP Community

HOSxP => Delphi / Pascal => ข้อความที่เริ่มโดย: gu_prajag ที่ พฤษภาคม 22, 2015, 16:13:44 PM

หัวข้อ: คำสั่งตัดคำ ใน pascal ครับ
เริ่มหัวข้อโดย: gu_prajag ที่ พฤษภาคม 22, 2015, 16:13:44 PM
มีข้อความยาวๆ จะตัดให้เหลือตามต้องการครับ เช่น

 st1:=vartostr(getsqldata('select pdx from an_stat where an="'+fan+'"'));
 fcds['name6']:= st1;
 fcds['name7']:=vartostr(getsqldata('select name from icd101 where code="'+st1+'"'));

จะตัดชื่อการวินิจซึ่งยาวเกินไปให้เหลือสั้น เช่น
Foodborne Bacillus cereus intoxication -> เป็น Foodborne Bacillus.... มีจุดๆๆๆ ต่อท้าย
หัวข้อ: Re: คำสั่งตัดคำ ใน pascal ครับ
เริ่มหัวข้อโดย: chitvichai ที่ พฤษภาคม 25, 2015, 10:34:24 AM
มีข้อความยาวๆ จะตัดให้เหลือตามต้องการครับ เช่น

 st1:=vartostr(getsqldata('select pdx from an_stat where an="'+fan+'"'));
 fcds['name6']:= st1;
 fcds['name7']:=vartostr(getsqldata('select name from icd101 where code="'+st1+'"'));

จะตัดชื่อการวินิจซึ่งยาวเกินไปให้เหลือสั้น เช่น
Foodborne Bacillus cereus intoxication -> เป็น Foodborne Bacillus.... มีจุดๆๆๆ ต่อท้าย

ถ้าใช้ใน script delphi ของ HOSxP ก็ copy(fullstring,stringStart,lenString); จะได้
 
 st1:=vartostr(getsqldata('select pdx from an_stat where an="'+fan+'"'));
 fcds['name6']:= st1;
 st2:=vartostr(getsqldata('select name from icd101 where code="'+st1+'"'));
 fcds['name7']:=copy(st2,1,15)+"...";

แต่ใช้ sql query
เป็น substr(fullstring,stringStart,lenString) หรือ substring(fullstring,stringStart,lenString) จะได้
 st1:=vartostr(getsqldata('select pdx from an_stat where an="'+fan+'"'));
 fcds['name6']:= st1;
 st2:=vartostr(getsqldata('select concat(substr(name,1,15),"...") from icd101 where code="'+st1+'"'));
 fcds['name7']:=st2;



หัวข้อ: Re: คำสั่งตัดคำ ใน pascal ครับ
เริ่มหัวข้อโดย: gu_prajag ที่ พฤษภาคม 25, 2015, 11:00:38 AM
ขอบคุณมากๆครับ chitvichai