Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Object Pascal Programming Language
  • Page:
  • 1

TOPIC:

Base64 from pl_BaseLib4Pascal 2 years 9 months ago #16624

  • Artur
  • Artur's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
Hello
I need Base64 for pas2js GUI application.
I found pl_BaseLib4Pascal

In the "Install / Uninstall Packages ..." window I found "pl_BaseLib4Pascal" and installed (Save and rebulid IDE). How can I benefit from it now?

There is no such tab in the list of components, and if I try to add Uses SbpBase64; I have an error: unit1.pas (9,3) Error: can't find unit "SbpSimpleBaseLibTypes".

Please help.

Windows 10, 64, Typhon 7.6

Please Log in or Create an account to join the conversation.

Base64 from pl_BaseLib4Pascal 2 years 6 months ago #17002

  • Robert Jenkins
  • Robert Jenkins's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 0
Arthur,

     I just saw this post and I don't know if you got an answer to your question or not so I worked up a simple basic example.  First, you don't need to "install" this package, just add it to the "Required Packages" of your project.  There are no visual components so no need to install it.  I created a form with two buttons and two memos.  Hope this helps.

Robert

ps.  I also believe there are examples included with CodeTyphon in the "CodeOcean" Examples.


Uses
  SbpBase64;

{$R *.frm}


Function ToBase64(Const ABytes : TBytes) : String; Overload;
Begin
  Result := TBase64.Default.Encode(ABytes);
End;

Function ToBase64(Const AString : String) : String; Overload;
Var
  ABytes : TBytes;
Begin
  ABytes := TEncoding.ANSI.GetAnsiBytes(AString);
  Try
    Result := ToBase64(ABytes);
  Finally
    SetLength(ABytes, 0);
  End;
End;

Function FromBase64(Const AString : String) : String;
Var
  ABytes : TBytes;
Begin
  ABytes := TBase64.Default.Decode(AString);
  Try
    Result := String(TEncoding.ANSI.GetString(ABytes));
  Finally
    SetLength(ABytes, 0);
  End;
End;


{ Tform1 }

Procedure Tform1.buttonToBase64click(Sender : Tobject);
Begin
  memoBase64Text.Lines.Text := ToBase64(memoNormalText.Lines.Text);
End;

Procedure Tform1.buttonFromBase64Click(Sender : Tobject);
Begin
  memoNormalText.Lines.Text := FromBase64(memoBase64Text.Lines.Text);
End;

Please Log in or Create an account to join the conversation.

  • Page:
  • 1