Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Program Record

m0rTaLm0rTaL Posts: 5Member
Hey, I seem to have a few problems
1. I want to use Records ex.
[code]User=Record
Username: string;
Password: string;[/code]
Now if I want to compare one of those with a string it doesnt work ex.
[code]User.Username = TEMP[/code]
it will give me an error ''Operator is not overloaded''
Why can't it compare the two variables?

2. How can I write an array into a string or read out an array to compare the single cells with a variable? Like the cell 1 of the array is equal to a sring? Here an example that I made that doesnt work [code]Example[1] = TEMP[/code] if I try that it will not work because it says cant read or write from this type of Variable

Can somebody help me there? Thx a lot in Advance

Comments

  • ActorActor Posts: 438Member
    You need to post more of your code. There's not enough here to tell what is happening.

  • ActorActor Posts: 438Member
    You need to post more of your code. There's not enough here to tell what is happening.

  • m0rTaLm0rTaL Posts: 5Member
    Here is my Code

    [code]program User_Registration;

    uses
    Crt;

    Type
    Userrecord= Record
    Password: string;
    Username: string;
    Password_ID: integer;
    Username_ID: integer;
    end;

    Var

    Index: integer;
    Temp: string;
    I: integer;
    n: integer;
    Database: array [0..100] of string;
    User: Userrecord;


    Begin



    Index:=0;
    randomize;
    writeln('User Registration Area');
    writeln('');
    writeln('');
    {Eingabe des Usernamen}
    write('Username: ');
    readln(Userrecord.Username);
    {
  • ActorActor Posts: 438Member
    : Here is my Code
    :
    : [code]: program User_Registration;
    :
    : uses
    : Crt;
    :
    : Type
    : Userrecord= Record
    : Password: string;
    : Username: string;
    : Password_ID: integer;
    : Username_ID: integer;
    : end;
    :
    : Var
    :
    : Index: integer;
    : Temp: string;
    : I: integer;
    : n: integer;
    : Database: array [0..100] of string;
    : [red]User: Userrecord;[/red]
    :
    :
    : Begin
    :
    :
    :
    : Index:=0;
    : randomize;
    : writeln('User Registration Area');
    : writeln('');
    : writeln('');
    : {Eingabe des Usernamen}
    : write('Username: ');
    : [red]readln(Userrecord.Username);[/red]
    [red]{
    [b]Userrecord[/b] is a type, not a variable.
    Use [b]User[/b] instead of [b]Userrecord[/b]
    }[/red]
    : {
  • Phat NatPhat Nat Posts: 757Member
    : Here is my Code
    :
    : [code]: program User_Registration;
    :
    : uses
    : Crt;
    :
    : Type
    : Userrecord= Record
    : Password: string;
    : Username: string;
    : Password_ID: integer;
    : Username_ID: integer;
    : end;
    :
    : Var
    :
    : Index: integer;
    : Temp: string;
    : I: integer;
    : n: integer;
    : Database: array [0..100] of string;
    : [color=Red]User: Userrecord;[/color]
    :
    :
    : Begin
    :
    :
    :
    : Index:=0;
    : randomize;
    : writeln('User Registration Area');
    : writeln('');
    : writeln('');
    : {Eingabe des Usernamen}
    : write('Username: ');
    : [color=Red]readln(Userrecord.Username);[/color]
    : {
  • m0rTaLm0rTaL Posts: 5Member
    Oh right I took out the begin end in the repeat until really wasnt needed. But when I change the readln userrecord.username into User.Username and try to read or write it will give an error that the variable isnt allowed. How can I have a record and read and write it? =/
  • ActorActor Posts: 438Member
    I get no errors. This works as far as getting the password.
    [code]
    program User_Registration;

    uses
    Crt;

    Type
    Userrecord = Record
    Password : string;
    Username : string;
    Password_ID : integer;
    Username_ID : integer;
    end;

    Var
    Index : integer;
    Temp : string;
    I : integer;
    n : integer;
    Database : array [0..100] of string;
    User : Userrecord;

    Begin
    Index:=0;
    randomize;
    writeln('User Registration Area');
    writeln('');
    writeln('');
    { Eingabe des Usernamen }
    write('Username: ');
    readln(User.Username);

    {
  • m0rTaLm0rTaL Posts: 5Member
    Thx a lot for the Help, now my prog works :D

    I used Lazarus IDE which uses FreePascal
    Now I use Turbo Pascal 7.0 and it works, how is that possible, does the FreePascal use a different Implementation? Oo
  • AtexAtex Posts: 268Member
    : I used Lazarus IDE which uses FreePascal
    : Now I use Turbo Pascal 7.0 and it works, how is that possible, does
    : the FreePascal use a different Implementation? Oo
    :

    FP has multiple modes, by default is not TP7 or Delphi compatible, so a program written in these dialects will not necessarily compile, unless you use the [b]{$mode ...}[/b] directive ( for TP7 use {$mode tp} ) to change the compatibility of the compiler. Read FP's documentation for more info, is well written and quite extensive.

  • m0rTaLm0rTaL Posts: 5Member
    Ah so it is the Information that is always on top of the program when you create a new one in Lazarus?

    I always deleted those informations ^^ Guess that must be the reason, thx for the great help =) ;-)
Sign In or Register to comment.