zbyti Posted July 2, 2020 Share Posted July 2, 2020 (edited) @Gury Another dummy refactor :] I can simplify it more but a little bit later I'll create an "exchange" array Edited July 2, 2020 by zbyti exchange Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 2, 2020 Share Posted July 2, 2020 (edited) @Gury & @tebe Free Pascal have a associative array construct? EDIT: OK, 2D array was enough https://github.com/Gury8/effectus/pull/15 Edited July 2, 2020 by zbyti 2D array 1 Quote Link to comment Share on other sites More sharing options...
funkheld Posted July 2, 2020 Share Posted July 2, 2020 hello thanks. greeting. Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 2, 2020 Share Posted July 2, 2020 (edited) MEMO: core.pas, room for refactor, ReplaceKey approach. if procName = 'PRINT' then begin temp := ' Write(' + params2 + ');'; code.Add(temp); end else if procName = 'PRINTE' then begin //writeln('params[0] = ', Trim(params[0]), '*'); if (params[0] = '""') or (UpperCase(params[0]) = 'PRINTE()') then begin //writeln('2.) params[0] = ', params[0], '**'); params2 := QuotedStr(''); end; temp := ' Writeln(' + params2 + ');'; code.Add(temp); end else if procName = 'PRINTB' then begin temp := ' Write(' + params2 + ');'; code.Add(temp); end else if procName = 'PRINTBE' then begin temp := ' Writeln(' + params2 + ');'; code.Add(temp); end else if procName = 'PRINTI' then begin temp := ' Write(' + params2 + ');'; code.Add(temp); end else if procName = 'PRINTIE' then begin temp := ' Writeln(' + params2 + ');'; code.Add(temp); end else if procName = 'PRINTC' then begin temp := ' Write(' + params2 + ');'; code.Add(temp); end else if procName = 'PRINTCE' then begin temp := ' Writeln(' + params2 + ');'; code.Add(temp); end else if procName = 'PUTE' then begin temp := ' Writeln(' + QuotedStr(params2) + ');'; code.Add(temp); end else if procName = 'GRAPHICS' then begin temp := ''; Edited July 2, 2020 by zbyti Quote Link to comment Share on other sites More sharing options...
Gury Posted July 2, 2020 Author Share Posted July 2, 2020 (edited) Yeah, I did this intentionally for readability and clarity. I will leave the refactoring to you if you don't mind, of course. I will cope deeply in issues posted on repo. Edited July 2, 2020 by Gury Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 2, 2020 Share Posted July 2, 2020 4 minutes ago, Gury said: Yeah, I did this intentionally for readability and clarity. I can leave a comment in source code witch "strings" should be processed or create separate arrays specifically tailored to the routine. What do you think? Quote Link to comment Share on other sites More sharing options...
Gury Posted July 2, 2020 Author Share Posted July 2, 2020 Good idea, this would be great. And yes, growing code of core.pas will need some logical cut-to-pieces separation in the future. 1 Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 2, 2020 Share Posted July 2, 2020 This time I fixed my own bugs https://github.com/Gury8/effectus/pull/19 1 Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 3, 2020 Share Posted July 3, 2020 (edited) _MP_DEVICE_SYSUTILS: array [0..8] of string = ('OPEN','CLOSE','PUTD','PRINTD','PRINTBD','PRINTCD','PRINTID', 'GETD','INPUTSD'); _MP_STICK: array [0..3] of string = ('STICK','STRIG','PADDLE','PTRIG'); _MP_GRAPHICS: array [0..4] of string = ('GRAPHICS','PLOT','DRAWTO','COLOR','FILL'); _MP_SYSUTILS: array [0..5] of string = ('STRB','STRC','STRI','VALB','VALC','VALI'); if IsArrayElementInString(_MP_DEVICE_SYSUTILS, tempxy.strings[i]) then begin devicePtr.isDevice := true; devicePtr.isSySutils := true; end; if IsArrayElementInString(_MP_STICK, tempxy.strings[i]) then devicePtr.isStick := true; if IsArrayElementInString(_MP_GRAPHICS, tempxy.strings[i]) then devicePtr.isGraphics := true; if IsArrayElementInString(_MP_SYSUTILS, tempxy.strings[i]) then devicePtr.isSySutils := true; Because tempxy.strings contains whole source: Pos('Put', source) > 0 will be true for _MP_DEVICE_SYSUTILS etc. We need better solution. It's not true I don't know We need better solution :D Edited July 4, 2020 by zbyti We need better solution 1 Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 3, 2020 Share Posted July 3, 2020 @Gury Please make a 'dev' branch because throwing changes to the 'master' is not a good idea Quote Link to comment Share on other sites More sharing options...
funkheld Posted July 3, 2020 Share Posted July 3, 2020 (edited) Hi good afternoon. what is the task of this command? i don't understand the exact task of it. thank you. greeting -------------------------- loc=Locate(20,20) color=LOC -------------------------- Edited July 3, 2020 by funkheld Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 3, 2020 Share Posted July 3, 2020 loc := GetPixel(20, 20); SetColor(LOC); Quote Link to comment Share on other sites More sharing options...
funkheld Posted July 3, 2020 Share Posted July 3, 2020 (edited) I do not understand? what did loc get from Getpixel (20,20)? greeting Edited July 3, 2020 by funkheld 1 Quote Link to comment Share on other sites More sharing options...
ivop Posted July 3, 2020 Share Posted July 3, 2020 (edited) 55 minutes ago, funkheld said: I do not understand? what did loc get from Getpixel (20,20)? greeting Its color That is, the color of the pixel at location (20,20). Edited July 3, 2020 by ivop Quote Link to comment Share on other sites More sharing options...
funkheld Posted July 3, 2020 Share Posted July 3, 2020 (edited) and what are the advantages of this additional new command? - less memory ?? - faster execution ?? does the effort make sense? there is nothing more important and effectus to make it more effective? there are so many other vulnerabilities. i don't see the meaning of it. how can you save a Data.bin from a specific address and load it again? Edited July 3, 2020 by funkheld 1 Quote Link to comment Share on other sites More sharing options...
Gury Posted July 3, 2020 Author Share Posted July 3, 2020 ??? Funkheld... I don't see the meaning of nonsense you are talking about. The above code shows a standard command of Action! language library. The purpose of Effectus is simulating Action! as close as possible. And if you feel something is missing, go get a copy of Effectus source code and add missing features and fix existing bugs, nobody stops you from doing it. 1 Quote Link to comment Share on other sites More sharing options...
funkheld Posted July 3, 2020 Share Posted July 3, 2020 I can not change that. do not have the program knowledge therefore my question. greeting 1 Quote Link to comment Share on other sites More sharing options...
Gury Posted July 4, 2020 Author Share Posted July 4, 2020 22 hours ago, zbyti said: @Gury Please make a 'dev' branch because throwing changes to the 'master' is not a good idea Hi, do you mean dev branch on my repo? I am aware of the risk to merge directly on master, but I always re-think twice before I commit changes :) Luckily, GitHub automatically generates new commits on any changes, so all can be reviewed what changes were merged vs previous versions. Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 4, 2020 Share Posted July 4, 2020 (edited) OK, as You wish ---------- @Gury for some strange reasons, I came to the conclusion that POS is case insensitive and looks for substrings too, I was wrong program Playground; uses SySutils; const _MP_DEVICE_SYSUTILS: array [0..8] of string = ('OPEN','CLOSE','PUTD','PRINTD','PRINTBD','PRINTCD','PRINTID', 'GETD','INPUTSD'); function IsArrayElementInString(seek : array of string; str : string) : boolean; var i : integer; begin Result := false; for i := Low(seek) to High(seek) do begin if Pos(seek[i], str) > 0 then begin Result := true; break; end end; end; begin Writeln(IsArrayElementInString(_MP_DEVICE_SYSUTILS,'PRINTBD')); Writeln(IsArrayElementInString(_MP_DEVICE_SYSUTILS,'PrintBD')); Writeln(IsArrayElementInString(_MP_DEVICE_SYSUTILS,'printbd')); Writeln(IsArrayElementInString(_MP_DEVICE_SYSUTILS,'PRINT')); end. ; output TRUE FALSE FALSE FALSE But I swear I had a issue with substrings: // doubled delimiter - to be sure ;) temp := ',' + procName + ','; // RAND, PEEK, PEEKC, VALB, VALC, VALI, GETD, INPUTBD, INPUTCD, INPUTID temp01 := ' ' + funcVar + ' := ' + _MARKER + '(' + params2 + ');'; // INPUTB, INPUTC, INPUTI temp02 := ' ' + _MARKER + '(' + funcVar + ');'; // STICK, STRIG, PADDLE, PTRIG temp03 := ' ' + funcVar + ' := ' + _MARKER + '[' + params2 + '];'; // ReplaceKey function works on _REPLACMENT array temp04 := ReplaceKey(_MARKER, procName); if Pos(temp, ',RAND,PEEK,PEEKC,VALB,VALC,VALI,GETD,INPUTBD,INPUTCD,INPUTID,') > 0 then temp01 := ReplaceStr(temp01, _MARKER, temp04) else if Pos(temp, ',INPUTB,INPUTC,INPUTI,') > 0 then temp02 := ReplaceStr(temp02, _MARKER, temp04) else if Pos(temp, ',STICK,STRIG,PADDLE,PTRIG,') > 0 then temp03 := ReplaceStr(temp03, _MARKER, temp04); and added doubled delimiter instead of space... I recheck this later ------------------- I have internet failure since yesterday, so I'll take advantage of the summer weather Edited July 4, 2020 by zbyti summer Quote Link to comment Share on other sites More sharing options...
Gury Posted July 4, 2020 Author Share Posted July 4, 2020 Yes, conclusions can sometimes lead to different results But, never mind, it happens to me frequently. Hey, live a little Go out and enjoy the summer! Quote Link to comment Share on other sites More sharing options...
funkheld Posted July 4, 2020 Share Posted July 4, 2020 Hi good afternoon. did you put a reverse gear in windows. which version is current for windows? thank you. greeting Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 4, 2020 Share Posted July 4, 2020 (edited) substrings, ok I get it why previous code (ElementInString) give BINGO :] program Playground; uses SySutils; begin if Pos('GET', 'RAND PEEK PEEKC VALB VALC VALI GETD INPUTBD INPUTCD INPUTID') > 0 then writeln('bingo') else writeln('miss'); if Pos('GETD', 'RAND PEEK PEEKC VALB VALC VALI GETD INPUTBD INPUTCD INPUTID') > 0 then writeln('bingo') else writeln('miss'); if Pos('getd', 'RAND PEEK PEEKC VALB VALC VALI GETD INPUTBD INPUTCD INPUTID') > 0 then writeln('bingo') else writeln('miss'); if Pos('INPUT', 'RAND PEEK PEEKC VALB VALC VALI GETD INPUTBD INPUTCD INPUTID') > 0 then writeln('bingo') else writeln('miss'); writeln('---->with delimiter<----'); if Pos(',GET,', ',RAND,PEEK,PEEKC,VALB,VALC,VALI,GETD,INPUTBD,INPUTCD,INPUTID,') > 0 then writeln('bingo') else writeln('miss'); if Pos(',GETd,', ',RAND,PEEK,PEEKC,VALB,VALC,VALI,GETD,INPUTBD,INPUTCD,INPUTID,') > 0 then writeln('bingo') else writeln('miss'); if Pos(',GETD,', ',RAND,PEEK,PEEKC,VALB,VALC,VALI,GETD,INPUTBD,INPUTCD,INPUTID,') > 0 then writeln('bingo') else writeln('miss'); end. ; output bingo bingo miss bingo ---->with delimiter<---- miss miss bingo Edited July 4, 2020 by zbyti bingo Quote Link to comment Share on other sites More sharing options...
zbyti Posted July 4, 2020 Share Posted July 4, 2020 (edited) @Gury I think what UpperCase(str) is in too many places in the code, if we key words and proc/func replace with upper case during reading Action! source then we can drop this change in other places, what do you think? Or it's time to use regular expressions? Edited July 4, 2020 by zbyti regexp Quote Link to comment Share on other sites More sharing options...
Gury Posted July 4, 2020 Author Share Posted July 4, 2020 Sunny day is over, we are near desk again I agree with you completely, zbyti. It would be better to make all commands uppercase during reading source data. Then there no extra checking would be needed. Sometimes I just missed such thing and errors emerged. 1 Quote Link to comment Share on other sites More sharing options...
funkheld Posted July 5, 2020 Share Posted July 5, 2020 Hi good afternoon. could you create a new screen for PLOT etc.? thank you. greeting BYTE ARRAY screen=$3000 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.