ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingขอคำแนะนำหน่อยครับ เค้าให้ code เรามา เราจะคอมไพล์ ออกมาอีกทีทำไงครับ
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ขอคำแนะนำหน่อยครับ เค้าให้ code เรามา เราจะคอมไพล์ ออกมาอีกทีทำไงครับ  (อ่าน 831 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
id09318
ก๊วนเสียว
*

พลังน้ำใจ: 9
ออฟไลน์ ออฟไลน์

กระทู้: 282



ดูรายละเอียด
« เมื่อ: 07 กรกฎาคม 2016, 16:42:59 »

เราสามารถใช้ พวก vs vb สร้างมันออกมาได้่ไหมครับ
แล้วเราจะสร้างมันได้ยังไงครับ

โค๊ด:
procedure TForm1.btnDat2XmlClick(Sender: TObject);
var
  XMLDoc: TXMLDocument;
  Node1: IXMLNode;
  Node2: IXMLNode;
  MyStream: TMemoryStream;
  i: integer;
begin
  if FileExists('.\GoodsSale_Tw.dat') then begin
    XMLDoc := TXMLDocument.Create(nil);
    XMLDoc.Active := True;
    XMLDoc.Version := '1.0';
    XMLDoc.Encoding := 'GB2312';
    XMLDoc.Options := [doNodeAutoCreate, doNodeAutoIndent, doAttrNull, doAutoPrefix, doNamespaceDecl];
    XMLDoc.DocumentElement := XMLDoc.CreateNode('table');
    myStream := TMemoryStream.Create;
    myStream.LoadFromFile('.\GoodsSale_Tw.dat');
    Count := (myStream.Size - 40) div 10;
    //myStream.ReadBuffer(Head[0], 10);
    MyStream.Position := 10;
    for i := 0 to Count - 1 do
    begin
      new(Pgshop);
      MyStream.Read(Pgshop^, sizeof(gshop_info));
      Node1 := XMLDoc.DocumentElement;
      Node2 := Node1.AddChild('row');
      if ((i + 1) mod 2) <> 0 then begin
        Node2.SetAttributeNS('大类', '', Pgshop^.a1 xor $72);
        Node2.SetAttributeNS('位置', '', Pgshop^.a2 xor $67);
        Node2.SetAttributeNS('物品ID', '', Pgshop^.a3 xor $AA13);
        Node2.SetAttributeNS('折叠数量', '', Pgshop^.a5 xor $86);
        Node2.SetAttributeNS('价格', '', Pgshop^.a6 xor $DFB0);
        Node2.SetAttributeNS('功能1', '', Pgshop^.a8 xor $C2);
        Node2.SetAttributeNS('功能2', '', Pgshop^.a9 xor $C8);
        Node2.SetAttributeNS('标识', '', Pgshop^.a10 xor $9D);
      end else begin
        Node2.SetAttributeNS('大类', '', Pgshop^.a1 xor $4E);
        Node2.SetAttributeNS('位置', '', Pgshop^.a2 xor $B0);
        Node2.SetAttributeNS('物品ID', '', Pgshop^.a3 xor $D103);
        Node2.SetAttributeNS('折叠数量', '', Pgshop^.a5 xor $BC);
        Node2.SetAttributeNS('价格', '', Pgshop^.a6 xor $8E05);
        Node2.SetAttributeNS('功能1', '', Pgshop^.a8 xor $07);
        Node2.SetAttributeNS('功能2', '', Pgshop^.a9 xor $92);
        Node2.SetAttributeNS('标识', '', Pgshop^.a10 xor $80);
      end;
    end;
    //myStream.ReadBuffer(LastRecord, 10);
    //myStream.ReadBuffer(Bottom[0], 20);
    XMLDoc.SaveToFile('.\GoodsSale_Tw.xml');
    XMLDoc.Free;
    myStream.Free;
  end;
end;

procedure TForm1.btnXml2DatClick(Sender: TObject);
var
  XMLDoc: TXMLDocument;
  Node, Node1: IXMLNode;
  MyStream: TMemoryStream;
  i, Count: integer;
begin
  if FileExists('.\GoodsSale_Tw.xml') then begin
    XMLDoc := TXMLDocument.Create(Application);
    XMLDoc.LoadFromFile('.\GoodsSale_Tw.xml');
    XMLDoc.Active := True;
    Node := XMLDoc.DocumentElement;
    Count := Node.ChildNodes.Count;
    myStream := TMemoryStream.Create;
    myStream.Write(Head[0], Length(Head));
    for i := 0 to Count - 1 do begin
      Node1 := XMLDoc.DocumentElement.ChildNodes[i];
      new(Pgshop);
      if ((i + 1) mod 2) <> 0 then begin
        Pgshop^.a1 := Byte(StrToInt(Node1.Attributes['大类'])) xor $72;
        Pgshop^.a2 := Byte(StrToInt(Node1.Attributes['位置'])) xor $67;
        Pgshop^.a3 := StrToInt(Node1.Attributes['物品ID']) xor $AA13;
        Pgshop^.a5 := Byte(StrToInt(Node1.Attributes['折叠数量'])) xor $86;
        Pgshop^.a6 := StrToInt(Node1.Attributes['价格']) xor $DFB0;
        Pgshop^.a8 := Byte(StrToInt(Node1.Attributes['功能1'])) xor $C2;
        Pgshop^.a9 := Byte(StrToInt(Node1.Attributes['功能2'])) xor $C8;
        Pgshop^.a10 := Byte(StrToInt(Node1.Attributes['标识'])) xor $9D;
      end else begin
        Pgshop^.a1 := Byte(StrToInt(Node1.Attributes['大类'])) xor $4E;
        Pgshop^.a2 := Byte(StrToInt(Node1.Attributes['位置'])) xor $B0;
        Pgshop^.a3 := StrToInt(Node1.Attributes['物品ID']) xor $D103;
        Pgshop^.a5 := Byte(StrToInt(Node1.Attributes['折叠数量'])) xor $BC;
        Pgshop^.a6 := StrToInt(Node1.Attributes['价格']) xor $8E05;
        Pgshop^.a8 := Byte(StrToInt(Node1.Attributes['功能1'])) xor $07;
        Pgshop^.a9 := Byte(StrToInt(Node1.Attributes['功能2'])) xor $92;
        Pgshop^.a10 := Byte(StrToInt(Node1.Attributes['标识'])) xor $80;
      end;
      myStream.Write(Pgshop^, SizeOf(gshop_info));
    end;
    myStream.Write(LastRecord[0], Length(LastRecord));
    myStream.Write(Bottom[0], Length(Bottom));
    myStream.SaveToFile('.\GoodsSale_Tw1.dat');
    myStream.Free;
  end;
end;
บันทึกการเข้า

มีแต่วันนี้ที่มีค่า ไม่มีวันหน้าและวันหลัง.
rapiz
Newbie
*

พลังน้ำใจ: 13
ออฟไลน์ ออฟไลน์

กระทู้: 81



ดูรายละเอียด เว็บไซต์
« ตอบ #1 เมื่อ: 07 กรกฎาคม 2016, 17:58:24 »

ภาษา Delphi (เดลไฟ) ครับ แต่ไม่แน่ใจว่า V อะไร  wanwan006 เขียนง่ายครับ ภาษานี้ ผมฝึกตอนเริ่มเขียนโค๊ดเลย


ฝากลายเซ็นด้วยนะครับ
บันทึกการเข้า

Web Hosting,Reseller Hosting ราคาถูกเริ่มต้นแค่ 200฿ ต่อปีเท่านั้น!
VPS Linux, Windows (*ฟรี Direct Admin*) เริ่มต้นแค่ 700฿ ต่อเดือนเท่านั้น
รับเขียน Application บน Windows, Linux ด้วยทีมงานมืออาชีพ!!
สนใจ สมัครบริการด้านบน http://www.rapizhost.com
ติดต่อ 091-7733660 (24ชม.) Line ID : @rapizhost
mango
สมุนแก๊งเสียว
*

พลังน้ำใจ: 83
ออฟไลน์ ออฟไลน์

กระทู้: 952



ดูรายละเอียด
« ตอบ #2 เมื่อ: 08 กรกฎาคม 2016, 03:37:23 »

เข้ามาเก็บความรู้ต่อเนื่อง  wanwan011
บันทึกการเข้า

sputtaro
สมุนแก๊งเสียว
*

พลังน้ำใจ: 139
ออฟไลน์ ออฟไลน์

กระทู้: 910



ดูรายละเอียด
« ตอบ #3 เมื่อ: 08 กรกฎาคม 2016, 15:26:01 »

เป็นโค๊ดภาษาเดลไฟครับ
ต้องใช้โปรแกรมเดลไฟ เปิดถึงจะคอมไพล์ได้
น่าจะใช้ได้กับทุกเวอร์ชั่นที่ใช้ TXMLDocument ได้นะครับ เพราะไม่มีอะไรเป็นพิเศษ

กรณีที่คุณต้องการสร้างด้วย VB (รวมไปถึงภาษาอื่นๆที่อ่านไฟล์ .dat ได้)
ก็น่าจะทำได้ไม่ยาก เพราะ
โค๊ดที่ให้มา เป็นการสร้างฟอร์มขึ้นมา 1 ฟอร์ม มี 2 ปุ่ม

ปุ่มแรก -- btnDat2XmlClick
ให้อ่านไฟล์ GoodsSale_Tw.dat
จากโค๊ด -- if FileExists('.\GoodsSale_Tw.dat')
แล้วเก็บลงในหน่วยความจำ -- TMemoryStream
ต่อจากนั้น เซฟเป็นไฟล์ .xml
จากโค๊ด -- .SaveToFile('.\GoodsSale_Tw.xml');

ปุ่มที่ 2 -- btnXml2DatClick
ก็หลักการเดียวกัน แต่อ่านและเซฟ สลับกันคือ
ให้อ่านไฟล์ GoodsSale_Tw.xml
จากโค๊ด -- if FileExists('.\GoodsSale_Tw.xml')
แล้วเก็บลงในหน่วยความจำ -- TMemoryStream
ต่อจากนั้น เซฟเป็นไฟล์ .dat
จากโค๊ด -- SaveToFile('.\GoodsSale_Tw1.dat');

หากคุณพอมีพื้นฐานบ้าง ผมคิดว่าไม่ยากเลยครับ

*******************************
หวังว่าจะมีประโยชน์บ้างนะครับ
« แก้ไขครั้งสุดท้าย: 08 กรกฎาคม 2016, 15:26:49 โดย sputtaro » บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์