Author Topic: Variable parameter test of Fas function  (Read 2573 times)

0 Members and 1 Guest are viewing this topic.

baitang36

  • Bull Frog
  • Posts: 213
Variable parameter test of Fas function
« on: April 01, 2020, 03:19:16 AM »
Look at the code first:

Code - Auto/Visual Lisp: [Select]
  1. (DEFUN t1(p1 p2 p3 p4 p5 p6 p7)
  2.   (if p1 (princ p1))
  3.   (if p2 (princ p2))
  4.   (if p3 (princ p3))
  5.   (if p4 (princ p4))
  6.   (if p5 (princ p5))
  7.   (if p6 (princ p6))
  8.   (if p7 (princ p7))
  9.   (princ)
  10. )
  11.  
  12. (t1 1)
  13. (t1 1 2)
  14. (t1 1 2 3)

This program can't run. It shows that there are too few parameters
However, it can be compiled into FAS
Loading this Fas also shows that there are too few parameters
Use WinHex to modify this FAS. It will work normally and the number of parameters can vary. Interested friends can try it out.

Offset          0   1   2   3  4   5   6  7    8   9  10  11 12 13 14 15
00000000   0D 0A 20 46 41 53 34 2D  46 49 4C 45 20 3B 20 44      FAS4-FILE ; D
00000016   6F 20 6E 6F 74 20 63 68  61 6E 67 65 20 69 74 21   o not change it!
00000032   0D 0A 32 31 33 0D 0A 39  20 24 14 07 01 07 00 09     213  9 $     
00000048   08 00 5C 00 00 09 07 00  5C 01 00 09 06 00 5C 02     \     \     \
00000064   00 09 05 00 5C 03 00 09  04 00 5C 04 00 09 03 00       \     \     
00000080   5C 05 00 09 02 00 5C 06  00 18 0F 00 03 08 00 67   \     \        g
00000096   0E 00 00 00 03 08 00 35  01 01 00 03 0A 57 00 00          5     W 
00000112   00 00 03 07 00 67 0E 00  00 00 03 07 00 35 01 01        g       5 
00000128   00 03 0A 57 00 00 00 00  03 06 00 67 0E 00 00 00      W       g   
00000144   03 06 00 35 01 01 00 03  0A 57 00 00 00 00 03 05      5     W     
00000160   00 67 0E 00 00 00 03 05  00 35 01 01 00 03 0A 57    g       5     W
00000176   00 00 00 00 03 04 00 67  0E 00 00 00 03 04 00 35          g       5
00000192   01 01 00 03 0A 57 00 00  00 00 03 03 00 67 0E 00        W       g 
00000208   00 00 03 03 00 35 01 01  00 03 0A 57 00 00 00 00        5     W   
00000224   03 02 00 67 0E 00 00 00  03 02 00 35 01 01 00 03      g       5   
00000240   0A 57 00 00 00 00 35 00  01 00 03 19 07 00 16 24    W    5        $
00000256   0D 0A 31 35 39 20 35 20  24 52 D1 6B 82 8D 6A 16     159 5 $R裬?j
00000272   03 61 2D 2B 46 14 18 41  55 52 43 48 62 65 BC 46    a-+F  AURCHbe糉
00000288   D0 6B 82 CE 58 16 35 5D  0D 20 47 27 96 11 07 1B   衚偽X 5]  G'? 
00000304   27 32 63 31 D6 16 82 23  CD CE 58 46 06 5D 57 24   '2c1??臀XF ]W$
00000320   47 44 76 11 57 2F 0D 5B  51 31 DD 74 D0 3A B2 8D   GDv W/ [Q1輙??
00000336   58 4A 31 5D 44 12 47 1D  43 1B 5B 1B 0D 39 62 6A   XJ1]D G C [  9bj
00000352   D9 77 D0 6A B9 8C 1B 12  31 5C 07 0E 53 15 43 11   賥衘箤  1\  S C
00000368   07 12 0E 0B 68 66 8D 46  D0 6A 8A 89 58 10 33 5D       hf F衘妷X 3]
00000384   0E 10 47 1E 71 10 32 1A  0F 0B 61 3B BF 47 E2 68     G q 2   a;縂鈎
00000400   B6 8F 5A 16 32 57 35 13  75 16 71 12 32 18 0F 0B   ?Z 2W5 u q 2   
00000416   61 3B B8 46 D1 6A 80 9B  16 B6 F0 20 4A C9 44 1C   a;窮裫€?娥 J蒁
00000432   0A 3B 66 61 73 34 20 63  72 75 6E 63 68 0A 3B 24    ;fas4 crunch ;$
00000448   3B 41 34 2F 31 2F 32 30                            ;A4/1/20

The red number was changed from 07 to 01
« Last Edit: April 01, 2020, 03:24:39 AM by baitang36 »

kpblc

  • Bull Frog
  • Posts: 396
Re: Variable parameter test of Fas function
« Reply #1 on: April 01, 2020, 05:39:35 AM »
Deleted. Sorry.
Sorry for my English.

jtoverka

  • Newt
  • Posts: 127
Re: Variable parameter test of Fas function
« Reply #2 on: April 01, 2020, 08:17:16 AM »

This program can't run. It shows that there are too few parameters
However, it can be compiled into FAS
Loading this Fas also shows that there are too few parameters
Use WinHex to modify this FAS. It will work normally and the number of parameters can vary. Interested friends can try it out.

I am very interested in this, what happens if you supply it with more arguments than the original function allows?

jtoverka

  • Newt
  • Posts: 127
Re: Variable parameter test of Fas function
« Reply #3 on: April 01, 2020, 04:13:59 PM »
I used sublime text as my Hex Editor, it works great. I tested this and played around and here are my results.

Below is the source code I used to compile this function
Code: [Select]
(DEFUN t1(p1 p2 p3 p4 p5 p6 p7)
  (if p1 (princ p1))
  (if p2 (princ p2))
  (if p3 (princ p3))
  (if p4 (princ p4))
  (if p5 (princ p5))
  (if p6 (princ p6))
  (if p7 (princ p7))
  (princ)
)

Below is the code I used to test this function. I just copied and pasted these into the command line to test this. I also used a variable range of arguments to test this.
Code: [Select]
(setq error (vl-catch-all-apply 't1 (list 1 2 3 4 5 6 7)))
(vl-catch-all-error-message error)

Below is the compiled FAS file shown in sublime text. I will make a note of the four hexadecimal digits in red. The first two digits control the minimum argument count to the function. The last two digits control the maximum argument count. The OP originally had 0107 for this value. It failed at 0 arguments and anything more than 7 arguments. With the values set to 00 and ff, the function accepts 0 arguments up until 255 arguments.


0d0a 2046 4153 342d 4649 4c45 203b 2044
6f20 6e6f 7420 6368 616e 6765 2069 7421
0d0a 3231 330d 0a39 2024 1407 00ff 0009
0800 5c00 0009 0700 5c01 0009 0600 5c02
0009 0500 5c03 0009 0400 5c04 0009 0300
5c05 0009 0200 5c06 0018 0f00 0308 0067
0e00 0000 0308 0035 0101 0003 0a57 0000
0000 0307 0067 0e00 0000 0307 0035 0101
0003 0a57 0000 0000 0306 0067 0e00 0000
0306 0035 0101 0003 0a57 0000 0000 0305
0067 0e00 0000 0305 0035 0101 0003 0a57
0000 0000 0304 0067 0e00 0000 0304 0035
0101 0003 0a57 0000 0000 0303 0067 0e00
0000 0303 0035 0101 0003 0a57 0000 0000
0302 0067 0e00 0000 0302 0035 0101 0003
0a57 0000 0000 3500 0100 0319 0700 1624
0d0a 3131 3720 3420 2419 d21c 104c 663f
c6e2 1b64 0612 1c40 7211 071a 0c48 6231
c90d d92f 117f 813f f4fa 1b64 0612 1c44
1158 4958 0d5b 5531 9a3b d34d 244c 040b
f4aa 025d 5720 4744 7211 0747 0d0b 2131
ca04 d317 4d4c 540d f4a1 656c 0712 7d15
0012 071a 0d17 7630 ca0d d314 134c 5e68
f4fa 315d 0e11 4712 4211 0e1a 0d1d 18f1
fc2f 3223 6f3b 04f0 0a3b 6661 7334 2063
7275 6e63 680a 3b24 3b41 342f 312f 3230


In another post I have asked around to creating lisp functions of variable argument counts so I can replace original functions to execute the intended code and write out to a file it's execution. This allows me to watch code being executed in real time. I will use this to help me achieve that goal. Thanks sir.

baitang36

  • Bull Frog
  • Posts: 213
Re: Variable parameter test of Fas function
« Reply #4 on: April 01, 2020, 10:56:42 PM »
Deleted. Sorry.
sony ?a japan co?

jtoverka

  • Newt
  • Posts: 127
Re: Variable parameter test of Fas function
« Reply #5 on: April 02, 2020, 08:41:39 AM »
How is one able to determine if an argument was passed versus an argument passed as nil?
example shown below
Code: [Select]
(t1 1 2 nil)
(t1 1 2)

baitang36

  • Bull Frog
  • Posts: 213
Re: Variable parameter test of Fas function
« Reply #6 on: April 02, 2020, 08:34:41 PM »
How is one able to determine if an argument was passed versus an argument passed as nil?
example shown below
Code: [Select]
(t1 1 2 nil)
(t1 1 2)
In my case, the two are the same。

baitang36

  • Bull Frog
  • Posts: 213
Re: Variable parameter test of Fas function
« Reply #7 on: April 02, 2020, 08:36:46 PM »
I used sublime text as my Hex Editor, it works great. I tested this and played around and here are my results.

Below is the source code I used to compile this function
Code: [Select]
(DEFUN t1(p1 p2 p3 p4 p5 p6 p7)
  (if p1 (princ p1))
  (if p2 (princ p2))
  (if p3 (princ p3))
  (if p4 (princ p4))
  (if p5 (princ p5))
  (if p6 (princ p6))
  (if p7 (princ p7))
  (princ)
)

Below is the code I used to test this function. I just copied and pasted these into the command line to test this. I also used a variable range of arguments to test this.
Code: [Select]
(setq error (vl-catch-all-apply 't1 (list 1 2 3 4 5 6 7)))
(vl-catch-all-error-message error)

Below is the compiled FAS file shown in sublime text. I will make a note of the four hexadecimal digits in red. The first two digits control the minimum argument count to the function. The last two digits control the maximum argument count. The OP originally had 0107 for this value. It failed at 0 arguments and anything more than 7 arguments. With the values set to 00 and ff, the function accepts 0 arguments up until 255 arguments.


0d0a 2046 4153 342d 4649 4c45 203b 2044
6f20 6e6f 7420 6368 616e 6765 2069 7421
0d0a 3231 330d 0a39 2024 1407 00ff 0009
0800 5c00 0009 0700 5c01 0009 0600 5c02
0009 0500 5c03 0009 0400 5c04 0009 0300
5c05 0009 0200 5c06 0018 0f00 0308 0067
0e00 0000 0308 0035 0101 0003 0a57 0000
0000 0307 0067 0e00 0000 0307 0035 0101
0003 0a57 0000 0000 0306 0067 0e00 0000
0306 0035 0101 0003 0a57 0000 0000 0305
0067 0e00 0000 0305 0035 0101 0003 0a57
0000 0000 0304 0067 0e00 0000 0304 0035
0101 0003 0a57 0000 0000 0303 0067 0e00
0000 0303 0035 0101 0003 0a57 0000 0000
0302 0067 0e00 0000 0302 0035 0101 0003
0a57 0000 0000 3500 0100 0319 0700 1624
0d0a 3131 3720 3420 2419 d21c 104c 663f
c6e2 1b64 0612 1c40 7211 071a 0c48 6231
c90d d92f 117f 813f f4fa 1b64 0612 1c44
1158 4958 0d5b 5531 9a3b d34d 244c 040b
f4aa 025d 5720 4744 7211 0747 0d0b 2131
ca04 d317 4d4c 540d f4a1 656c 0712 7d15
0012 071a 0d17 7630 ca0d d314 134c 5e68
f4fa 315d 0e11 4712 4211 0e1a 0d1d 18f1
fc2f 3223 6f3b 04f0 0a3b 6661 7334 2063
7275 6e63 680a 3b24 3b41 342f 312f 3230


In another post I have asked around to creating lisp functions of variable argument counts so I can replace original functions to execute the intended code and write out to a file it's execution. This allows me to watch code being executed in real time. I will use this to help me achieve that goal. Thanks sir.
Good experiment. I wish you success

hanhphuc

  • Newt
  • Posts: 64
Re: Variable parameter test of Fas function
« Reply #8 on: April 03, 2020, 11:55:16 PM »
can be multiple parameters like

setq x a y b expr...
while x expr...
repeat x expr...
foreach x expr...
progn ?






( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

jtoverka

  • Newt
  • Posts: 127
Re: Variable parameter test of Fas function
« Reply #9 on: April 04, 2020, 03:35:07 PM »
can be multiple parameters like

setq x a y b expr...
while x expr...
repeat x expr...
foreach x expr...
progn ?

Yes