I need help to declare a variable or a function in scheme - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: I need help to declare a variable or a function in scheme (/Thread-I-need-help-to-declare-a-variable-or-a-function-in-scheme) |
I need help to declare a variable or a function in scheme - PixLab - 12-07-2023 I'm trying to set a variable or a function but nothing is working, I always got "Illegal function", or "unbound variable", or whatnot A screenshot about what I try to do Having a variable will allow me to only input the variable in the other lines (in red), unless my thinking is wrong (that's also something to take in count). [attachment=10755] Here is the code, if I understood (while (> i 0) where i is a variable and I try to catch when i is equal to 1 How can I catch that number to change the variable depending that number? Code: (while (> i 0) I did try with (cond instead of (if I tried also starting with (begin (set! nothing is working, and let's face it, I'm also overwhelmed by the number of parenthesis RE: I need help to declare a variable or a function in scheme - pixelmixer - 12-07-2023 try VSC, free in linux, it's great, colored brackets for scheme help a lot. this code will print 'value = 1' in the error console. change #t to #f and it'll print 'value = 2' Code: (let* maybe try: (set! isInteractive (if (equal? i 1) RUN-INTERACTIVE RUN-WITH-LAST-VALS)) I'd probably do this though, out of habit. Code: (if (= i 1) (set! isInteractive RUN-INTERACTIVE) RE: I need help to declare a variable or a function in scheme - PixLab - 12-08-2023 Thanks @pixelmixer, but no, that was not the problem I found out why it was not working, and also I found out that I i comparison with a hard number was also wrong First I did not declare isInteractive in the top list of variable declaration, because I over looked this part where there is (let* (yeah I know... I should have paid attention) Then it was working backward, because of i comparing with 1 or 2, because I did not see i that i was the list of opened image misused by 1 on each loop, as I thought it was and ordered count number starting by 0 or 1, then I understood that I needed to save the original first count of the images somewhere for comparison, thus I created j which keep the full original number of the images in the list and the everything went according to the plan and tada... YEaaaa, all tested and working super nicely (it looks so simple now, but what a struggle ) [attachment=10760] EDIT: What a disappointment this script language... it runs RUN-WITH-LAST-VALS not the way as I expected, it seems to take in count the last values you did exported using File > Export... or the original quality of the JPG, I said "or", because it seems to be inconsistent. (need more tests to find out where come those values) In all case it does not take in count the last value of RUN-INTERACTIVE the first time the script is launched, NOR the hard coded values I did input in the script Also, if you add some more opened images after running the script, the next time you re-run the script, all added images AFTER the script first run will run in INTERACTIVE > you do need to refresh the script for the added images to not run interactive... I feel I did all that for nothing, I' thinking I'd just keep my first version with setting in the code itself, this version is consistent and does follow the settings coded RE: I need help to declare a variable or a function in scheme - PixLab - 12-08-2023 OK, I don't give up... yet. I might have found a solution, but it will be ugly, and I'm kind of good at being ugly But I do need to know how to add the "Tips" part in a scm like in Python, because people will never remember some "conditions" [attachment=10761] Some one knows how to do it? RE: I need help to declare a variable or a function in scheme - pixelmixer - 12-08-2023 the highs and lows of programming! RE: I need help to declare a variable or a function in scheme - PixLab - 12-08-2023 (12-08-2023, 11:51 AM)pixelmixer Wrote: the highs and lows of programming! Indeed! Anyway it's finished, I'm quite happy as it works fine, but I cannot find how to put the "Tips" or comment above |