faustin
New Member
Failing to install BaCon on Manjaro...
Posts: 7
|
Post by faustin on Feb 10, 2019 17:18:40 GMT 1
Hi all, I encountered an converting/compiling error inside a Select-Casec structure and dont know how to solve this problem. This is the error it prints me: Compiler error:
Description: file 'paige.bac' line 28: CASE 7 Cause: member reference base type 'char' is not a structure or union ------------------------------ And here is the Select structure where the error occures: IF FILETYPE(array$[1]) == 1 THEN CALL readfile() ELSE
filetype = FILETYPE(array[1]) SELECT filetype 'ausgabe mit select CASE 0 PRINT "\nAn undefined Error occured" CASE 2 PRINT "\nThe given argument is a Directory" CASE 3 PRINT "\nThe given agrument is a character device" CASE 4 PRINT "\nThe given agrument is a block device" CASE 5 PRINT "\nThe given argument is a named pipe (FIFO)" CASE 6 PRINT "\nThe given argument is a symlink" CASE 7 PRINT "\nThe given argument is a socket" DEFAULT PRINT "\nUndefined error. What have you done?" END SELECT ENDIF ------------------------------- Can anyone help me? according to the official documentation, the syntax is alright... I simply dont know whats the matter.. Thank you for your help in advance. Faustin
|
|
|
Post by Pjot on Feb 10, 2019 18:13:06 GMT 1
Hi Faustin, Herzliches willkommen! If you put multiple statements on one line, then you must separate them with a colon symbol ':'. Even in case of comments. So in your code, we can see the following: SELECT filetype 'ausgabe mit select
But this syntax is not correct. If you want to place a comment on the same line, you have to tell BaCon that it is a new statement and separate it with a colon, as follows: SELECT filetype : 'ausgabe mit select
HTH Peter
|
|
faustin
New Member
Failing to install BaCon on Manjaro...
Posts: 7
|
Post by faustin on Feb 10, 2019 18:16:56 GMT 1
thx peter, but now he says:
Compiler error:
Description: file 'paige.bac' line 14: filetype = FILETYPE(array[1]) Cause: member reference base type 'char' is not a structure or union ----------------- i dont get it ...
|
|
|
Post by Pjot on Feb 10, 2019 18:26:51 GMT 1
Do you mean to say array[1] or array$[1] ?
BR Peter
|
|
faustin
New Member
Failing to install BaCon on Manjaro...
Posts: 7
|
Post by faustin on Feb 10, 2019 18:43:48 GMT 1
omg im so stupid xD this array is for command line arguments so its ment to be array$[1]....
thx peter ^^
but he still wont compile it now, says something about 4 warnings and 2 errors generated...
they might be in paige.bac.o ...
but i cant read the converted C statements he prints out, also the print out is too long
for my terminal so i cant see everything... but he referes to my subroutine... -------------
SUB readfile() OPEN array$[1] FOR READING AS file WHILE NOT(ENDFILE(array$[1])) READLN text$ FROM array$[1] IF NOT(ENDFILE(array$[1])) THEN PRINT text$ ENDIF WEND CLOSE FILE array$[1] ENDSUB -----------------
can you see any syntax failures in here? (sry for asking so much...)
|
|
|
Post by Pjot on Feb 10, 2019 18:56:07 GMT 1
Well, I can see multiple problems, but I am assuming that the 'array$' is a global array, so it is recognized by your SUB? If that is the case, then please read carefully the syntax for ENDFILE. As is mentioned there, it needs a filehandle and not a string as argument. So this code would be better: SUB readfile() OPEN array$[1] FOR READING AS file WHILE NOT(ENDFILE(file)) READLN text$ FROM file IF NOT(ENDFILE(file)) THEN PRINT text$ ENDIF WEND CLOSE FILE file ENDSUB
Or even shorter: SUB readfile() PRINT LOAD$(array$[1]) ENDSUB
HTH Peter
|
|
faustin
New Member
Failing to install BaCon on Manjaro...
Posts: 7
|
Post by faustin on Feb 10, 2019 19:03:56 GMT 1
now its working... im so thankful this program really made me mad xD
regards Faustin
|
|