Recent

Author Topic: A stupid question  (Read 1734 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
A stupid question
« on: February 05, 2016, 09:12:40 am »
How do I change a word in a string, and vice versa?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

chenyuchih

  • Jr. Member
  • **
  • Posts: 83
Re: A stupid question
« Reply #1 on: February 05, 2016, 09:49:27 am »

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
Re: A stupid question
« Reply #2 on: February 05, 2016, 11:38:13 am »
No I mean a number word

var

   myvar: word;

begin

myvar:=123456789;
writeln myvar?!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: A stupid question
« Reply #3 on: February 05, 2016, 12:10:29 pm »
1) Word is 16-bit unsigned, 0..65535, you cannot assign 123456789 to it

2) there are function IntToStr(); an StrToInt();

3) WriteLn(); is part of compiler magic, you don't have to convert it to string

You can do both
Code: Pascal  [Select][+][-]
  1. writeln(myvar);
  2. writeln(inttostr(myvar));
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

TinyPortal © 2005-2018