MCPcopy Create free account
hub / github.com/abaplint/transpiler / set

Method set

packages/runtime/src/types/string.ts:32–62  ·  view source on GitHub ↗
(value: ICharacter | string | number | FieldSymbol)

Source from the content-addressed store, hash-verified

30 }
31
32 public set(value: ICharacter | string | number | FieldSymbol): String {
33 if (value instanceof FieldSymbol) {
34 if (value.getPointer() === undefined) {
35 throw new Error("GETWA_NOT_ASSIGNED");
36 }
37 return this.set(value.getPointer());
38 } else if (typeof value === "string") {
39 this.value = value;
40 } else if (typeof value === "number") {
41 this.value = value.toString();
42 } else if (value instanceof Character) {
43 // replace trailing blanks if the source is a Character string
44 this.value = value.getTrimEnd();
45 } else if (value instanceof Structure) {
46 this.value = value.getCharacter().trimEnd();
47 } else if (value instanceof Packed) {
48 const fixed = (value as Packed).toFixed(value.getDecimals());
49 const lv_sign = fixed.startsWith("-") ? "-" : " ";
50 this.value = (fixed.startsWith("-") ? fixed.slice(1) : fixed) + lv_sign;
51 } else if (value instanceof Integer) {
52 const lv_sign = (value as Integer).get() >= 0 ? " " : "-";
53 this.value = Math.abs((value as Integer).get()) + "";
54 this.value += lv_sign;
55 } else if (value instanceof Float) {
56 this.value = value.get() + "";
57 this.value = this.value.replace(",", ".");
58 } else {
59 this.value = value.get() + "";
60 }
61 return this;
62 }
63
64 public clear(): void {
65 this.value = "";

Callers 4

getOffsetMethod · 0.95
getOffsetMethod · 0.95
getOffsetMethod · 0.95
getOffsetMethod · 0.95

Calls 6

toStringMethod · 0.80
getTrimEndMethod · 0.80
getCharacterMethod · 0.80
getDecimalsMethod · 0.80
getMethod · 0.65
getPointerMethod · 0.45

Tested by

no test coverage detected