Jump to content

Leading zero's in attribute value


The Buzzard

Recommended Posts

Buzzard,

 

What is the purpose of this line?

 

;------------------------------------------------------------------------------------------
;
; F05b - Set Tile.
;
 (defun COMM_ST (key value lst)(set_tile key (if (nth (atoi (eval value)) lst)(eval value)(set value "0"))))
[color=red][b]  (mapcar (function (lambda (symbol value)(or (boundp symbol)(set symbol value)))) '(COMM:OTYP COMM:OMNT COMM:OUSE) '("0" "0" "0"))[/b][/color]
;
;------------------------------------------------------------------------------------------

Link to comment
Share on other sites

I surpised you are asking me that, You wrote it, I just supplied variables to it. I believe it is to set the corresponding popup lists to their first lines.

Link to comment
Share on other sites

I surpised you are asking me that, You wrote it, I just supplied variables to it. I believe it is to set the corresponding popup lists to their first lines.

 

I know I wrote it, which is why I wanted to see if you understood its purpose in the code, because it is certainly not part of the 'Set Tile' function. Furthermore, it seems to be not consistent with how you coded the same operation earlier in the code; which leads me to think there was a touch of copy/paste involved.

Link to comment
Share on other sites

I know I wrote it, which is why I wanted to see if you understood its purpose in the code, because it is certainly not part of the 'Set Tile' function. Furthermore, it seems to be not consistent with how you coded the same operation earlier in the code; which leads me to think there was a touch of copy/paste involved.

 

I am not sure I understand you. I do know its not part of the set_tile function, However it was written below the set_tile function when you supplied it to me. I just may have formatted it in a way that may seem confusing. Sorry about that.

Link to comment
Share on other sites

This is the way you had it.

Same code different format and variables.

I did not not change any part of this earlier in the code either.

Its what I posted from the start.

(defun set-tile ( key value lst )
   (set_tile key
     (if (nth (atoi (eval value)) lst)
       (eval value)
       (set value "0")
     )
   )
 )
 (mapcar
   (function
     (lambda ( symbol value )
       (or (boundp symbol) (set symbol value))
     )
   )
   '(*make *model *year) '("0" "0" "0")
 )

Link to comment
Share on other sites

Do you know exactly what the line of code does? I would not have written it to be associated with a subfunction.

 

Here is the code you supplied me with. I just added the 2 at the end of the name as I also have the earlier version of this. I did not change a thing.

Example2.dcl

Example2.lsp

Link to comment
Share on other sites

You didn't answer my question. I'm not saying you did change it, in fact, that is the reason I bring it up: directly copying code without notification would imply that you have written it yourself, hence I ask whether you understand what you claim to have written.

Link to comment
Share on other sites

You didn't answer my question. I'm not saying you did change it, in fact, that is the reason I bring it up: directly copying code without notification would imply that you have written it yourself, hence I ask whether you understand what you claim to have written.

 

I did not claim anything. You supplied me with this code. I am using this code. I also stated earlier this code is not completed. This is still work in progress. I posted this code looking for help with leading zeros. I did not put the headers in it yet as I have said it is not done. I always give credit to the people who have helped me and you know that very well. I am not finished yet. I will remove the posted code if this will put an end to this.

Link to comment
Share on other sites

Lee,

 

I removed the posted codes. Am I also to assume you do not want me to use your codes at this point?

If so, not a problem.

 

Do you understand the code you are using in your programs?

 

I don't mind you directly copying my code if you quote next to the lines you have directly copied, but it peeves me when you directly copy codes into your program blindly without thought about their function.

Link to comment
Share on other sites

Do you understand the code you are using in your programs?

 

I don't mind you directly copying my code if you quote next to the lines you have directly copied, but it peeves me when you directly copy codes into your program blindly without thought about their function.

 

Lee,

 

In the first place, This is my thread looking for some help which had nothing to do with what you are peeved over. I do not know what has happened to you, But it seems there is not much anyone has to do to get you in that mode. You have already told me you wish to have no further contact with me. I am just fine with that.

 

Please keep your promises.

 

I have told you and you know I have always admired your abilities and have learned a thing or two from you. For the record I still feel the same way, However I also feel that when you stir up nonsense like this, It is only intended to cause harm and embarassment to me and really has nothing to do with understanding if I had understood anything from your codes. I am not the only one who has gone through this with you I afraid. I have decided to write the code another way as not to give you any excuses for further harassment. I seem to doubt this will even help. On several occasions when I was tried to help others looking for help, Rather than you also trying to help these people you chose to insult my coding instead. I believe that conduct is contrary to to the way this forum was meant to operate. Up to this point it only confirms my suspicions as to your intentions. For the good of the forum I am again going to request that you do not contact or make reference to coding I post again in the future. I wish to leave this alone and put an end to it. I do not intend use your provided coding at all from this point on if that helps.

 

I wish you the best,

The Buzzard

Link to comment
Share on other sites

  • 11 years later...
On 9/2/2010 at 7:37 PM, alanjt said:

 

(defun AT:NumFix (s n)
 ;; Fix number string with leading zeros
 ;; s - Number string to fix
 ;; n - Number of characters for final string
 ;; Alan J. Thompson, 10.29.09
 (if (< (strlen s) n)
   (AT:NumFix (strcat "0" s) n)
   s
 )
)
 

 

 

(AT:NumFix "3" 4) -> "0003"

 

I hope you don't mind Alan but I've add support for minus values here also based on your function here and trimmed any existing padding (leading 0's) so this will work for any text that already has padding applied.

 

(defun AT:NumFix (numInput lenNew / lenInput minus result)
  (vl-load-com)
  ; Fix number string with leading zeros
  ; numInput - Number string to fix
  ; lenNew - Number of characters for final string
  ; Alan J. Thompson, 10.29.09. https://www.cadtutor.net/forum/topic/14276-alanjts-misc-useful-lisp-subroutines/?do=findComment&comment=151562
  ; 3dwannab 2022.07.09. Added minus values support
  (setq minus (vl-string-search "-" numInput))
  (setq numInput (vl-string-left-trim "0" numInput)) ;; Trims existing padding
  (setq lenInput (strlen numInput))
  ;; If a minus is found set the lenInput minus 1 and trim the minus. This will get added back later on
  (if minus 
    (progn 
      (setq lenInput (abs (- 1 (strlen numInput))))
      (setq numInput (vl-string-left-trim "-" numInput))
    )
  )
  (setq result (vl-princ-to-string numInput))
  (while (< (strlen result) lenNew)
    (setq result (strcat "0" result))
  ) ;_ while
  ;; Output the result depending on whether there's a minus or not
  (if minus 
    (strcat "-" result)
    result
  )
)
(princ (AT:NumFix "-003" 6)) ; -> -000003
(princ "\n")
(princ (AT:NumFix "003" 12)) ; -> 000000000003
(princ "\n")
(princ (AT:NumFix "00" 4)) ; -> 0000

 

Edited by 3dwannab
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...