![]() |
[QUOTE=CRGreathouse;239709]Great! Add it.
You may also want to register on RC so that your contributions show up under your name (or rather your chosen pseudonym) instead of under your IP address.[/QUOTE] maybe I'm having one difficulty for the file read: [CODE]read_file_completely(file)= a=Vec(Str(read(file)));for(x=1,#a,print(a[x]))[/CODE] if I don't go " before a path the : makes it end , if I do use " before and after it says variable name expected. when i then use, p="E:\\output.txt" it gives me *** error opening input file: E:\output.txt if we can get around that it's home free. doh i know why i deleted that file lol. [code](14:35) gp > read_file_completely(p="E:\\modulo.txt") 369369369369369369369369369369[/code] now we are getting somewhere as that is a line in the file, however not the first. |
[QUOTE=science_man_88;239700][url]http://rosettacode.org/wiki/Conditional_structures[/url]
this one is a long list lol; addhelp alias allocatemem apply [COLOR="Lime"]break [/COLOR] default error extern [COLOR="lime"]for fordiv forell forprime forstep forsubgroup forvec[/COLOR] getheap getrand getstack gettime global [COLOR="lime"]if [/COLOR] input install [COLOR="Lime"]kill[/COLOR] local my [COLOR="lime"]next[/COLOR] print print1 printp printp1 printtex quit read readvec return select setrand system [COLOR="lime"]trap[/COLOR] type [COLOR="lime"] until [/COLOR] whatnow [COLOR="lime"]while [/COLOR] write write1 writebin writetex[/QUOTE] Hmm. I wouldn't consider break a conditional structure, although it can be used with them. I don't think the page counts loops, although you're certainly right that they are actually conditional. kill and next aren't conditional in similar fashion to break. That leaves if and maybe trap. You could also add && and || (or their short forms & and |) because they short-circuit: 1&print("this happens"); 0&print("this doesn't"); |
[QUOTE=science_man_88;239711]when i then use, p="E:\\output.txt" it gives me *** error opening input file: E:\output.txt if we can get around that it's home free. doh i know why i deleted that file lol.[/QUOTE]
You might be able to make that work by reversing \ and /, I'm not sure. But I think this task is not solvable because GP evaluates the contents of the file so two files that are different but evaluate to the same thing can't be distinguished. |
[QUOTE=CRGreathouse;239715]You might be able to make that work by reversing \ and /, I'm not sure.
But I think this task is not solvable because GP evaluates the contents of the file so two files that are different but evaluate to the same thing can't be distinguished.[/QUOTE] I know what messes it up control characters like enter. If I straighten the file to one line it read it all if not it only evaluated the last line. though 0 seemed to mess it up as well if all numerical.if we can get past that, and I have an idea how,but I don't know how slow it would be. |
[QUOTE=science_man_88;239722]I know what messes it up control characters like enter. If I straighten the file to one line it read it all if not it only evaluated the last line.
though 0 seemed to mess it up as well if all numerical.if we can get past that, and I have an idea how,but I don't know how slow it would be.[/QUOTE] I'm not talking about escaping the backslashes "c:\\documents and settings\\foo\\bar.gp" but about replacing them with slashes, which as it happens do not need to be escaped: "c:/documents and settings/foo/bar.gp" This is, as I understand, an artifact of the system (cygwin? mingw?) that underlies the Windows version of GP. |
[QUOTE=CRGreathouse;239730]I'm not talking about escaping the backslashes
"c:\\documents and settings\\foo\\bar.gp" but about replacing them with slashes, which as it happens do not need to be escaped: "c:/documents and settings/foo/bar.gp" This is, as I understand, an artifact of the system (cygwin? mingw?) that underlies the Windows version of GP.[/QUOTE] I'm not talking in the file name I'm talking in the file if we can remove things like enters and 0's we could do it I think. The enters can be done with deleting the last line and repeated reading it into a Vec. For the 0's i was thinking of appending something on the front of each line then getting rid of it later but that's not so helpful. |
[QUOTE=science_man_88;239731]I'm not talking in the file name I'm talking in the file if we can remove things like enters and 0's we could do it I think. The enters can be done with deleting the last line and repeated reading it into a Vec. For the 0's i was thinking of appending something on the front of each line then getting rid of it later but that's not so helpful.[/QUOTE]
So all you have to do is read in the file, change the... wait... :smile: |
[QUOTE=CRGreathouse;239733]So all you have to do is read in the file, change the... wait... :smile:[/QUOTE]
[B]entire contents[/B] however if i load individual lines in and replace the enters and 0's when I'm done I did get the entire contents lol. |
[QUOTE=science_man_88;239735][B]entire contents[/B]
however if i load individual lines in and replace the enters and 0's when I'm done I did get the entire contents lol.[/QUOTE] 1. Not good enough; if you have to do something this means GP isn't doing it on its own. 2. You wouldn't get the contents of the file but the contents of the edited file; you'd need to remember what you changed and change it back. This would probably be very hard to do. |
[QUOTE=CRGreathouse;239736]1. Not good enough; if you have to do something this means GP isn't doing it on its own.
2. You wouldn't get the contents of the file but the contents of the edited file; you'd need to remember what you changed and change it back. This would probably be very hard to do.[/QUOTE] the enters are easy the 0's are the hard part. [CODE](16:28) gp > read_file_completely(file)= b=[];a=eval(Vec(Str(read(file))));b=concat(a,b); (16:28) gp > read_file_completely("e:\\modulo.txt") %279 = [3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9, 3, 6, 9][/CODE] also I can get the file up back in full i believe. I'd do it in the script lol. |
on another script:
[url]http://rosettacode.org/wiki/Day_of_the_week[/url] is in the can't be done etc. but: [url]http://rosettacode.org/wiki/Five_weekends[/url] in the to do list would use it. |
| All times are UTC. The time now is 23:08. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.