Lazarus

Programming => General => Topic started by: Re-searcher on May 06, 2021, 04:08:35 pm

Title: How to rewrite this type example ?
Post by: Re-searcher on May 06, 2021, 04:08:35 pm
Hi everyone,

Congratulations to the designer for creating this Visual IDE and FPC

I am translating a program from basic to Laz/FPC but have the following problem.
The program does not know this example with type.
Have an error by compiling.
How can I rewrite this now?

Type ConstMeta
  Value As String
  Startup As String
End Type

With best regards,
Erik
Title: Re: How to rewrite this type example ?
Post by: MarkMLl on May 06, 2021, 05:00:00 pm
Not knowing BASIC, but surely that's just a simple record containing two strings?

MarkMLl
Title: Re: How to rewrite this type example ?
Post by: Re-searcher on May 06, 2021, 06:45:13 pm
Thanks MarkMLl for the quick response

the language was FreeBasic.

Erik
Title: Re: How to rewrite this type example ?
Post by: lucamar on May 06, 2021, 06:48:10 pm
If that type is the FreeBASIC one (https://www.freebasic.net/wiki/KeyPgType) then yes, it's (more or less) the equivalent of a Pascal record:

Code: Pascal  [Select][+][-]
  1. type
  2.   ConstMeta = record
  3.     Value: String;
  4.     Startup: String;
  5.   end;
Title: Re: How to rewrite this type example ?
Post by: Re-searcher on May 07, 2021, 01:54:04 pm
Thanks lucamar for your answer.

The program was for programming PIC and AVR MCU's
But has no IDE for Linux , only for Windows.
It is gcbasic and made in FreeBasic
gcbasic has new keywords.
http://gcbasic.sourceforge.net/Typesetter/index.php/Home

Freebasic has no IDE and no designer like Lazarus in Linux.
Geany has an IDE but no designer.

I want to create a program with the designer and communicate with the PIC or AVR MCU (Microcontroller)
https://en.wikipedia.org/wiki/Microcontroller

With kind regards,
Erik
Title: Re: How to rewrite this type example ?
Post by: MarkMLl on May 07, 2021, 02:55:11 pm
I want to create a program with the designer and communicate with the PIC or AVR MCU (Microcontroller)

So what language are you trying to write in? Your OP said you were converting /to/ Pascal, but if you're asking how to program in BASIC you're not really in the right place.

MarkMLl
Title: Re: How to rewrite this type example ?
Post by: dseligo on May 07, 2021, 03:42:25 pm
So what language are you trying to write in? Your OP said you were converting /to/ Pascal, but if you're asking how to program in BASIC you're not really in the right place.

Int the first post he said:
Quote
I am translating a program from basic to Laz/FPC but have the following problem.

By designer he probably means Lazarus' IDE (and visual design of forms).
Title: Re: How to rewrite this type example ?
Post by: MarkMLl on May 07, 2021, 04:43:43 pm
So what language are you trying to write in? Your OP said you were converting /to/ Pascal, but if you're asking how to program in BASIC you're not really in the right place.

Int the first post he said:
Quote
I am translating a program from basic to Laz/FPC but have the following problem.

By designer he probably means Lazarus' IDE (and visual design of forms).

I can see what he said, which is why I referred to his OP. So why's he complaining that his BASIC tools don't have "a designer"?

MarkMLl
Title: Re: How to rewrite this type example ?
Post by: lucamar on May 07, 2021, 04:47:44 pm
So why's he complaining that his BASIC tools don't have "a designer"?

AFAICT, he's not complaining, he's explaining why he wants to move from BASIC to Pascal, to wit: because of our wonderful "designer" :D
Title: Re: How to rewrite this type example ?
Post by: MarkMLl on May 07, 2021, 05:14:41 pm
AFAICT, he's not complaining, he's explaining why he wants to move from BASIC to Pascal, to wit: because of our wonderful "designer" :D

Well, in that case I think we unite in welcoming him. I was just a bit concerned by his "BUT..." :-)

Obviously there's quite a few of us who've put work into getting Lazarus/FPC apps talking to microcontrollers, so he didn't really have to quote Wp at us :-)

MarkMLl


Title: Re: How to rewrite this type example ?
Post by: Re-searcher on May 10, 2021, 06:09:25 pm
@MarkMLl

If the people deliver a piece of code, these people also expect a piece of code in return.
The topic also said: How to rewrite this type example?

You also wrote: So what language are you trying to write in?
This furum is about pascal.
So the basic language to Pascal.
I couldn't do anything with your ordinary text file that you gave me.

The only person who helped me is lucamar.

The microcontroller that was just one example.
This is because they now use it.
I also built the interface between a microcontoller and a the PC by myself.

I could also have said: an old CNC from 1966 with a PC.
I have also done this inteface.
Or a link between a PLC and a PC. Have even built an interface for this.
Built an OBDII tool..
Modems built ..... Morse, telex, fax, packet radio

Erik
Title: Re: How to rewrite this type example ?
Post by: marcov on May 10, 2021, 07:04:53 pm
@MarkMLl

If the people deliver a piece of code, these people also expect a piece of code in return.

This is not a FreeBasic forum. You can't expect people to know obscure Basic dialects here.

Moreover, basic (record and other) syntax can be easily gained from 20 minutes of reading the reference manual.  Something I suggest to read anyway.




Title: Re: How to rewrite this type example ?
Post by: Re-searcher on May 13, 2021, 05:43:09 pm
Hi everyone,

My country language is not English but dutch.
I am an old person and I have not had to work for a while now.
It is not easy to learn a new computer language that is also written in English with new and incomprehensible words.
The documentation that is in a language other than my country language

The last 3 years at school I only had a calculator.
In recent years, that has been head arithmetic.
Back then, computers at school did not exist.
This was my first PC: Commodore c64 (64kb) with data set 1530 (tape recorder)
The only record I knew was  : PRESS PLAY AND RECORD ON TAPE
Basic V2.0 This is the only basic I know.

At work I learned PLC programming and assembler.


This was the answer from MarkMLl.
Not knowing BASIC, but surely that's just a simple record containing two strings?


Then why can't MarkMLl write in pascal? Can't this person write in Pascal either ?


I hope you now understand and have an understanding of old persons like me.


Erik

Title: Re: How to rewrite this type example ?
Post by: MarkMLl on May 13, 2021, 06:23:41 pm
My country language is not English but dutch.
I am an old person and I have not had to work for a while now.
It is not easy to learn a new computer language that is also written in English with new and incomprehensible words.
The documentation that is in a language other than my country language

I agree that it's regrettable that the language and documentation doesn't conform to your native language, but I suggest that you take that up with Wirth- who despite his appointment at ETH in Zurich designed the language using English keywords and has always documented it in English.

Quote
The last 3 years at school I only had a calculator.
In recent years, that has been head arithmetic.
Back then, computers at school did not exist.

Calculator? You had a calculator while at school? You obnoxious young whippersnapper, when I was at school I was grateful to have a decent sliderule and mathematical tables and I didn't have access to a desktop computer until my fourth year at university.

Now I know that /some/ schools had access to the county mainframe using a Teletype- ever seen one of those? or by mailing off coding forms to be punched onto cards- ever done that and had to wait a week for the syntax errors to be sent back to you?

Quote
This was my first PC: Commodore c64 (64kb) with data set 1530 (tape recorder)
The only record I knew was  : PRESS PLAY AND RECORD ON TAPE
Basic V2.0 This is the only basic I know.

At work I learned PLC programming and assembler.

So? Some of us had to do stuff like that using ladder diagrams or machinecode. On occasion I found myself waking up from a dream where I was disassembling Z80 in my head.

Put another way, don't try the "I'm a poor old man" act around here, kiddo >:-)

Quote
This was the answer from MarkMLl.
Not knowing BASIC, but surely that's just a simple record containing two strings?

And? You could have found the example in any elementary text: I carefully gave you the two important terms RECORD and STRING, and if you drop the three terms 'pascal' 'record' 'string' into Google it gives you e.g. https://www.pascal-programming.info/lesson11.php hence the example

Code: Pascal  [Select][+][-]
  1. Type
  2.         Str25    = String[25];
  3.         TBookRec =
  4.                         Record
  5.                                 Title, Author, ISBN : Str25;
  6.                                 Price : Real;
  7.                         End;
  8.  
  9. Var
  10.     myBookRec : TBookRec;
  11.  

Now that's using a "shortstring" which is allocated with a predefined maximum length, you'd more likely these days to do something like

Code: Pascal  [Select][+][-]
  1. Type
  2.         TBookRec =
  3.                         Record
  4.                                 Title, Author, ISBN : String;
  5.                                 Price : Real;
  6.                         End;
  7.  

...and leave the hard work to the compiler.

Quote
I hope you now understand and have an understanding of old persons like me.

Old? Bah...

Look, hopefully we've got that one out of the way. Because of the way you phrased the question I found it very unclear as to what /exactly/ you were asking. If I caused offence and in particular if I wasted your time I'm sorry, but all of us here answer questions as best we can allowing that most of us are still actually working, so we have limited time to spoon-feed people who aren't up to using Google or haven't bothered to find an online book.

MarkMLl
Title: Re: How to rewrite this type example ?
Post by: Bart on May 13, 2021, 06:51:50 pm
My country language is not English but dutch.
I am an old person and I have not had to work for a while now.
It is not easy to learn a new computer language that is also written in English with new and incomprehensible words.
The documentation that is in a language other than my country language

Hoi Erik,

Wellicht kun je ook terecht op het NLDelphi forum (https://www.nldelphi.com/forum.php).
Daar is ook een Lazarus sectie aanwezig.
Kun je gewoon Nederlands praten.

{
Hi Erik,
Perhaps you could goto to NLDelphi forum (https://www.nldelphi.com/forum.php).
It has a Lazarus section.
You can talk Dutch there.
}

Bart
Title: Re: How to rewrite this type example ?
Post by: Re-searcher on May 15, 2021, 11:33:42 pm
Hi MarkMLl

In the early years when I started working, punched cards was also used.
I have also seen large mainframes with large tape recorders.
Teletype terminals (VT ...)
I had a punched card to register at the factory (time registration)
punched card was also used as a means of payment.
A street organ with a punched card.

Erik
Title: Re: How to rewrite this type example ?
Post by: Re-searcher on May 15, 2021, 11:36:22 pm
Hey Bart,

Bedankt voor het bezorgen van de link
Ik zie U wel op dat forum.

Hi Bart
{Thanks for sending me for the link
I'll see you on that forum.}

Erik
Title: Re: How to rewrite this type example ?
Post by: MarkMLl on May 16, 2021, 10:11:37 am
Teletype terminals (VT ...)

:-) No, not VT but the entirely-mechanical ones... ASR33 and the like.

"Métal hurlant" :-)

MarkMLl
Title: Re: How to rewrite this type example ?
Post by: winni on May 16, 2021, 11:37:51 am
Teletype terminals (VT ...)

:-) No, not VT but the entirely-mechanical ones... ASR33 and the like.

"Métal hurlant" :-)

MarkMLl

Hi!

For the "young blood":

https://www.pdp8online.com/asr33/asr33.shtml (https://www.pdp8online.com/asr33/asr33.shtml)

Winni
Title: Re: How to rewrite this type example ?
Post by: MarkMLl on May 16, 2021, 11:48:32 am
:-) I might still have a set of the manuals somewhere. The bottom line is that the only electrical devices were a motor, a single electromagnet for printing, and a rotating commutator on the keyboard. One man could carry one- unlike the Olivetti I owned once which had been carefully "reimagined" to circumvent the patents and which replaced every pressed-metal part with a machined-and-bolted subassy which could easily drift out of alignment... I heard that the maintenance course was 12 weeks.

It's difficult to imagine terminals which predate microprocessors, but "glass teletypes" with varying degrees of sophistication and ingenuity go back to the 1960s.

@Re-searcher: you /really/ don't want to get me going on this stuff :-)

MarkMLl
Title: Re: How to rewrite this type example ?
Post by: BobDog on May 16, 2021, 12:10:33 pm

Hello re searcher.
I am no spring chicken either.

Remember that pascal string and freebasic string are not the same thing.
You need ansistring, or the switch for ansistring to get a reasonable representation.
Code: Pascal  [Select][+][-]
  1.  
  2.  
  3.  {$H+}            // String is now an alias for AnsiString
  4.  
  5.     type
  6.   ConstMeta = record
  7.     Value: String;
  8.     Startup: String;
  9.   end;
  10.  
  11.   var s:ConstMeta;
  12.  
  13.  
  14. begin
  15. s.Value:='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
  16. s.Value:=s.Value+s.Value;
  17.  s.Value:=s.Value+s.Value;
  18.  s.Value:=s.Value+s.Value;
  19.  s.Value:=s.Value+s.Value;
  20.  s.Value:=s.Value+s.Value;
  21.  
  22. writeln;
  23. writeln(s.Value);
  24.  
  25. readln;
  26. end.
Title: Re: How to rewrite this type example ?
Post by: Re-searcher on May 17, 2021, 03:03:04 pm
@BobDog
Thanks for this information.

@MarkMLl

When I was born at the time, there were no computers and printers (asr33)
This type of printer is not stored in my memory brain only Mechanical desktop typewriters not with electronic like asr33

I have learned to write with a pen with ink from a bottle.
http://www.overdiep.nl/ink/inkhomed.html

Erik
Title: Re: How to rewrite this type example ?
Post by: MarkMLl on May 17, 2021, 03:23:48 pm
This type of printer is not stored in my memory brain only Mechanical desktop typewriters not with electronic like asr33

That contained NO ELECTRONICS.

Quote
I have learned to write with a pen with ink from a bottle.
http://www.overdiep.nl/ink/inkhomed.html

Yes, and when I was at school the desks had inkwells next to each pupil and we used dip pens, none of these fountain pens or Biros.

I lie: we had Biros in primary school, but after that were expected to learn how to do things properly.

MarkMLl
TinyPortal © 2005-2018