What is CAPL

Forum: Microcontrollers and Digital Electronics Understand a simple program in the CAPL programming language





Hello, I wanted to get to know the basics of the CAPL programming language. There is a sample program. I wanted to look at the example and understand how the program works step by step: byte binary array [16] // What happens in the line? Is the BYTE data type declared with an array? What is 16? int number = 1234; // Why 1234? How did you want to use the variable number here? What's the point? int index = 0; // What is the variable index for? Why is the = 0? while (number! = 0) // As long as variable number is not equal to 0 {binaryArray [index ++] = number% 10; // What happens on the line? number = number / 10 What happens in the line? But was it already divided by 10 in the previous line? Why here too? } -> Result 11010010 how do you get the result? ======================= ========================== And second program: it is about an example with data type function: void PrintMe (int num, char msg []) // Is the function PrintMe declared here? With variables 1) num of type int and 2) msg ​​of type char. What role do the variables play? What do [] mean at msg? {write ("% d% s", num msg); } PrintMe (1, "Error"); // Function call What does 1 and "error" mean? What are they for? long Mult (int x, int y) // What is Mult, x, y? {int i; long result; // What is result and what is it for? result = 1; for (i = 1; i <= y; i ++) result * = x; // What is happening on the line? return result; } xy = Mult (2,4); // Function call Why do you have to call a function here? Can you see what result? Why are xy written next to each other and no character (e.g. *) between them?

: Edited by user


Hi> But it was already divided by 10> in the previous line? Nope> number% 10; is called number mod 10> I wanted to get to know the basics of the CAPL programming language. What is that? Somehow reminds me of C MfG Spess



spess53 wrote:> What is that? Somehow reminds me of C CAPL is a programming language developed by Vector Informatik that is available in the widely used software tools CANoe and CANalyzer.



CAPL is an unbelievable cramp. VBA is still really good against it. You can't call that a programming language. And yes, I know what I'm talking about. S.



In the first snippet, byte binary array [16] must probably be named byte binaryArray [16]. This makes it a meaningful definition and is used as such below. The rest actually looks a lot like standard C.



Stefan wrote:> CAPL is an unbelievable cramp. VBA is still really good> on the other hand.> Something like that cannot be called a programming language. And yes, I> know what I'm talking about.> S. Does this have anything to do with the TO question? Does that help him somehow?



Hel B. wrote:> void PrintMe (int num, char msg []) // Is the function PrintMe> declared here? With variables 1)> num of type int and 2) msg ​​of> type char. >> What role do the> variables play? What do [] mean with> msg?> {> Write ("% d% s", num msg);>} PrintMe is a procedure (= function without return value) that expects two arguments. The first must be an integer and is made available within the procedure as the variable num. The second argument is an array of char elements - that is, a string. Hel B. wrote:> long Mult (int x, int y) // What is Mult, x, y?> {This is now a function that returns a result of type long. Hel B. wrote:> long result; // What is result and what is it for? just a variable of type long Hel B. wrote:> result * = x; // What happens on the line? What is already in result is multiplied by x. Hel B. wrote:> xy = Mult (2,4); // Function call Why do you need xy is a new variable and is filled with the return value of the function.



JJ wrote:> In the first snippet> byte binary Array [16]> probably> byte binaryArray [16]> must be. This means that it is a meaningful definition and is also used as> below. >> The rest actually looks very much like standard C. But this is about one of the many C extensions ... In order to understand them you have to read the K&R beforehand, which the OP somehow missed. And no, C as a programming language is not self-explanatory.



Erwin D. wrote:> Does that have anything to do with the question of the TO?> Does that help him in any way? He could consider whether it makes sense to invest time in this outgrowth of programming language or whether it leads to a dead end. He could better learn such basics from a widely used programming language.

by Arduino Fanboy D. (ufuf)


W.A. wrote:> He could consider whether it makes sense to invest time in this outgrowth of programming language. Sometimes you have a choice, sometimes you don't. I was also allowed to create printer drivers for Data General AOS / VS. The choice was very limited. JJ wrote:> In the first snippet,> byte binary array [16]> likely> byte binaryArray [16] improbable. I also sometimes miss binary arrays in c. The output looks like that's right. (unfortunately I don't know CAPL well enough)



FYI: The examples seem to come from this university exercise script: http://www.ias.uni-stuttgart.de/lehre/praktika/automatisierung/unterlagen/06-Kurzanleitung_CAPL-v10_de.pdf There is on page 8: byte binaryArray [16] instead of byte binary array [16] as above. The second example on page 10 also contains the typing error of the missing comma in "write" in the original.

Write an answer

Providing an email address is voluntary. If you would like to be automatically informed by e-mail about replies to your post, please log in.

Important rules - read first, then post!

  • Use upper and lower case
  • Do not insert longer source code in the text, but as a file attachment

Formatting (more information ...)

  • [c] C code [/ c]
  • [code] code in other languages, ASCII drawings [/ code]
  • [math] Formula in LaTeX syntax [/ math]
  • [[Title]] - Link to article
  • Insert reference to another post: right-click on the post title,
    "Copy address" and paste it into the text